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

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
<template> <template>
<view class="u-wrap"> <view class="u-wrap">
<loading-view v-if="isFirstLoading"></loading-view>
<!-- 顶部导航栏 --> <!-- 顶部导航栏 -->
<u-navbar :border-bottom="false" :is-back="false" :background="{ background: '#ffffff' }"> <u-navbar :border-bottom="false" :is-back="false" :background="{ background: '#ffffff' }">
<view class="pl-base w-full" @tap="$u.route('/pages/search/search')"> <view class="pl-base w-full" @tap="$u.route('/pages/search/search')">
@ -24,28 +25,29 @@
</scroll-view> </scroll-view>
<scroll-view :scroll-top="scrollRightTop" scroll-y scroll-with-animation class="right-box" @scroll="rightScroll"> <scroll-view :scroll-top="scrollRightTop" scroll-y scroll-with-animation class="right-box" @scroll="rightScroll">
<view class="page-view"> <view class="page-view">
<view class="class-item" :id="'item' + index" v-for="(item , index) in tabbar" :key="index"> <block v-for="(item,index) in tabbar" :key="index">
<view class="item-title"> <view class="class-item" :id="'item' + index" v-for="(item1 , index1) in item.children" :key="index1">
<text>{{item.name}}</text> <view class="item-title">
</view> <text>{{item1.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> <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>
<view class="item-container"> </block>
<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>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import classifyData from './data.js';
export default { export default {
data() { data() {
return { return {
@ -55,21 +57,28 @@
menuHeight: 0, // menuHeight: 0, //
menuItemHeight: 0, // item menuItemHeight: 0, // item
itemId: '', // scroll-viewid itemId: '', // scroll-viewid
tabbar: classifyData, tabbar:[],
menuItemPos: [], menuItemPos: [],
arr: [], arr: [],
scrollRightTop: 0, // scroll-view scrollRightTop: 0, // scroll-view
timer: null, // timer: null, //
isFirstLoading:true,
} }
}, },
onLoad() { onLoad() {
setTimeout(()=>{
this.isFirstLoading=false
},300)
this.getDate()
}, },
onReady() { onReady() {
this.getMenuItemTop() this.getMenuItemTop()
}, },
methods: { methods: {
async getDate(){
const resData=await this.$api.get('/v1/product/categories')
this.tabbar=resData
},
// //
async swichMenu(index) { async swichMenu(index) {
if(this.arr.length == 0) { if(this.arr.length == 0) {