wuguojie 4 месяцев назад
Родитель
Сommit
b1b94c3a10
2 измененных файлов с 40 добавлено и 21 удалено
  1. 18 11
      src/pages/index/index.vue
  2. 22 10
      src/pages/login/wxLogin.vue

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

@@ -287,17 +287,24 @@ 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()
-				})
-			}
-		})
+		const token = uni.getStorageSync('access-token') || '';
+		const isLogin = !!token;
+		if(!isLogin) {
+			receiveCoupon({
+				...this.myCouponObj
+			}).then(res => {
+				this.receiveLoading = false
+				if(res.data.code == 200) {
+					this.$nextTick(() => {
+						this.$refs.popup.close()
+					})
+				}
+			})
+		} else{
+			uni.navigateTo({
+				url: `/pages/login/wxLogin?shareType=${this.query.shareType}&shareContentId=${this.query.shareContentId}`
+			})
+		}
 	},
     // 获取城市
     getCity() {

+ 22 - 10
src/pages/login/wxLogin.vue

@@ -59,13 +59,14 @@
 				isLogin: false,
 				token: '',
 				look:false,
-        isWechat:true,
-        phone: '',
-        code: '',
-        countdown: 60,
-        timer: null,
-        isSendingCode: false,
-        isBinding: false
+				isWechat:true,
+				phone: '',
+				code: '',
+				countdown: 60,
+				timer: null,
+				isSendingCode: false,
+				isBinding: false,
+				query: {}
 			}
 		},
     computed: {
@@ -82,6 +83,12 @@
       }else {
         this.isWechat = navigator.userAgent.toLowerCase().includes('micromessenger');
       }
+	  if(options.shareType === 'COUPON' && options.shareContentId) {
+		this.query = {
+			shareType: options.shareType,
+			shareContentId: options.shareContentId
+		}
+	  }
     },
 		methods: {
 			goPrivacy(){
@@ -99,10 +106,15 @@
 			},
 			login() {
 				if (this.look) {
-          let ruri = encodeURIComponent('https://city.baoxianzhanggui.com/fragrance/');
-          let appid = 'wx9dc677bd41e82569'
+					let ruri = ''
+					if(this.query.shareType && this.query.shareContentId) {
+						_this.back();
+					} else {
+						ruri = encodeURIComponent('https://city.baoxianzhanggui.com/fragrance/');
+					}
+					let appid = 'wx9dc677bd41e82569'
 				 	window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${ruri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
-        } else {
+				} else {
 					uni.showToast({
 						title: '请同意《用户协议》和《隐私政策》',
 						icon: 'none'