XSLu08042 5 hodín pred
rodič
commit
8dc8933c3d
3 zmenil súbory, kde vykonal 151 pridanie a 31 odobranie
  1. 25 17
      api/course.js
  2. 114 7
      pages_course/activity.vue
  3. 12 7
      pages_course/videoDetail.vue

+ 25 - 17
api/course.js

@@ -83,69 +83,77 @@ export function getWxConfig(data) {
  }
  
  // 保存评论数据
- export function saveMsg(data, type) {
+ export function saveMsg(data) {
  	return request('/app/course/saveMsg', data, 'POST', 'application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
  }
  
  // 撤销评论
- export function revokeMsg(data, type) {
+ export function revokeMsg(data) {
  	return request('/app/course/revokeMsg', data, 'PUT', 'application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
  }
  
  // 获取历史评论数据
- export function getComments(data, type) {
+ export function getComments(data) {
  	return request('/app/course/getComments', data, 'GET','','https://h5api.his.cdwjyyh.com');
  }
  
  // 错误日志未知异常,请联系管理员
- export function errorLogUpload(data, type) {
+ export function errorLogUpload(data) {
  	return request('/app/common/errorLogUpload', data, 'POST','','https://h5api.his.cdwjyyh.com');
  }
  
- export function getTypeTree(data, type) {
+ export function getTypeTree(data) {
  	return request('/app/user/complaint/getTypeTree', null, 'GET','','https://h5api.his.cdwjyyh.com');
  }
- export function complaintRecord(data, type) {
+ export function complaintRecord(data) {
  	return request('/app/user/complaint/record', data, 'POST','application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
  }
  
- export function uploadOSS(data, type) {
+ export function uploadOSS(data) {
  	return request('/app/common/uploadOSS', data, 'POST','application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
  }
 // 公开课
- export function getAppletCourse(data, type) {
+ export function getAppletCourse(data) {
  	return request('/app/course/getAppletCourse', null, 'GET','','https://h5api.his.cdwjyyh.com');
  }
- export function getAppletCourseVideo(data, type) {
+ export function getAppletCourseVideo(data) {
  	return request('/app/course/getAppletCourseVideo', data, 'GET','','https://h5api.his.cdwjyyh.com');
  }
- export function getConfigByKey(data, type) {
+ export function getConfigByKey(data) {
  	return request('/app/common/getConfigByKey',data,'GET','','https://h5api.his.cdwjyyh.com');
  }
 // 获取芳华币礼品
-export function getCourseIntegralGoods(data,type) {
+export function getCourseIntegralGoods(data) {
 	return request('/app/course/getCourseIntegralGoods', null, 'GET','','https://h5api.his.cdwjyyh.com');
 }
- export function claim(data, type) {
+ export function claim(data) {
  	return request('/app/course/rewardRound/claim', data, 'POST','application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
  }
- export function isClaim(data, type) {
+ export function isClaim(data) {
  	return request('/app/course/rewardRound/isClaim', data, 'POST','application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
 }
- export function getVideoRewardTypes(data, type) {
+ export function getVideoRewardTypes(data) {
   	return request('/app/course/getVideoRewardTypes', data, 'POST','application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
  }
- export function getVideoRewardRules(data, type) {
+ export function getVideoRewardRules(data) {
   	return request('/app/course/getVideoRewardRules', data, 'POST','application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
  }
- export function getUserPhoneDeviceType(data, type) {
+ export function getUserPhoneDeviceType(data) {
   	return request('/app/pop/getUserPhoneDeviceType', data, 'POST','application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
  }
  //检查是否有头像以及昵称
  export function checkUserInfo(data) {
- 	 return request('/app/user/checkUserInfo',data,'GET','application/json;charset=UTF-8');
+ 	 return request('/app/user/checkUserInfo',data,'GET','application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
  }
  //更改用户头像以及昵称
  export function editUser(data) {
  	 return request('/app/user/editUser',data,'POST','application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
+ }
+ 
+ 
+ export function getLuckyBagInfo(data) {
+ 	 return request('/app/luckyBag/getLuckyBagInfo',data,'GET','','https://h5api.his.cdwjyyh.com');
+ }
+ export function receiveLuckyBag(data) {
+  	return request('/app/luckyBag/receiveLuckyBag', data, 'POST','application/json;charset=UTF-8','https://h5api.his.cdwjyyh.com');
  }

+ 114 - 7
pages_course/activity.vue

@@ -5,11 +5,11 @@
 		<view class="conbox">
 			<image class="activity_yh_right" src="https://cdn.his.cdwjyyh.com/minapp/course/activity_yh_right.png" mode="widthFix"></image>
 			<image class="activity_yh_left" src="https://cdn.his.cdwjyyh.com/minapp/course/activity_yh_left.png" mode="widthFix"></image>
-			<image class="activity_title" v-show="status==0" src="https://cdn.his.cdwjyyh.com/minapp/course/activity_title.png" mode="widthFix"></image>
-			<view class="activity_title2" v-if="status==1">
+			<image class="activity_title" v-if="collectType!=2&&isExpiry" src="https://cdn.his.cdwjyyh.com/minapp/course/activity_title.png" mode="widthFix"></image>
+			<view class="activity_title2" v-if="!isExpiry==1&&collectType==2">
 				福袋已经失效了~
 			</view>
-			<template v-if="status==2">
+			<template v-if="collectType==1">
 				<view class="activity_title3">
 					您已经领取过本次福袋啦~
 				</view>
@@ -20,15 +20,15 @@
 			<view class="ybg_box">
 				<view class="ybg"></view>
 				<image class="activity_lucky_bag" src="https://cdn.his.cdwjyyh.com/minapp/course/activity_lucky_bag.png" mode="heightFix"></image>
-				<image class="activity_ysx" v-show="status==1" src="https://cdn.his.cdwjyyh.com/minapp/course/activity_ysx.png" mode="widthFix"></image>
-				<image class="activity_ylq" v-show="status==2" src="https://cdn.his.cdwjyyh.com/minapp/course/activity_ylq.png" mode="widthFix"></image>
+				<image class="activity_ysx" v-show="!isExpiry==1&&collectType==2" src="https://cdn.his.cdwjyyh.com/minapp/course/activity_ysx.png" mode="widthFix"></image>
+				<image class="activity_ylq"  v-show="collectType==1" src="https://cdn.his.cdwjyyh.com/minapp/course/activity_ylq.png" mode="widthFix"></image>
 			</view>
-			<view class="activity_btn animation" v-if="status==0" @click="handleReceive">
+			<view class="activity_btn animation" v-if="collectType!=2&&isExpiry" @click="handleReceive">
 				<view class="btn">领取福袋</view>
 				<image src="https://cdn.his.cdwjyyh.com/minapp/course/activity_btn.png" mode="heightFix"></image>
 				<view class="exsct"></view>
 			</view>
-			<view class="activity_btn_down x-c" v-if="status!=0" @click="navTo">
+			<view class="activity_btn_down x-c" v-else @click="navTo">
 				<text>如何下载芳华未来APP</text>
 				<image src="https://cdn.his.cdwjyyh.com/minapp/course/activity_more.png" mode="aspectFill"></image>
 			</view>
@@ -52,14 +52,52 @@
 </template>
 
 <script>
+	import { mapGetters } from 'vuex';
+	import { getLuckyBagInfo,receiveLuckyBag } from '@/api/course.js'
 	export default {
 		data() {
 			return {
 				statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
 				show: false,
 				status: 0, 
+				recordId: '',
+				urlOption: {},
+				sortLink: '',
+				corpId: null,
+				isLogin: false,
+				isLoginH5:0, // 1服务号授权
+				collectType: -1, // 领取状态(0-已发放 1-已领取 2-已失效)
+				isExpiry: true, // false 失效 true 有效
 			}
 		},
+		computed:{
+			...mapGetters(['coureLogin']),
+		},
+		watch: {
+		    coureLogin: {
+		      immediate: true,          // 页面一进入就检查一次
+		      handler(val) {
+		        if (val == 2&&this.isLogin) {
+					console.log("注册AppToken失效,请重新登录")
+					uni.removeStorageSync('web_userInfo');
+					uni.removeStorageSync('TOKEN_WEXIN');
+					this.isLogin = false
+					if(this.isLoginH5==0){
+						this.goWXLogin()
+					}else{
+						this.goLogin()
+					}
+		        }
+		      }
+		    }
+		},
+		onLoad(option) {
+			this.recordId = option.recordId || ''
+			this.urlOption = option.link ? JSON.parse(decodeURIComponent(option.link)) : {},
+			this.sortLink = this.urlOption.link || ''
+			this.corpId = this.urlOption.corpId
+			console.log(this.sortLink)
+		},
 		methods: {
 			goBack() {
 				uni.navigateBack();
@@ -84,6 +122,75 @@
 				// 		}
 				// 	}
 				// });
+			},
+			getLuckyBagInfo() {
+				getLuckyBagInfo({recordId:this.recordId}).then(res=>{
+					if(res.code ==200) {
+						this.collectType = res.data.collectType; //领取状态(0-已发放 1-已领取 2-已失效)
+						this.isExpiry = res.data.isExpiry; //false 失效 true 有效
+					} else {
+						uni.showToast({
+							title: res.msg,
+							icon: 'none'
+						});
+					}
+				})
+			},
+			goLogin(data) {
+				if(this.isLoginH5==0) {
+					this.goWXLogin()
+					return
+				}
+			},
+			goWXLogin() {
+				this.utils.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,appId:getApp().globalData.appId}).then(res=>{
+										 uni.hideLoading();
+										 if (res.code == 200) {
+											 // this.checkUserInfoA()
+											this.$store.commit('setCoureLogin', 1);
+											uni.setStorageSync('AppTokenmini_RTCourse', res.token);
+											uni.setStorageSync('auto_userInfo', JSON.stringify(res.user));
+											this.isLogin = true
+											// if(this.chatId!=''||this.chatId){
+											// 	this.userlogo=true
+											// }else{
+											// 	this.getLuckyBagInfo()
+											// }
+											this.getLuckyBagInfo()
+										 } else {
+											uni.showToast({
+												title: res.msg,
+												icon: 'none'
+											});
+										 }
+									 }).catch(err=>{
+										uni.hideLoading();
+										uni.showToast({
+											icon:'none',
+											title: "登录失败,请重新登录",
+										});
+									});
+							   }
+							});
+						}
+					})
+				}).catch(err => {})
 			}
 		}
 	}

+ 12 - 7
pages_course/videoDetail.vue

@@ -765,7 +765,7 @@
 							this.playDuration = res.playDuration || 0
 							this.tipsTime = res.tipsTime || 0
 							const showTreatmentFlag = res.course&&res.course.showTreatment!=null ? res.course.showTreatment : 1
-							this.treatmentPackage = res.course&&res.course.treatmentPackage ? res.course.treatmentPackage : [],
+							this.treatmentPackage = res.course&&res.course.treatmentPackage ? res.course.treatmentPackage : []
 							this.showTreatment = showTreatmentFlag==0&&this.treatmentPackage.length>0 ? 0 : 1
 							let lineList = []
 							if (res.course && res.course.lineOne) {
@@ -778,6 +778,12 @@
 								lineList.push(res.course.lineThree)
 							}
 							this.lineList = lineList
+							this.quesList = res.questions && res.questions.length > 0 ? res.questions : []
+							this.quesList = this.quesList.map(item => ({
+								...item,
+								questionOption: JSON.parse(item.question),
+								answer: ''
+							}))
 							this.courseLogo = res.config&&res.config.courseLogo
 							this.viewCommentNum = res.config&&res.config.viewCommentNum || 200
 					
@@ -826,12 +832,11 @@
 								this.player.play();
 							}
 							this.updateTime();
-							this.quesList = res.questions && res.questions.length > 0 ? res.questions : [],
-								this.quesList = this.quesList.map(item => ({
-									...item,
-									questionOption: JSON.parse(item.question),
-									answer: ''
-								}))
+						} else {
+							uni.showToast({
+								title: res.msg,
+								icon: 'none'
+							})
 						}
 						this.getHeight()
 						this.$nextTick(()=>{