XSLu08042 1 mese fa
parent
commit
f1faec5c35
4 ha cambiato i file con 46 aggiunte e 71 eliminazioni
  1. 3 0
      App.vue
  2. 12 12
      api/course.js
  3. 2 0
      note.txt
  4. 29 59
      pages_course/video.vue

+ 3 - 0
App.vue

@@ -4,6 +4,9 @@
 	var isSocketOpen=false;
 	var socket=null;
 	export default {
+		globalData: {
+			appId: 'wxd70f99287830cb51', // appId 看课授权登录微信appId
+		},
 		data() {
 			return {
 			};

+ 12 - 12
api/course.js

@@ -2,27 +2,27 @@ import Request from '../common/request.js';
 let request = new Request().http
 
 export function loginByMp(data) {
- 	 return request('/app/wx/courseLogin2',data,'POST','application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
+ 	 return request('/app/wx/courseLogin2',data,'POST','application/json;charset=UTF-8');
  }
 
 // 获取真实链接
 export function getRealLink(data) {
-	return request('/app/course/getRealLink', data, 'GET','','https://h5api.his.cdwjyyh.com');
+	return request('/app/course/getRealLink', data, 'GET','');
 }
 
 // h5课程简介
 export function getH5CourseByVideoId(data) {
-	return request('/app/course/getH5CourseByVideoId', data, 'GET','','https://h5api.his.cdwjyyh.com');
+	return request('/app/course/getH5CourseByVideoId', data, 'GET','');
 }
 
 // h5课程详情加问答
 export function getH5CourseVideoDetails(data) {
-	return request('/app/course/getH5CourseVideoDetails', data, 'GET','','https://h5api.his.cdwjyyh.com');
+	return request('/app/course/getH5CourseVideoDetails', data, 'GET','');
 }
 
 // 答题发红包
 export function courseAnswer(data) {
-	return request('/app/course/courseAnswer', data, 'POST', 'application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
+	return request('/app/course/courseAnswer', data, 'POST', 'application/json;charset=UTF-8');
 }
 
 // // 记录看课时间(旧)
@@ -32,36 +32,36 @@ export function courseAnswer(data) {
 
 // 记录看课时间(新)
 export function getFinishCourseVideo(data) {
-	return request('/app/course/updateWatchDuration', data, 'POST', 'application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
+	return request('/app/course/updateWatchDuration', data, 'POST', 'application/json;charset=UTF-8');
 }
 
 // 关注客服
 export function getIsAddKf(data) {
-	return request('/app/course/isAddKf', data, 'POST', 'application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
+	return request('/app/course/isAddKf', data, 'POST', 'application/json;charset=UTF-8');
 }
 
 // 流量(缓冲百分比)
 export function getInternetTraffic(data) {
-	return request('/app/course/getInternetTraffic', data, 'POST', 'application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
+	return request('/app/course/getInternetTraffic', data, 'POST', 'application/json;charset=UTF-8');
 }
 
 // 每十分钟获得积分
 export function getIntegralByH5Video(data) {
-	return request('/app/course/getIntegralByH5Video', data, 'POST', 'application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
+	return request('/app/course/getIntegralByH5Video', data, 'POST', 'application/json;charset=UTF-8');
 }
 
 // 发送奖励
 export function sendReward(data) {
-	return request('/app/course/sendReward', data, 'POST', 'application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
+	return request('/app/course/sendReward', data, 'POST', 'application/json;charset=UTF-8');
 }
 
 // 播放错误上报
 export function getErrMsg(data) {
-	return request('/app/course/getErrMsg', data, 'POST', 'application/x-www-form-urlencoded','https://h5api.his.cdwjyyh.com');
+	return request('/app/course/getErrMsg', data, 'POST', 'application/x-www-form-urlencoded');
 }
 
 
 // 获取getWxConfig
 export function getWxConfig(data) {
-	return request('/app/wx/mp/getWxConfig', data, 'GET','','https://h5api.his.cdwjyyh.com');
+	return request('/app/wx/mp/getWxConfig', data, 'GET','');
 }

+ 2 - 0
note.txt

@@ -0,0 +1,2 @@
+// appId 看课授权登录微信appId
+// 需要在app.vue => globalData中配置

+ 29 - 59
pages_course/video.vue

@@ -340,23 +340,6 @@
 				}
 			}
 		},
-		//发送给朋友
-		onShareAppMessage(res) {
-			return {
-				title: "御君方互联网医院",
-				path: '/pages/index/index',
-				imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
-			}
-			
-		},
-		//分享到朋友圈
-		onShareTimeline(res) {
-			return {
-				title: "御君方互联网医院",
-				imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
-			}
-			
-		},
 		onLoad(option) {
 			this.code = option.code
 			this.urlOption = option.course ? JSON.parse(option.course) : {}
@@ -388,7 +371,7 @@
 		onShow() {
 			this.tipsOpen = false
 			this.isExpand = true
-			// this.isLogin = this.$isLoginCourse()
+			// this.isLogin = this.utils.isLogin()
 			this.uuId = generateRandomString(16)
 			if (this.videoId) {
 				this.getH5CourseByVideo()
@@ -679,30 +662,25 @@
 					return
 				}
 				// 登录
-				this.$isLoginCourse().then(
-					res => {
-						if(res){
-							if (this.isAddKf == 1) {
-								// 答题
-								// 您已提交过答案,请领取红包
-								this.courseAnswer()
-							} else {
-								// 添加客服
-								if (this.videoId && this.qwUserId) {
-									this.getIsAddKf()
-								} else {
-									uni.showToast({
-										title: '请添加客服',
-										icon: 'none'
-									})
-								}
-							} 
-						} else{
-							this.goLogin()
+				this.isLogin = this.utils.isLogin()
+				if(this.isLogin){
+					if (this.isAddKf == 1) {
+						// 答题
+						this.courseAnswer()
+					} else {
+						// 添加客服
+						if (this.videoId && this.qwUserId) {
+							this.getIsAddKf()
+						} else {
+							uni.showToast({
+								title: '请添加客服',
+								icon: 'none'
+							})
 						}
-					},
-					rej => {}
-				);
+					} 
+				} else{
+					this.goLogin()
+				}
 			},
 			// 答题
 			courseAnswer() {
@@ -790,8 +768,8 @@
 					const param = {
 						...this.urlOption,
 						rewardType: Number(this.currentReward),
-						source: 2,
-						appId: 'wxa9be7360a11024a4'
+						source: 2, // 小程序
+						appId: getApp().globalData.appId
 					}
 					sendReward(param).then(res => {
 						uni.showToast({
@@ -962,12 +940,11 @@
 									code: loginRes.code,
 									encryptedData:infoRes.encryptedData,
 									iv:infoRes.iv,
-									appId: 'wxa9be7360a11024a4'
+									appId: getApp().globalData.appId
 								}).then(res=>{
 									 uni.hideLoading();
 									 if (res.code == 200) {
-										uni.setStorageSync('AppTokenmini_RTCourse', res.token);
-										uni.setStorageSync('userInfo', JSON.stringify(res.user));
+										uni.setStorageSync('AppToken', res.token);
 										this.isLogin = true
 										this.getIsAddKf() 
 									 } else {
@@ -989,8 +966,6 @@
 				})
 			},
 			getLink() {
-				this.goLogin()
-				return
 				let that = this;
 				this.msg = ''
 				getRealLink({sortLink:this.sortLink}).then(res=>{
@@ -1002,17 +977,12 @@
 							this.getH5CourseVideoDetails()
 						}
 						if (this.videoId && this.isAddKf != 1) {
-							this.$isLoginCourse().then(
-								isLogin => {
-									this.isLogin = isLogin
-									if(isLogin){
-										this.getIsAddKf() 
-									} else {
-										this.goLogin()
-									}
-								},
-								rej => {}
-							);
+							this.isLogin = this.utils.isLogin()
+							if(this.isLogin){
+								this.getIsAddKf() 
+							} else {
+								this.goLogin()
+							}
 						}
 					} else {
 						this.isExpire = true