diff --git a/pages/shop/GoodsCon/index.vue b/pages/shop/GoodsCon/index.vue index e2142d0..b2bd15f 100644 --- a/pages/shop/GoodsCon/index.vue +++ b/pages/shop/GoodsCon/index.vue @@ -732,6 +732,7 @@ export default { console.log("getLaunchOptionsSync", uni.getLaunchOptionsSync()) console.log("getEnterOptionsSync", uni.getEnterOptionsSync()) uni.removeStorageSync('couponId') + const pageQuery = Object.assign({}, this.resolvePageQuery(), options || {}) const from = options.from const id = options.id switch (from) { @@ -779,10 +780,10 @@ export default { if (url && url.productId) { this.id = url.productId } else if (options.id) { - this.id = options.id || null - this.partnerId = options.partnerId || null - this.activityId = this._route.query.activityId - this.source = this._route.query.from || '' + this.id = pageQuery.id || options.id || null + this.partnerId = pageQuery.partnerId || options.partnerId || null + this.activityId = Number(pageQuery.activityId || pageQuery.drawActivityId || 0) + this.source = pageQuery.from || '' } else { const obj = uni.getEnterOptionsSync() if (options.scene != null || obj.query.scene != null) { @@ -847,6 +848,18 @@ export default { } }, methods: { + resolvePageQuery() { + if (this.$yroute && this.$yroute.query) { + return this.$yroute.query + } + if (this.$route && this.$route.query) { + return this.$route.query + } + if (this._route && this._route.query) { + return this._route.query + } + return {} + }, gift() { this.goCat(2) }, diff --git a/pkg_user/views/gift/gift.vue b/pkg_user/views/gift/gift.vue index 04568d3..dd26b6a 100644 --- a/pkg_user/views/gift/gift.vue +++ b/pkg_user/views/gift/gift.vue @@ -299,11 +299,12 @@ export default { } }, onLoad(opts) { - this.cartId = opts.cartId - this.isGroupBuy = opts.isGroupBuy === '1' - this.isCountyLotteryGift = opts.from === 'countyLottery' || opts.isCountyLotteryGift === '1' || !!opts.drawActivityId + const pageQuery = Object.assign({}, this.resolvePageQuery(), opts || {}) + this.cartId = pageQuery.cartId + this.isGroupBuy = pageQuery.isGroupBuy === '1' + this.isCountyLotteryGift = pageQuery.from === 'countyLottery' || pageQuery.isCountyLotteryGift === '1' || !!pageQuery.drawActivityId // this.couponId = opts.couponId || 0 - this.discount = opts.discount + this.discount = pageQuery.discount if(this.isGroupBuy) { this.getGroupBuyInfo() } else { @@ -332,10 +333,39 @@ export default { } }, methods: { + resolvePageQuery() { + if (this.$yroute && this.$yroute.query) { + return this.$yroute.query + } + if (this.$route && this.$route.query) { + return this.$route.query + } + if (this._route && this._route.query) { + return this._route.query + } + return {} + }, getCouponId() { if (this.isCountyLotteryGift) return 0 return this.couponId || 0 }, + isCountyLotteryCartItem(item) { + return Number( + (item && item.drawActivityId) || + (item && item.productInfo && item.productInfo.drawActivityId) || + 0 + ) > 0 + }, + syncCountyLotteryGiftFlag(item) { + if (!this.isCountyLotteryGift && this.isCountyLotteryCartItem(item)) { + this.isCountyLotteryGift = true + } + if (!this.isCountyLotteryGift) return + this.couponTitle = '' + if (Number(this.couponId || 0) !== 0) { + this.couponId = 0 + } + }, adjustCoverListForProductStory(coverList, productInfo, defaultTemplate) { if (!productInfo || !productInfo.productStory) { return { @@ -436,6 +466,7 @@ export default { this.giftNotice = res.data.giftCardGiftNotice this.orderKey = res.data.orderKey this.goodsInfo = goodsInfo + this.syncCountyLotteryGiftFlag(goodsInfo) this.templateId = template.id this.defaultIndex = this.coverList.findIndex(item => item.id === this.templateId) console.log(this.defaultIndex, 'defaultIndex'); @@ -522,6 +553,7 @@ export default { this.giftNotice = res.data.giftCardGiftNotice this.orderKey = res.data.orderKey this.goodsInfo = goodsInfo + this.syncCountyLotteryGiftFlag(goodsInfo) this.templateId = template.id this.selectedCover = template.cover this.giftImage = template.image