6
0
Fork 0

对接商品分类接口

hui.zhou
h30830569 2022-05-17 17:43:57 +08:00
parent 2fa2537f1a
commit 082d16cfbc
3 changed files with 36 additions and 1110 deletions

View File

@ -1,9 +1,8 @@
<template>
<view>
<u-navbar :border-bottom="false" back-icon-color="#000000" :background="{ background: '#ffffff' }">
<view class="pl-base w-full">
<u-search @change="Change" placeholder="" v-model="searchText" :show-action="false"></u-search>
<u-search @change="Change" placeholder=" " @search="Search" v-model="searchText" :show-action="false"></u-search>
</view>
<view slot="right" class="pr-base" @tap="$u.routeAuth('/pages/auxiliary_cart/index')">
<image class="w-48rpx h-48rpx" src="/static/images/cart/short-cart.png" mode="scaleToFill" />
@ -60,6 +59,7 @@
key: 0,
sort: '', //price sales release_at price -price
searchText: '',
category:'',
downOption: {
auto: false,
},
@ -81,15 +81,18 @@
return windowHeight - statusBarHeight - 44 + 'px';
},
},
onLoad({
searchText
}) {
onLoad({ searchText,category}) {
this.searchText = searchText
this.category = category
},
methods: {
Change(e) {
if (e == '') uni.navigateBack()
},
Search(){
this.category=''
this.downCallback()
},
downCallback() {
this.dataList = []
this.$refs.uWaterfall.clear();
@ -102,6 +105,7 @@
let obj = {
page: page.num,
per_page: page.size,
category:this.category ,
keyword: this.searchText,
sort: this.sort
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
<template>
<view class="u-wrap">
<loading-view v-if="isFirstLoading"></loading-view>
<!-- 顶部导航栏 -->
<u-navbar :border-bottom="false" :is-back="false" :background="{ background: '#ffffff' }">
<view class="pl-base w-full" @tap="$u.route('/pages/search/search')">
@ -24,28 +25,29 @@
</scroll-view>
<scroll-view :scroll-top="scrollRightTop" scroll-y scroll-with-animation class="right-box" @scroll="rightScroll">
<view class="page-view">
<view class="class-item" :id="'item' + index" v-for="(item , index) in tabbar" :key="index">
<view class="item-title">
<text>{{item.name}}</text>
</view>
<!-- 广告位 -->
<view class="my-20rpx">
<image class="w-full h-200rpx" src="https://img1.baidu.com/it/u=1597761366,2823600315&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" mode="aspectFill"></image>
<block v-for="(item,index) in tabbar" :key="index">
<view class="class-item" :id="'item' + index" v-for="(item1 , index1) in item.children" :key="index1">
<view class="item-title">
<text>{{item1.name}}</text>
</view>
<!-- 广告位 -->
<view class="my-20rpx" v-if="item1.icon">
<image class="w-full h-200rpx" :src="item1.icon" mode="aspectFill"></image>
</view>
<view class="item-container">
<view @click="$u.route('/pages/search/search_result', {category: item2.id,})" class="thumb-box" v-for="(item2, index2) in item1.children" :key="index2">
<image v-if="item2.icon" class="item-menu-image" :src="item2.icon" mode=""></image>
<view class="item-menu-name">{{item2.name}}</view>
</view>
</view>
</view>
<view class="item-container">
<view class="thumb-box" v-for="(item1, index1) in item.foods" :key="index1">
<image class="item-menu-image" :src="item1.icon" mode=""></image>
<view class="item-menu-name">{{item1.name}}</view>
</view>
</view>
</view>
</block>
</view>
</scroll-view>
</view>
</view>
</template>
<script>
import classifyData from './data.js';
export default {
data() {
return {
@ -55,21 +57,28 @@
menuHeight: 0, //
menuItemHeight: 0, // item
itemId: '', // scroll-viewid
tabbar: classifyData,
tabbar:[],
menuItemPos: [],
arr: [],
scrollRightTop: 0, // scroll-view
timer: null, //
isFirstLoading:true,
}
},
onLoad() {
setTimeout(()=>{
this.isFirstLoading=false
},300)
this.getDate()
},
onReady() {
this.getMenuItemTop()
},
methods: {
async getDate(){
const resData=await this.$api.get('/v1/product/categories')
this.tabbar=resData
},
//
async swichMenu(index) {
if(this.arr.length == 0) {