Parcourir la source

feat: 详情页新增二维码扫码进来

xuqiaoying il y a 2 ans
Parent
commit
9aa4b948a8
3 fichiers modifiés avec 32 ajouts et 12 suppressions
  1. 3 8
      pages/webview/index.vue
  2. 13 1
      pages2/bank/detail.vue
  3. 16 3
      pages3/course/detail.vue

+ 3 - 8
pages/webview/index.vue

@@ -60,14 +60,11 @@ export default {
   onLoad(option) {
     console.log('--option-', option)
     this.options = option
-    console.log('userInfo:', this.userInfo)
   },
   onShow() {
-    console.log('22222222222222')
     if (this.$method.isGoLogin()) { // 扫二维码进来的没登录需要跳到登录页,登录后返回
       return;
     }
-    console.log('33333333333333')
     if (this.options.scene) {
       this.optObj = {}
       let arrs = decodeURIComponent(this.options.scene).split('&')
@@ -79,16 +76,14 @@ export default {
     // 有a字段是标识是扫二维码进来的
     if (this.optObj.a == 1) {
       if (!this.userInfo) {
-        console.log('没有userInfo')
         this.getInfo()
       } else {
-        console.log('有userInfo')
         this.getParam()
       }
       
     } else {
       this.url = decodeURIComponent(decodeURIComponent(this.options.url))
-      console.log('小程序进来的url:', this.url)
+      // console.log('小程序进来的url:', this.url)
       let index = this.url.indexOf('?')
       let paramArr = this.url.slice(index + 1).split('&')
       let paramObj = {}
@@ -98,7 +93,7 @@ export default {
       this.paramObj = paramObj
       this.sectionType = this.paramObj.sectionType || 2 // 默认直播,回放的加了sectionType=3
       this.vid = this.paramObj.vid || ''
-      console.log('paramObj', paramObj)
+      // console.log('paramObj', paramObj)
       this.studyLog(paramObj)
     }
   },
@@ -111,7 +106,7 @@ export default {
 			this.$api.getInfo({ fromPlat: 1 }).then(res => {
 				if(res.data.code == 200){
 					this.$store.state.userInfo = res.data.data
-          console.log('this.userInfo', this.userInfo)
+          // console.log('this.userInfo', this.userInfo)
           this.getParam()
 				}
 			})

+ 13 - 1
pages2/bank/detail.vue

@@ -229,7 +229,19 @@ export default {
 		},
 	},
 	onLoad(option) {
-		this.id = option.id;
+		if (option.scene) {
+			// scene 生成二维码扫码进来的
+			let optObj = {}
+			let arrs = decodeURIComponent(option.scene).split('&')
+			for (let i = 0; i < arrs.length; i++) {
+				optObj[arrs[i].split('=')[0]] = arrs[i].split('=')[1]
+			}
+			this.id = optObj.id
+		} else {
+			// 小程序正常跳转的
+			// this.id => goodsId
+			this.id = option.id
+		}
 		this.getDetail();
 		this.goodsBankList();
 		this.getIsBuy() // 判断是否已经购买过该课程

+ 16 - 3
pages3/course/detail.vue

@@ -271,9 +271,22 @@ export default {
 		},
 	},
 	onLoad(option) {
-		// this.id => goodsId
-		this.id = option.id;
-		this.goodsType = option.goodsType
+		console.log('option:', option);
+		if (option.scene) {
+			// scene 生成二维码扫码进来的
+			let optObj = {}
+			let arrs = decodeURIComponent(option.scene).split('&')
+			for (let i = 0; i < arrs.length; i++) {
+				optObj[arrs[i].split('=')[0]] = arrs[i].split('=')[1]
+			}
+			this.id = optObj.id
+			this.goodsType = optObj.goodsType
+		} else {
+			// 小程序正常跳转的
+			// this.id => goodsId
+			this.id = option.id
+			this.goodsType = option.goodsType
+		}
 		this.getDetail()
 		this.goodsCourseList()
 		this.appCommonGoodsCourseModuleFreeExamList();