diff --git a/common/js/request.js b/common/js/request.js index 0bf5967..ee157b5 100644 --- a/common/js/request.js +++ b/common/js/request.js @@ -336,5 +336,13 @@ export default { data: params }) return res[1].data; + }, + async getGoodsDetail(params) { + let res = await uni.request({ + url: '/goods/goods/getDetail', + method: 'POST', + data: params + }) + return res[1].data.data; } } diff --git a/components/goods-card/horizontal-goods-card.vue b/components/goods-card/horizontal-goods-card.vue index 51e927f..c81d8f9 100644 --- a/components/goods-card/horizontal-goods-card.vue +++ b/components/goods-card/horizontal-goods-card.vue @@ -9,7 +9,7 @@ - {{product.discountsPrice}} + {{product.discountPrice}} ¥{{product.goodsPrice}} diff --git a/pages/order/order-detail.vue b/pages/order/order-detail.vue index 8bf3c35..e8b9561 100644 --- a/pages/order/order-detail.vue +++ b/pages/order/order-detail.vue @@ -164,16 +164,10 @@ this.offBindEvent(); }, methods: { - async loadData(params) { + async loadData(params) { + console.log(params) // this.pickedProductList = await this.$api.data('pickedProductList'); - this.pickedProductList = params.pickedProductList; - // TODO: 遍历查询每个product的总价并赋值,此处先赋定值 - for (let i = 0; i < this.pickedProductList.length; i++) { - for (let j = 0; j < this.pickedProductList[i].product.length; j++) { - this.pickedProductList[i].product[j].discountsPrice = 100; - this.pickedProductList[i].product[j].goodsPrice = 200; - } - } + this.pickedProductList = params.pickedProductList; this.formInfo.defaultAddress = await this.$api.data('defaultAddress'); }, bindEvent() { @@ -208,7 +202,7 @@ shopInfo.product.forEach((productInfo) => { productInfo.pickedList.forEach((pickedSpecs) => { goodsList.push({ - goodsId: pickedSpecs.id, + goodsStandardId: pickedSpecs.id, num: pickedSpecs.pickedNum, }) }) diff --git a/pages/product/filtered-products.vue b/pages/product/filtered-products.vue index 7b91652..0ab7bd2 100644 --- a/pages/product/filtered-products.vue +++ b/pages/product/filtered-products.vue @@ -206,7 +206,7 @@ }, showDetails(productItem) { let params = { - id: productItem.goodsId + goodsId: productItem.goodsId } uni.navigateTo({ url: '/pages/product/product-detail?params=' + encodeURIComponent(JSON.stringify(params)) diff --git a/pages/product/product-detail.vue b/pages/product/product-detail.vue index 69559cc..6460068 100644 --- a/pages/product/product-detail.vue +++ b/pages/product/product-detail.vue @@ -16,20 +16,22 @@ - - - - + + + + + + - {{curProductSpecs.salePrice}} + {{curProductSpecs.discountPrice}} - ¥{{curProductSpecs.price}} + ¥{{curProductSpecs.goodsPrice}} @@ -38,7 +40,7 @@ - 佣金:{{curProductSpecs.commission}} + 佣金:{{curProductSpecs.groupPrice}} - + - + - {{item.name}} + 服务保障 - {{item.desc}} + + {{item.areaName}}, + + + + + + + + + 服务区域 + + + + {{item.areaName}}, + + + + + + + + + 备注 + + + {{productDetail.remark}} 选择品类 - + {{item.name}} + :class="curProductSpecs.goodsStandardId === item.goodsStandardId ? 'line-main-color' : 'line-default'" + @click="chooseSpecs(item)">{{item.goodsStandardName}} - - 详情图片...... + @@ -146,7 +173,7 @@ - + @@ -161,15 +188,15 @@ productPick }, data() { - return { + return { + productDetail: {}, + detailPicList: [], swiperList: [], curProductSpecs: {}, productInfo: {}, guaranteeList: [], - specsList: [], isShowAllSpecs: false, reviewers: [], - productDetailImgUrl: '', productVideoPlaying: false, showTopNav: false, curTopNav: 0, @@ -178,7 +205,7 @@ orderNow: false, totalPickCount: 0, ifHasCsMsg: true, - swiperPicUrls: [] + picUrls: [] } }, onLoad(options) { @@ -197,20 +224,28 @@ }, methods: { async loadData(params) { - let productDetail = await this.$api.data('productDetail'); - this.swiperList = productDetail.swiperList; - this.productInfo = productDetail.productInfo; - this.guaranteeList = productDetail.guaranteeList; - this.specsList = productDetail.specsList; - this.curProductSpecs = this.specsList[0]; - this.reviewers = productDetail.reviewers; - this.productDetailImgUrl = productDetail.productDetailImgUrl; - this.shopInfo = productDetail.shopInfo; - for (let i = 0; i < this.swiperList.length; i++) { - if (this.swiperList[i].type === 'image') { - this.swiperPicUrls.push(this.swiperList[i].url); - } - } + let productDetailMock = await this.$api.data('productDetail'); + this.productDetail = await this.$request.getGoodsDetail({ + goodsId: params.goodsId + }); + // 默认规格 + this.curProductSpecs = this.productDetail.goodsStandardList[0]; + // 轮播图 + this.swiperList = this.productDetail.goodsImgsMap["0"]; + // 详情图 + this.detailPicList = this.productDetail.goodsImgsMap["1"]; + // 用于点击放大查看图片 + this.swiperList.forEach((picItem) => { + this.picUrls.push(picItem.imgUrl); + }) + this.detailPicList.forEach((picItem) => { + this.picUrls.push(picItem.imgUrl); + }) + + this.guaranteeList = productDetailMock.guaranteeList; + this.productInfo = productDetailMock.productInfo; + this.reviewers = productDetailMock.reviewers; + this.shopInfo = productDetailMock.shopInfo; }, bindEvent() { uni.$on('product-detail_add2Cart', this.add2Cart); @@ -224,16 +259,16 @@ showAllSpecs() { this.isShowAllSpecs = !this.isShowAllSpecs; }, - clickSwiper(e, item) { - if (item.type === 'image') { + clickSwiper(e, item, type) { + if (type === 1) { this.viewImage(item.url); - } else if (item.type === 'video') { + } else if (type === 0) { this.pauseVideo(e); } }, viewImage(url) { uni.previewImage({ - urls: this.swiperPicUrls, + urls: this.picUrls, current: url }); }, @@ -292,7 +327,7 @@