wuguojie 4 месяцев назад
Родитель
Сommit
9e2899e8fd
2 измененных файлов с 12 добавлено и 7 удалено
  1. 11 6
      src/pages/index/index.vue
  2. 1 1
      src/pages/my/my.vue

+ 11 - 6
src/pages/index/index.vue

@@ -165,7 +165,7 @@
 						</view>
 					</view>
 					<view class="coupon-btn-box">
-						<view class="coupon-btns" @click="handleReceiveCoupon">立即领取</view>
+						<button class="coupon-btns" :loading="receiveLoading" @click="handleReceiveCoupon">立即领取</button>
 					</view>
 				</view>
 				<view class="coupon-close" @click="handleCloseCoupon">
@@ -217,7 +217,8 @@ export default {
         },
       ],
 	  myCouponObj: {},
-	  query: []
+	  query: [],
+	  receiveLoading: false
     }
   },
   onShow() {
@@ -236,14 +237,11 @@ export default {
     this.getCoupon()
     // 获取推荐数据
     this.getRanking()
-	// 获取优惠券
-	if(this.query.shareType === 'COUPON') {
-		this.showCoupons()
-	}
   },
   onLoad(query) {
     // 静默登录
 	this.query = query
+	console.log('参数', query)
     // 1. 获取URL中的code和state参数
     const urlParams = new URLSearchParams(window.location.search)
     const code = urlParams.get('code')
@@ -258,6 +256,10 @@ export default {
       window.location.replace(targetUrl)
     }
     if (query.code) this.onLogin(query.code)
+	// 获取优惠券
+	if(query.shareType === 'COUPON' && query.shareContentId) {
+		this.showCoupons()
+	}
 
     // uni.setStorageSync('wx_copenid', 'o-HEJ6VP2YNi0HPeLaIHCQsQD69s')
     // uni.setStorageSync('access-token', 'eyJhbGciOiJIUzUxMiJ9.eyJ0ZjoiOiJlNGNiNjY0ZS05Y2Q5LTRlOWItODU1Yy0zN2RlNjRiOGI3ZDIifQ.xj0ZBULLc7wYOaUgDQd_zbeynbJ8M3M-UQM6JPUKcV9rIWVlax8dJnU247om39nialcKnklKFZ8m8oerc-NY0A')
@@ -284,9 +286,12 @@ export default {
 	},
 	// 领取优惠券
 	handleReceiveCoupon() {
+		this.receiveLoading = true
+		if (!this.$utils.checkLogin({ type: 'modal' })) return;
 		receiveCoupon({
 			...this.myCouponObj
 		}).then(res => {
+			this.receiveLoading = false
 			if(res.data.code == 200) {
 				this.$nextTick(() => {
 					this.$refs.popup.close()

+ 1 - 1
src/pages/my/my.vue

@@ -222,7 +222,7 @@ export default {
 		// 获取优惠劵
 		getCoupon() {
 			let params = {
-				openid: uni.getStorageSync('wx_copenid')
+				receiveOpenId: uni.getStorageSync('wx_copenid')
 			}
 			getCoupon(params).then(res => {
 				if (res.data.code == 200 && res.data.data.length > 0) {