From 4bc06cd1a6e223f6e2b884bc5e094480424f6583 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Fri, 10 Jun 2022 13:05:03 +0800 Subject: [PATCH] 1 --- src/pages/product_details/index.vue | 14 +++++++++----- src/pages/welcome/index.vue | 21 ++++++++++++++------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/pages/product_details/index.vue b/src/pages/product_details/index.vue index 5513611..6311514 100644 --- a/src/pages/product_details/index.vue +++ b/src/pages/product_details/index.vue @@ -382,6 +382,9 @@ export default { isFirstLoading: true, isNull: false, loading: false, + // 商品SPU-ID + productId: '', + // 选择的SKU-ID skuId: '', number: 1, products: {}, @@ -478,11 +481,11 @@ export default { return price } }, - onLoad({ skuId, showShrough }) { + onLoad({ productId, showShrough }) { if (showShrough) { this.showShrough = showShrough; } - this.skuId = skuId; + this.productId = productId; this.getProducts(); this.$store.dispatch('goods/getCartList'); }, @@ -495,7 +498,7 @@ export default { let code = this.user.code ? this.user.code : ''; let shareObj = { title: this.detail.name, - path: `/pages/product_details/index?skuId=${this.skuId}&invite_code=${code}`, + path: `/pages/product_details/index?product=${this.productId}&invite_code=${code}`, imageUrl: this.detail.cover, }; return shareObj; @@ -604,8 +607,9 @@ export default { async getProducts() { try { this.loading = true; - const resData = await this.$api.get(`/v1/product/products/${this.skuId}`); + const resData = await this.$api.get(`/v1/product/products/${this.productId}`); this.products = resData; + this.skuId = this.products?.id if (resData?.sku?.is_bargaing) { this.bargainOrderLog(); @@ -649,7 +653,7 @@ export default { this.loading = true; const resData = await this.$api.get(`/v1/product/sku/${this.skuId}`); this.products = resData; - + if (resData?.sku?.is_bargaing) { this.bargainOrderLog(); } diff --git a/src/pages/welcome/index.vue b/src/pages/welcome/index.vue index 0fffdbf..bb089da 100644 --- a/src/pages/welcome/index.vue +++ b/src/pages/welcome/index.vue @@ -17,12 +17,20 @@ onLoad(e) { const scene = strToParams(decodeURIComponent(e.scene)) console.log(scene); + + // 优先存储 invite_code + if (scene.invite_code) { + uni.setStorageSync('INVITE_CODE', scene.invite_code) + } + + // 产品详细页 if (scene.product) { uni.redirectTo({ url: '/pages/product_details/index?skuId=' + scene.product }) - uni.setStorageSync('INVITE_CODE', scene.code) - } else if (scene.order_pre) { + } + // 扫码下单 + else if (scene.order_pre) { setTimeout(async () => { uni.showLoading({ title: '加载中', @@ -31,19 +39,18 @@ const obj = { id: scene.order_pre } - const { - order_id - } = await this.$api.post(`/v1/order-pre/order`, obj) + const { order_id } = await this.$api.post(`/v1/order-pre/order`, obj) uni.hideLoading() uni.redirectTo({ url: '/pages/order_details/index?id=' + order_id }) }, 1000) - }else if(scene.invite_code){ + } + // 默认跳转首页 + else { uni.redirectTo({ url: '/pages/index/index' }) - uni.setStorageSync('INVITE_CODE', scene.invite_code) } }, }