XSLu08042 1 day ago
parent
commit
5335953048
4 changed files with 89 additions and 65 deletions
  1. 1 1
      App.vue
  2. 3 1
      README.md
  3. 19 5
      pages_course/video.vue
  4. 66 58
      pages_course/videoNew.vue

+ 1 - 1
App.vue

@@ -1,7 +1,7 @@
 <script>
 	export default {
 		globalData: {
-			wsUrl: 'ws://c7d8ff63.natappfree.cc',
+			wsUrl: 'wss://h5api.his.cdwjyyh.com',
 			appId: 'wxa9be7360a11024a4', // appId 看课授权登录微信appId
 		},
 		onLaunch: function() {

+ 3 - 1
README.md

@@ -9,4 +9,6 @@ wsUrl: 'wss://xxxxxx', // 弹幕评论wsUrl
 appId: 'xxxxxxxxxxx', // appId 看课授权登录微信appId
 ```
 3、页面分享名字和图片
-4、utils=》common=> 的TOKEN_KEY
+4、utils=》common=> 的TOKEN_KEY
+5、 目前除了润天,其他项目发红包和积分是后台配置,代码中需要注意答题正确直接调closeAnswerPopup方法,
+6、 修改弹幕、评论app.vue的wsUrl地址

+ 19 - 5
pages_course/video.vue

@@ -236,7 +236,7 @@
 				statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
 				scrollTop: 0,
 				height: '0px',
-				isLogin: true,
+				isLogin: false,
 				videoUrl: "",
 				videoId: "",
 				//现在的时长
@@ -478,7 +478,7 @@
 			// 当开始/继续播放时触发play事件
 			getPlay() {
 				this.errorCount = 0
-				this.judgeDuration()
+				// this.judgeDuration()
 			},
 			getPause() {
 				this.clearIntegral()
@@ -767,7 +767,8 @@
 								// 答题成功
 								this.errTitle = "恭喜你,回答正确"
 								this.errDesc = `请选择奖励`
-								this.$refs.answerPopup.open("center")
+								// this.$refs.answerPopup.open("center")
+								this.closeAnswerPopup(1)
 							}
 						} else {
 							if (res.msg == "该课题到达答错次数限制") {
@@ -789,15 +790,22 @@
 			rewardChange(e) {
 				this.currentReward = e.detail.value
 			},
-			closeAnswerPopup() {
+			closeAnswerPopup(type) {
 				this.$refs.answerPopup.close()
 				if (this.errTitle == '恭喜你,回答正确') {
 					const param = {
 						...this.urlOption,
 						rewardType: Number(this.currentReward),
-						source: 2, // 小程序润天独有
+						source: 2,
 						appId: getApp().globalData.appId
 					}
+					if(type == 1) {
+						param = {
+							...this.urlOption,
+							source: 2,
+							appId: getApp().globalData.appId
+						}
+					}
 					sendReward(param).then(res => {
 						uni.showToast({
 							title: res.msg,
@@ -881,6 +889,12 @@
 						} else if (res.code == 504) {
 							// 登录
 							this.goLogin()
+						} else if (res.code == 566) {
+							// 官方群发通用链接
+							const url = res.courseLink.realLink.split('?course=')[1]
+							this.urlOption = JSON.parse(url)
+							this.isAddKf = 1
+							this.getH5CourseVideoDetails()
 						} else {
 							this.isAddKf = 0
 							uni.showToast({

+ 66 - 58
pages_course/videoNew.vue

@@ -296,7 +296,7 @@
 				statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
 				scrollTop: 0,
 				height: '0px',
-				isLogin: true,
+				isLogin: false,
 				videoUrl: "",
 				videoId: "",
 				//现在的时长
@@ -552,7 +552,7 @@
 			// 当开始/继续播放时触发play事件
 			getPlay() {
 				this.errorCount = 0
-				this.judgeDuration()
+				// this.judgeDuration()
 			},
 			getPause() {
 				this.clearIntegral()
@@ -866,7 +866,8 @@
 								// 答题成功
 								this.errTitle = "恭喜你,回答正确"
 								this.errDesc = `请选择奖励`
-								this.$refs.answerPopup.open("center")
+								// this.$refs.answerPopup.open("center")
+								this.closeAnswerPopup(1)
 							}
 						} else {
 							if (res.msg == "该课题到达答错次数限制") {
@@ -888,28 +889,38 @@
 			rewardChange(e) {
 				this.currentReward = e.detail.value
 			},
-			closeAnswerPopup() {
+			closeAnswerPopup(type) {
 				this.$refs.answerPopup.close()
 				if (this.errTitle == '恭喜你,回答正确') {
-					const param = {
+					let param = {
 						...this.urlOption,
 						rewardType: Number(this.currentReward),
-						source: 2
+						source: 2,
+						appId: getApp().globalData.appId
+					}
+					if(type == 1) {
+						param = {
+							...this.urlOption,
+							source: 2,
+							appId: getApp().globalData.appId
+						}
 					}
 					sendReward(param).then(res => {
-						uni.showToast({
-							title: res.msg,
-							icon: 'none'
-						})
-						// if(res.code == 200) {
-						// 	//重构 发红包,后台通过OPENID发零钱到 账
-						// 	//this.initWXConfig(res.package)
-						// }else {
-						// 	uni.showToast({
-						// 		title: res.msg,
-						// 		icon: 'none'
-						// 	})
-						// }
+						if(res.isNew&&res.isNew==1) {
+							const packageInfo = res.data.packageInfo || ''
+							if(packageInfo) {
+								uni.setStorageSync('receive_package',packageInfo);
+								if(res.mchId) uni.setStorageSync('mchId',res.mchId);
+								uni.navigateTo({
+									url: '/pages_course/reward'
+								})
+							}
+						} else {
+							uni.showToast({
+								title: res.msg,
+								icon: 'none'
+							})
+						}
 					})
 				}
 			},
@@ -1049,48 +1060,43 @@
 				})
 			},
 			goLogin() {
-				this.$getProvider().then(provider=>{
-					console.log('当前的环境商',provider)
-					if (!provider) {
-					  reject()
-					}
-					uni.login({
-						provider: provider,
-						success: async loginRes => {
-							console.log(loginRes)
-							uni.getUserInfo({
-							   provider: provider,
-							   success: (infoRes)=> {
-								    uni.showToast({
-										title: '处理中...',
-										icon: 'loading'
-								    });
-									loginByMp({code: loginRes.code,encryptedData:infoRes.encryptedData,iv:infoRes.iv}).then(res=>{
-										 uni.hideLoading();
-										 if (res.code == 200) {
-											uni.setStorageSync(TOKEN_KEY, res.token);
-											uni.setStorageSync('userInfo', JSON.stringify(res.user));
-											this.user = res.user
-											this.isLogin = true
-											this.getIsAddKf() 
-										 } else {
-											uni.showToast({
-												title: res.msg,
-												icon: 'none'
-											});
-										 }
-									 }).catch(err=>{
-										uni.hideLoading();
+				let provider = 'weixin'
+				uni.login({
+					provider: provider,
+					success: async loginRes => {
+						console.log(loginRes)
+						uni.getUserInfo({
+						   provider: provider,
+						   success: (infoRes)=> {
+							    uni.showToast({
+									title: '处理中...',
+									icon: 'loading'
+							    });
+								loginByMp({code: loginRes.code,encryptedData:infoRes.encryptedData,iv:infoRes.iv}).then(res=>{
+									 uni.hideLoading();
+									 if (res.code == 200) {
+										uni.setStorageSync(TOKEN_KEY, res.token);
+										uni.setStorageSync('userInfo', JSON.stringify(res.user));
+										this.user = res.user
+										this.isLogin = true
+										this.getIsAddKf() 
+									 } else {
 										uni.showToast({
-											icon:'none',
-											title: "登录失败,请重新登录",
+											title: res.msg,
+											icon: 'none'
 										});
+									 }
+								 }).catch(err=>{
+									uni.hideLoading();
+									uni.showToast({
+										icon:'none',
+										title: "登录失败,请重新登录",
 									});
-							   }
-							});
-						}
-					})
-				}).catch(err => {})
+								});
+						   }
+						});
+					}
+				})
 			},
 			getLink() {
 				let that = this;
@@ -1705,6 +1711,7 @@
 			}
 		}
 		.warning {
+			flex-shrink: 0;
 			color: #888;
 			font-size: 24rpx;
 			@include u-flex(column, center, center);
@@ -1907,6 +1914,7 @@
 		@include u-flex(row, center, flex-start);
 		background-color: #fff;
 		.warning {
+			flex-shrink: 0;
 			padding-right: 20rpx;
 		}
 	}