浏览代码

feat: 扫二维码进来商品详情页的新用户注册接口新加sc码

xuqiaoying 2 年之前
父节点
当前提交
419f5c9535
共有 3 个文件被更改,包括 13 次插入2 次删除
  1. 4 0
      pages2/register/register.vue
  2. 2 0
      pages3/course/detail.vue
  3. 7 2
      pages4/login/login.vue

+ 4 - 0
pages2/register/register.vue

@@ -391,10 +391,14 @@ export default {
 						code:this.form.code,
 						pwd:this.form.pwd
 						}
+					if (uni.getStorageSync('newUser_sc')) {
+						datas['shareCode'] = uni.getStorageSync('newUser_sc')
+					}
 					that.$api.registerUser(datas).then(
 						res => {
 							that.isUse = false
 							if (res.data.code == 200) {
+								uni.removeStorageSync('newUser_sc')
 								uni.showModal({
 									title: '提示',
 									content: '注册成功',

+ 2 - 0
pages3/course/detail.vue

@@ -279,8 +279,10 @@ export default {
 			for (let i = 0; i < arrs.length; i++) {
 				optObj[arrs[i].split('=')[0]] = arrs[i].split('=')[1]
 			}
+			// console.log('optObj:', optObj);
 			this.id = optObj.id
 			this.goodsType = optObj.goodsType
+			uni.setStorageSync('newUser_sc', optObj.sc)
 		} else {
 			// 小程序正常跳转的
 			// this.id => goodsId

+ 7 - 2
pages4/login/login.vue

@@ -116,6 +116,7 @@ export default {
 			codeTips: '',
 			isUse:false,
 			scanCode: '', // pc端扫码登录获取的标志码
+			newUser_sc: '', // 用户扫码进来详情页获取的sc
 			isBack:false
 		};
 	},
@@ -129,7 +130,9 @@ export default {
 		// 	this.scanCode = option.scanCode
 		// }
 		// this.from = option.from; 
-		
+		if (uni.getStorageSync('newUser_sc')) {
+			this.newUser_sc = uni.getStorageSync('newUser_sc')
+		}
 	},
 	onShow() {
 		// 获取code
@@ -149,7 +152,8 @@ export default {
 			this.$api.wxLogin({
 				code: this.code,
 				encryptedData: e.detail.encryptedData,
-				iv:  e.detail.iv
+				iv:  e.detail.iv,
+				shareCode: this.newUser_sc
 			}).then(res => {
 				if (res.data.code == 200) {
 					this.loginCallback(res, 'wxlogin')
@@ -351,6 +355,7 @@ export default {
 		loginCallback(res, types) {
 			console.log('登录页面:', this.isBack)
 			// if(res.data.data && res.data.data.full_info){
+				uni.removeStorageSync('newUser_sc')
 				//信息完善,直接进入页面
 				uni.setStorageSync('user_account', res.data.data.user_account);
 				uni.setStorageSync('token', res.data.data.token);