From f5f7d733ff85fab4859d06372e1937e78e37a788 Mon Sep 17 00:00:00 2001 From: RIceWqy <1840169763@qq.com> Date: Mon, 25 Dec 2023 22:59:03 +0800 Subject: [PATCH] goods --- pages/goods/detail.vue | 31 +++++++++++++++++++++++++++++-- pages/goods/list.vue | 34 +++++++++++++++++++++++++++++----- shopro/request/apis.js | 12 ++++++++++++ shopro/request/request.js | 2 +- 4 files changed, 71 insertions(+), 8 deletions(-) diff --git a/pages/goods/detail.vue b/pages/goods/detail.vue index db7280d..9fc648b 100644 --- a/pages/goods/detail.vue +++ b/pages/goods/detail.vue @@ -361,7 +361,34 @@ export default { getGoodsDetail() { let that = this; return new Promise((resolve, reject) => { - that.$http( + that.$jsonrpc('goods.detail',{id: that.$Route.query.id},'', + false).then(res=>{ + console.log(res) + if (res.error.code === 200) { + that.showEmpty = false; + that.goodsInfo = res.result; + if (that.goodsInfo.activity_type) { + that.activityRules.status = that.goodsInfo.activity.status_code; + } + share.setShareInfo({ + title: that.goodsInfo.title, + desc: that.goodsInfo.subtitle, + image: that.goodsInfo.image, + params: { + page: 2, + pageId: that.$Route.query.id + } + }); + that.getCommentList(); + resolve(res.result); + } else { + resolve(false); + // that.$u.toast(res.msg); + that.showEmpty = true; + that.showEmptyText = res.result.title; + } + }); + /* that.$http( 'goods.detail', { id: that.$Route.query.id @@ -392,7 +419,7 @@ export default { that.showEmpty = true; that.showEmptyText = res.msg; } - }); + }); */ }); }, // 商品评论 diff --git a/pages/goods/list.vue b/pages/goods/list.vue index fee57a4..fd460c2 100644 --- a/pages/goods/list.vue +++ b/pages/goods/list.vue @@ -109,12 +109,13 @@ export default { methods: { // 瀑布流相关 async splitData() { + if (!this.tempList.length) return; let item = this.tempList[0]; if (!item) return; // 分左右 - if (this.leftHeight < this.rightHeight) { + /* if (this.leftHeight < this.rightHeight) { this.leftHeight += item.activity_discounts_tags.length ? 350 : 330; this.leftList.push(item); } else if (this.leftHeight > this.rightHeight) { @@ -123,8 +124,11 @@ export default { } else { this.leftHeight += item.activity_discounts_tags.length ? 350 : 330; this.leftList.push(item); - } - + } */ + let count = Math.floor(Math.random() * (10 - 1 + 1)) + 1; + count % 2 === 0 ? this.leftHeight +=350 : this.rightHeight +=330; + count % 2 === 0 ? this.leftList.push(item): this.rightList.push(item) ; + // 移除临时列表的第一项,如果临时数组还有数据,继续循环 this.tempList.splice(0, 1); if (this.tempList.length) { @@ -176,20 +180,40 @@ export default { getGoodsList() { let that = this; that.loadStatus = 'loading'; + console.log("good list ") + this.$jsonrpc('goods.list2',this.listParams,'加载中...').then(res=>{ + console.log(res) + if (this.searchVal && !historyTag.includes(this.searchVal)) { + let searchHistoryArr = JSON.stringify(this.getArr(historyTag, this.searchVal)); + uni.setStorageSync('searchHistoryArr', searchHistoryArr); + } + if (res.error.code === 200) { + that.goodsList = [...that.goodsList, ...res.result.resultGoods]; + that.isEmpty = !that.goodsList.length; + that.lastPage = res.result.last_page ; + that.loadStatus = that.listParams.page < res.result.last_page ? 'loadmore' : 'nomore'; + that.tempList = res.result.resultGoods; + that.splitData(); + } + + }) + + /* that.$http('goods.lists', that.listParams, '加载中...').then(res => { if (this.searchVal && !historyTag.includes(this.searchVal)) { let searchHistoryArr = JSON.stringify(this.getArr(historyTag, this.searchVal)); uni.setStorageSync('searchHistoryArr', searchHistoryArr); } if (res.code === 1) { + console.log(res) that.goodsList = [...that.goodsList, ...res.data.data]; that.isEmpty = !that.goodsList.length; that.lastPage = res.data.last_page; that.loadStatus = that.listParams.page < res.data.last_page ? 'loadmore' : 'nomore'; that.tempList = res.data.data; that.splitData(); - } - }); + } + }); */ } } }; diff --git a/shopro/request/apis.js b/shopro/request/apis.js index 952e016..4d7b7f2 100644 --- a/shopro/request/apis.js +++ b/shopro/request/apis.js @@ -162,6 +162,18 @@ export default { method: "GET", // desc: '商品列表', }, + list: { + url: "goods/list", + auth: false, + method: "GET", + // desc: '商品列表', + }, + list2: { + url: "goods/list2", + auth: false, + method: "GET", + // desc: '商品列表', + }, seckillList: { url: "goods/seckillList", auth: false, diff --git a/shopro/request/request.js b/shopro/request/request.js index b057ee6..3eedc06 100644 --- a/shopro/request/request.js +++ b/shopro/request/request.js @@ -148,7 +148,7 @@ async requestJson(options = {}) { options.data = createJsonRpc options.method="POST" - + console.log(createJsonRpc) /* let mergeUrl = Request.isUrl(options.url) ? options.url : (options.baseUrl + options.url) if (JSON.stringify(options.params) !== '{}') { let query = Request.addQueryString(options.params);