提交 f9cecf76 编写于 作者: chengxiang.li's avatar chengxiang.li

添加活动主页任务的逻辑

上级 9997b4fe
...@@ -207,11 +207,12 @@ ...@@ -207,11 +207,12 @@
</template> </template>
<script> <script>
import { getActivityId, getUserScoreInfo, getInviteList, getClockStatus, goToUpdateClock, getTimsActivityInfo } from '@/service/activityMainpage'; import { getActivityId, getUserScoreInfo, getInviteList, getClockStatus, goToUpdateClock, getTimsActivityInfo, selectAppModuleParam, checkToken, getRole, sayHello } from '@/service/activityMainpage';
import { checkHospitalStatus } from '@/service'; import { checkHospitalStatus } from '@/service';
import h5header from '@/components/h5header'; import h5header from '@/components/h5header';
import { getShareUrl } from '@/utils/index'; import { getShareUrl } from '@/utils/index';
import { Toast } from 'vant'; import { Toast } from 'vant';
import { setEventByModuleCode } from '@/utils';
const cookies = require('cookie-universal')(); const cookies = require('cookie-universal')();
...@@ -220,7 +221,7 @@ ...@@ -220,7 +221,7 @@
export default { export default {
data () { data () {
return { return {
token: '',
activityId: 2, // 上线前等产品通知修改默认值 activityId: 2, // 上线前等产品通知修改默认值
serverTime: '', serverTime: '',
...@@ -328,9 +329,12 @@ ...@@ -328,9 +329,12 @@
}, },
created() { created() {
vm = this; vm = this;
},
mounted() {
// 取服务器时间,切换不同时间段的显示 // 取服务器时间,切换不同时间段的显示
vm.getServerTime(); vm.getServerTime();
// 经与后端产品确认,默认没传id的话,就取接口;默认有的话就不取接口 // 请求接口获取activityId (经与后端产品确认,默认没传id的话,就取接口;默认有的话就不取接口)
if( !vm.activityId ){ if( !vm.activityId ){
getActivityId().then(res => { getActivityId().then(res => {
alert('guhui 获取id') alert('guhui 获取id')
...@@ -345,9 +349,7 @@ ...@@ -345,9 +349,7 @@
} }
}) })
} }
},
mounted() {
vm.getUserActivityInfo();
vm.shareObj = { vm.shareObj = {
shareUrl: window.location.href, shareUrl: window.location.href,
title1: '分享title分享title', title1: '分享title分享title',
...@@ -356,7 +358,6 @@ ...@@ -356,7 +358,6 @@
} }
vm.isWeb = vm.$rocNative.isWeb; vm.isWeb = vm.$rocNative.isWeb;
vm.getTasks();
vm.$rocNative.appInit(); vm.$rocNative.appInit();
vm.getUserInfo(); // 判断是否登录 vm.getUserInfo(); // 判断是否登录
...@@ -368,15 +369,7 @@ ...@@ -368,15 +369,7 @@
} }
} }
}, },
watch: {
clockAward(val){
alert('watch clockAward')
alert(val)
if(val.activityId && val.id && vm.isJoin){
vm.getTaskStatus(vm.clockAward);
}
}
},
methods: { methods: {
// 获取服务器时间 // 获取服务器时间
getServerTime() { getServerTime() {
...@@ -428,7 +421,8 @@ ...@@ -428,7 +421,8 @@
.then(params => { .then(params => {
// _seft.userToken = params.userToken; // 存到store里 // _seft.userToken = params.userToken; // 存到store里
if(params && params.userToken){ if(params && params.userToken){
cookies.set('token', params.userToken) cookies.set('token', params.userToken);
vm.token = params.userToken;
} }
// alert(JSON.stringify(params)); // alert(JSON.stringify(params));
if(params && params.userMobile){ // 已登录 (有手机号表示 已登录,无手机号表示 未登录) if(params && params.userMobile){ // 已登录 (有手机号表示 已登录,无手机号表示 未登录)
...@@ -438,6 +432,8 @@ ...@@ -438,6 +432,8 @@
}else{ // 未登录 }else{ // 未登录
vm.isLogin = false; vm.isLogin = false;
} }
// 登录状态确定后,再调任务接口,以便获取打卡状态
vm.getTasks();
}); });
}, },
...@@ -445,7 +441,7 @@ ...@@ -445,7 +441,7 @@
appLogin() { appLogin() {
vm.$rocNative.gotoLogin(); vm.$rocNative.gotoLogin();
}, },
// 登陆ok后 回调: 获取邀请的医生列表等。。 // 登陆ok后 回调: 获取邀请的医生列表 & 检查是否加入机构
loginCallback() { loginCallback() {
vm.getUserActivityInfo(); vm.getUserActivityInfo();
vm.goToCheckJoin(); vm.goToCheckJoin();
...@@ -708,7 +704,11 @@ ...@@ -708,7 +704,11 @@
}) })
} }
}else{ // 非打卡,直接走积木tims跳转逻辑 }else{ // 非打卡,直接走积木tims跳转逻辑
// vm.jumpPage(item.) // alert('去课程或者患者招募 。。。。。。')
if(item.isFinish == 0){ // 已完成 不可点
return;
}
vm.jumpPage(item.linkId);
} }
}, },
...@@ -756,7 +756,10 @@ ...@@ -756,7 +756,10 @@
id: item.id, id: item.id,
}; };
vm.taskObj.clock = item; vm.taskObj.clock = item;
if(vm.isLogin){ // 登录后,获取打卡状态
vm.goToGetClockStatus(vm.clockAward);
}
}else if( item.resourceType == 1 && item.timeStatus == 1 ){ // 课程 默认奖励 20分 20豆 }else if( item.resourceType == 1 && item.timeStatus == 1 ){ // 课程 默认奖励 20分 20豆
item.eachInviteAwardMark = 20; item.eachInviteAwardMark = 20;
item.eachInviteAwardBean = 20; item.eachInviteAwardBean = 20;
...@@ -784,12 +787,8 @@ ...@@ -784,12 +787,8 @@
vm.$toast(res.message); vm.$toast(res.message);
} }
}) })
}, },
getTaskStatus(params) { goToGetClockStatus(params) {
vm.isClockFinish = false; vm.isClockFinish = false;
getClockStatus(params).then(res => { getClockStatus(params).then(res => {
if(res && res.code == '000000'){ if(res && res.code == '000000'){
...@@ -854,87 +853,152 @@ ...@@ -854,87 +853,152 @@
} }
return text; return text;
}, },
<<<<<<< HEAD
async jumpPage(url, id) { async jumpPage(url, id) {
const _this = this; const _this = this;
if (!!url) { if (!!url) {
// 判断是否有跳转 // 判断是否有跳转
const { token, isWeb } = _this; const { token } = _this;
_this.videoWatchTime = 0;
_this.widgetId = id;
const { data } = await selectAppModuleParam({ const { data } = await selectAppModuleParam({
id: url, id: url,
token token
}); });
alert('inJumpage'); alert(JSON.stringify(data))
const itemData = data.model; const itemData = data.model;
this.$sendBuriedData({ // 积木组件点击埋点
url: this.baseUrl + "/file/log/trace1", // 增加点击图片时候,是否有loginFlag参数,有,则校验并登录。如未登录去登录,已登录,老逻辑。
action: 'ACTION_CLICK', const loginFlag = this.checkLoginFlag(itemData.paramList);
component_tag: `200#${_this.tempId}#0#${_this.widgetId}` if(loginFlag){
_this.refreshFlag = true;
_this.$rocNative.getToken().then(res => {
const { userToken } = res;
// alert('APP拿到的token=:'+userToken)
checkToken({ token: userToken }).then(res=>{
if(res.code == '200000' || res.code == '200006') {
_this.$rocNative.gotoLogin();
}else{
_this.oldJumpHandle(itemData, userToken);
}
})
});
}else{
_this.oldJumpHandle(itemData, _this.token);
}
}
},
// 增加一个点击图片请求selectAppModuleParam这个接口时候的 loginFlag 字段校验
checkLoginFlag(paramList){
let flag = false;
for(let i=0;i<paramList.length;i++){
if(paramList[i].key === 'loginFlag' && paramList[i].value === '1'){
flag = true;
break;
}
}
return flag;
},
// 原先的点击图片跳转逻辑
oldJumpHandle(itemData, token){ alert('oldJUmpHundalsdllksllll')
// 不改动原先逻辑
if (itemData.code == 'M301') {
itemData.code = 'M300';
//鉴权 自己调用token
this.$rocNative.getToken().then(res => {
const { userToken } = res;
// setCookie('token', userToken);
// setCookie('headToken', userToken);
cookies.set('token', userToken);
cookies.set('headToken', userToken);
this.setJQ(itemData, userToken);
}); });
if (isWeb) { } else {
// TODO: //如果在 web 中在这里写 const paramList = setEventByModuleCode(
if (itemData.code == 'M300') { itemData,
let paramList = setEventByModuleCode(itemData); token
if ( );
paramList[0].value.search('crrspt.') != -1 this.$rocNative.dispatchEventByModuleCode({
) { modeCode: itemData.code,
// 患者招募 jsonString: paramList
paramList[0].value = });
paramList[0].value + '?' + this.paramString; }
} },
if (paramList[0].value.search('/wjdc/') != -1) { //鉴权 自己调用token 是否认证
// 问卷调查 setJQ(itemData, token) {
//console.log(paramList[0].value + '&pageUrl=' + window.location.href) this.itemData = itemData;
location.href = this.getUserInfo2(itemData, token);
paramList[0].value + },
'&pageUrl=' + // 兼容Andriod新版本
window.location.href; getUserInfo2(itemData, token) {
return; this.$rocNative
.getUserInfo()
.then(params => {
this.token = params.userToken;
// setCookie('headToken', params.userToken)
cookies.set('headToken', params.userToken);
// this.prbateFun(this.itemData, this.token);
getRole({token: this.token}).then(res => {
if (res.code == '000000') {
if (res.data.role == 4) {
if (res.data.flag == 1) {
this.setJQ2(itemData, token);
} else {
this.$rocNative.showNativeToast({
message: '请加入机构,再尝试访问!'
});
}
} else if (res.data.role == 2) {
this.$rocNative.showNativeToast({
message: '仅限认证用户浏览 '
});
} else if (res.data.role == 3) {
this.$rocNative.showNativeToast({
message: '仅限认证且加入机构的用户浏'
});
}
} else {
this.$rocNative.showNativeToast({
message: res.message
});
} }
location.href = paramList[0].value; });
} else { });
this.$dialog },
.confirm({ setJQ2(itemData, token) {
message: '请下载最新app', let _this = this,
confirmButtonText: '去下载', para = {
className: 'go-down-msg-box' token: this.token,
}) setEntry: 'headers'
.then(() => { };
location.href = sayHello(para).then(res => {
'https://www.yunqueyi.com/mobile/share_pica.html?hideQrcode=true'; if (res.code == '000000') {
}) _this.nonce_str = res.data.nonce_str;
.catch(() => {}); itemData.paramList.push({
} id: 598,
key: 'nonce_str',
seqNo: 3,
type: 4,
value: res.data.nonce_str
});
let paramList = setEventByModuleCode(
itemData,
token
);
this.$rocNative.dispatchEventByModuleCode({
modeCode: itemData.code,
jsonString: paramList
});
} else { } else {
// 增加点击图片时候,是否有loginFlag参数,有,则校验并登录。如未登录去登录,已登录,老逻辑。 this.$rocNative.showNativeToast({
const loginFlag = this.checkLoginFlag(itemData.paramList); message: res.message
if(loginFlag){ });
_this.refreshFlag = true;
_this.$rocNative.getToken().then(res => {
const { userToken } = res;
// alert('APP拿到的token=:'+userToken)
checkToken({ token: userToken }).then(res=>{
if(res.code == '200000' || res.code == '200006') {
_this.$rocNative.gotoLogin();
}else{
_this.oldJumpHandle(itemData, userToken);
}
})
});
}else{
_this.oldJumpHandle(itemData, _this.token);
}
} }
} });
}, },
=======
getHeaderHeight(val){ getHeaderHeight(val){
this.padTop = val; this.padTop = val;
}, },
>>>>>>> c333d6d43d0751c36d403ffb7f9896282838b121
}, },
} }
</script>> </script>>
......
...@@ -64,3 +64,39 @@ export const getTimsActivityInfo = (id) => { ...@@ -64,3 +64,39 @@ export const getTimsActivityInfo = (id) => {
withCredentials: true, withCredentials: true,
}) })
} }
export const selectAppModuleParam = async ({id, token }) => {
return request({
url: `/contents/contentAppModule/selectAppModuleParam?id=${id}&token=${token}&setEntry=true`,
withCredentials: true
});
}
export const checkToken = async({token}) => {
return request({
url: `campaign/admin/task/checkToken?token=${token}`,
withCredentials: true
})
}
export const getRole = async ({ token }) => {
return request({
url: `/contents/template/getRole?token=${token}`,
headers: {
token
}
// withCredentials: true
});
}
export const sayHello = async ({ token }) => {
return request({
method: 'POST',
// withCredentials: true,
headers: {
token
},
data: { token },
url: `/diplomat/oauth/sayhello?app_id=pica-crrs`
});
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册