diff --git a/pages/goods_details/index.vue b/pages/goods_details/index.vue index e17fa03..61ee2e1 100644 --- a/pages/goods_details/index.vue +++ b/pages/goods_details/index.vue @@ -389,6 +389,25 @@ + + + + + + + + + + + + 我已同意《购物协议》 + + + 继续购物 + {{ Number(countdown_timer) > 0 ? countdown_timer : '继续购物' }} + 关闭 + + @@ -584,6 +603,13 @@ url: '/pages/user/index' }, ], + // 购物协议 + buy_agreement: '', + countdown: 10, + is_agree: true, + news: {}, + countdown_timer: 0, + intervalId: '', }; }, computed:{ @@ -1097,6 +1123,10 @@ that.$set(that.storeInfo, 'community', res.data.community); that.$set(that.storeInfo, 'top_name', res.data.top_name); that.$set(that.storeInfo, 'atmosphere_pic', res.data.atmosphere_pic); + // 购物协议 + that.$set(that, 'buy_agreement', res.data.buy_agreement ? (res.data.buy_agreement.content || '') : ''); + if(that.buy_agreement) that.is_agree = false; + that.$set(that, 'countdown', res.data.countdown ? (Number(res.data.countdown) > 0 ? Number(res.data.countdown) : 10) : 10); }) if (that.isLogin) { that.downloadFilePromotionCode(); @@ -1347,8 +1377,24 @@ * 加入购物车 */ goCat: function(news) { - let that = this, - productSelect = that.productValue[this.attrValue]; + let that = this; + // 是否同意协议 + if(!that.is_agree){ + that.news = news; + that.$refs.agreePopup.open('bottom'); + // 开始倒计时 + that.countdown_timer = that.countdown; + that.intervalId = setInterval(function () { + --that.countdown_timer; + if(that.countdown_timer <= 0){ + if (that.intervalId) clearInterval(that.intervalId); + } + }, 1000); // 每秒更新一次时间 + return false + } + + // 购买流程 + let productSelect = that.productValue[this.attrValue]; //打开属性 if (that.attrValue) { //默认选中了属性,但是没有打开过属性弹窗还是自动打开让用户查看默认选中的属性 @@ -1723,11 +1769,67 @@ uni.hideLoading(); } }); - } + }, + // 继续购买 + continueShopping(){ + this.closeAgreePopup(); + this.goCat(this.news); + }, + closeAgreePopup(){ + this.$refs.agreePopup.close(); + } } }