From 1437dcbe4d30ecb1dc231c30acf209d34ad8cf5a Mon Sep 17 00:00:00 2001 From: wangdong <1551135706@qq.com> Date: Thu, 16 May 2024 14:36:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/goods/list.vue | 1 + pages/search/index.vue | 11 ++- pages/shopList/index.vue | 8 +- pages/shopList/shopPage.vue | 138 +++++++++++----------------------- pages/squareDynamic/index.vue | 43 ++++++----- 5 files changed, 80 insertions(+), 121 deletions(-) diff --git a/pages/goods/list.vue b/pages/goods/list.vue index f710b7f..192686b 100644 --- a/pages/goods/list.vue +++ b/pages/goods/list.vue @@ -411,6 +411,7 @@ sortPrice: Number(app.sortPrice), categoryId: (app.options.categoryId || app.options.categoryId != undefined) ? app.options .categoryId : 0, + merchantId: app.options.merchantId, // goodsName: app.options.search || '', page: pageNo, keywords: keywords.length > 0 ? keywords.join(',') : '', diff --git a/pages/search/index.vue b/pages/search/index.vue index 54cbe17..e354568 100644 --- a/pages/search/index.vue +++ b/pages/search/index.vue @@ -85,6 +85,7 @@ page: 1, goodsList: [], category_id:0, + merchantId: '', isHot: true, } }, @@ -98,7 +99,8 @@ }, onLoad(op) { - this.category_id=op.category_id + this.category_id=op.category_id + this.merchantId = op.merchantId this.getHot() this.chartsGoodsJingHandle() }, @@ -150,7 +152,7 @@ }, searchGoods(item) { uni.navigateTo({ - url: '/pages/goods/list?search=' + item + url: `/pages/goods/list?search=${item}&merchantId=${this.merchantId}` }) }, getSearchInfo() { @@ -159,9 +161,10 @@ this.searchList.push(this.searchValue) this.searchList = Array.from(new Set(this.searchList)); uni.setStorageSync('searchList', this.searchList) - } + } + console.log(this.merchantId); uni.redirectTo({ - url: '/pages/goods/list?search=' + this.searchValue+'&categoryId=' + this.category_id + url: `/pages/goods/list?search=${this.searchValue}&categoryId=${this.category_id}&merchantId=${this.merchantId}` }) }, chartsGoodsJingHandle() { diff --git a/pages/shopList/index.vue b/pages/shopList/index.vue index fabb20b..35ba78b 100644 --- a/pages/shopList/index.vue +++ b/pages/shopList/index.vue @@ -31,7 +31,7 @@ 进店 - + ¥{{ good.goods_price_min }} @@ -163,6 +163,12 @@ url: `/pages/shopList/shopPage?id=${item.merchant_id}`, }) }, + // 跳转商品详情页 + onGoodDetail(goodsId) { + this.$navTo('pages/goods/detail', { + goodsId + }) + }, }, }; diff --git a/pages/shopList/shopPage.vue b/pages/shopList/shopPage.vue index f7d61d1..37bfc28 100644 --- a/pages/shopList/shopPage.vue +++ b/pages/shopList/shopPage.vue @@ -57,19 +57,19 @@ - - {{ item }} - - + + {{ item.name }} + + - - - {{ item.name }} + + + {{ item.goods_name }} - ¥{{ item.price }} - ¥{{ item.originPrice }} + ¥{{ item.goods_price_min>0?Number(item.goods_price_min):0.00 }} + ¥{{ item.line_price_min>0?Number(item.line_price_min):'' }} @@ -96,6 +96,7 @@ import * as Api from '@/api/shop/index'; import * as cstegory from '@/api/category' import * as GoodsApi from '@/api/goods' + import { debounce } from 'lodash'; export default { data() { @@ -106,91 +107,24 @@ }, id: '', scrollTop: 0, - shopDetail: { - logo: '', - name: '小米旗舰店', - label: '商家直营 正品保障' - }, - goodsCate: [ - { id: 1, name: '热门分类', children: [{ id: 1, name: '二级分类1'}, { id: 1, name: '二级分类2'}, { id: 1, name: '二级分类3'}, { id: 1, name: '二级分类4'}, { id: 1, name: '二级分类5'}]}, - { id: 1, name: '手机', children: [{ id: 1, name: '二级分类1'}, { id: 1, name: '二级分类2'}, { id: 1, name: '二级分类3'}, { id: 1, name: '二级分类4'}, { id: 1, name: '二级分类5'}]}, - { id: 1, name: '平板', children: [{ id: 1, name: '二级分类1'}, { id: 1, name: '二级分类2'}, { id: 1, name: '二级分类3'}, { id: 1, name: '二级分类4'}, { id: 1, name: '二级分类5'}]}, - { id: 1, name: '电脑', children: [{ id: 1, name: '二级分类1'}, { id: 1, name: '二级分类2'}, { id: 1, name: '二级分类3'}, { id: 1, name: '二级分类4'}, { id: 1, name: '二级分类5'}]}, - { id: 1, name: '冰箱', children: [{ id: 1, name: '二级分类1'}, { id: 1, name: '二级分类2'}, { id: 1, name: '二级分类3'}, { id: 1, name: '二级分类4'}, { id: 1, name: '二级分类5'}]}, - ], + shopDetail: {}, + goodsCate: [], firstCate: '', secondCate: '', - activeFilter: '综合', + activeFilter: 'all', filterDirection: 'ASC', - filterList: ['综合', '价格', '折扣', '销量'], + filterList: [ + { name: '综合', value: 'all' }, + { name: '价格', value: 'price' }, + { name: '折扣', value: 'discount' }, + { name: '销量', value: 'sales' }], isTop: false, page: 1, limit: 10, loadTitle: '', loading: false, finished: true, - goods: [ - // { - // pic: '', - // name: '小米耳机最新版小米耳机最新版', - // price: 208.00, - // originPrice: 809, - // }, - // { - // pic: '', - // name: '小米耳机最新版小米耳机最新版', - // price: 208.00, - // originPrice: 809, - // }, - // { - // pic: '', - // name: '小米耳机最新版小米耳机最新版', - // price: 208.00, - // originPrice: 809, - // }, - // { - // pic: '', - // name: '小米耳机最新版小米耳机最新版', - // price: 208.00, - // originPrice: 809 - // }, - // { - // pic: '', - // name: '小米耳机最新版小米耳机最新版', - // price: 208.00, - // originPrice: 809, - // }, - // { - // pic: '', - // name: '小米耳机最新版小米耳机最新版', - // price: 208.00, - // originPrice: 809, - // }, - // { - // pic: '', - // name: '小米耳机最新版小米耳机最新版', - // price: 208.00, - // originPrice: 809, - // }, - // { - // pic: '', - // name: '小米耳机最新版小米耳机最新版', - // price: 208.00, - // originPrice: 809, - // }, - // { - // pic: '', - // name: '小米耳机最新版小米耳机最新版', - // price: 208.00, - // originPrice: 809, - // }, - // { - // pic: '', - // name: '小米耳机最新版小米耳机最新版', - // price: 208.00, - // originPrice: 809, - // }, - ] + goods: [] }; }, // computed: { @@ -203,8 +137,14 @@ // } // }, watch: { + firstCate() { + this.goods = []; + this.page = 1; + this.loading = false; + this.finished = false; + this.getGoodsList(); + }, secondCate() { - console.log(this.secondCate); this.goods = []; this.page = 1; this.loading = false; @@ -234,16 +174,21 @@ search() { // 跳转商品搜索 uni.navigateTo({ - url: '/pages/search/index' + url: `/pages/search/index?merchantId=${this.id}` }) }, changeFilter(item) { if (item !== this.activeFilter) { this.activeFilter = item; this.filterDirection = 'ASC'; - } else if (item === '价格') { + } else if (item === 'price') { this.filterDirection = this.filterDirection === 'ASC' ? 'DESC' : 'ASC'; } + this.goods = []; + this.page = 1; + this.loading = false; + this.finished = false; + this.getGoodsList(); }, openScrollTo() { uni.pageScrollTo({ @@ -284,18 +229,17 @@ * 获取商品列表 * @param {number} pageNo 页码 */ - getGoodsList() { + getGoodsList: debounce(function() { if (this.loading || this.finished) { return; } this.loadTitle = ""; const param = { sortType: this.activeFilter, - sortPrice: this.filterDirection === 'ASC' ? 1 : 0, - categoryId: this.secondCate, - // goodsName: app.options.search || '', + sortPrice: this.filterDirection === 'DESC' ? 1 : 0, + categoryId: this.secondCate || this.firstCate, + merchantId: this.id, page: this.page++, - pageSize: 10 } GoodsApi.list(param) .then(result => { @@ -306,12 +250,18 @@ this.finished = data.length < 10; this.loadTitle = this.finished ? "已全部加载完" : "上拉加载更多"; }) - }, + }, 500), toCart() { uni.switchTab({ url: '/pages/cart/index' }) }, + // 跳转商品详情页 + onGoodDetail(goodsId) { + this.$navTo('pages/goods/detail', { + goodsId + }) + }, } }; diff --git a/pages/squareDynamic/index.vue b/pages/squareDynamic/index.vue index a1d7472..a6b178e 100644 --- a/pages/squareDynamic/index.vue +++ b/pages/squareDynamic/index.vue @@ -22,7 +22,7 @@ 全文 - + @@ -72,26 +72,7 @@ return { tabList: ['推荐', '精选', '晒单', '日常', '文章'], activeTab: '推荐', - dynamicList: [ - // { - // avatar: '', - // name: '幽默的先生', - // time: '11:23', - // content: '今天天气真好啊!碧蓝的天空,绿油油的油菜花,空 中飘香,远远的山脉看着忽远忽近。', - // pic: ['', '', '', '', ''], - // likeNum: 1000, - // isLike: true, - // }, - // { - // avatar: '', - // name: '幽默的先生', - // time: '4月12日 11:21', - // content: '今天天气真好啊!碧蓝的天空,绿油油的油菜花,空 中飘香,远远的山脉看着忽远忽近。远远的山脉看着忽远忽近。远远的山脉看着忽远忽近。远远的山脉看着忽远忽近。远远的山脉看着忽远忽近。', - // pic: ['', '', '', '', ''], - // likeNum: 1000, - // isLike: false, - // }, - ], + dynamicList: [], page: 1, limit: 10, loadTitle: '', @@ -124,7 +105,6 @@ frontColor: '#000000', backgroundColor: '#E7F1FC', }); - this.getDynamicList(); const sys = uni.getSystemInfoSync(); this.windowWidth = sys.windowWidth; this.windowHeight = sys.windowHeight; @@ -139,6 +119,13 @@ this.offsetHeight = data.height / 2; }).exec(); }, + onShow() { + this.loading = false; + this.finished = false; + this.page = 1; + this.dynamicList = []; + this.getDynamicList(); + }, methods: { async getDynamicList() { if (this.loading || this.finished) { @@ -298,6 +285,18 @@ this.isMove = false; }, + + previewImage(idx, images) { + console.log(idx, images); + const arr = []; + images.forEach(v => { + arr.push(v.external_url); + }) + uni.previewImage({ + current: idx, + urls: arr, + }) + }, }, };