提交 a7a54c32 编写于 作者: tao.wu's avatar tao.wu

Merge remote-tracking branch 'origin/dev-stage2-20191125' into dev-stage2-20191125

...@@ -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')();
...@@ -232,6 +233,8 @@ ...@@ -232,6 +233,8 @@
return { return {
activeOverTimeStr: new Date('2019-12-30 00:00:00').getTime() , // 活动结束 一天 activeOverTimeStr: new Date('2019-12-30 00:00:00').getTime() , // 活动结束 一天
activeOverTimeStr2: new Date('2019-12-31 00:00:00').getTime() , // 活动结束 二天 activeOverTimeStr2: new Date('2019-12-31 00:00:00').getTime() , // 活动结束 二天
token: '',
activeOverTimeStr: new Date('2019/12/27 00:00:00') , // 活动结束
activityId: 2, // 上线前等产品通知修改默认值 activityId: 2, // 上线前等产品通知修改默认值
serverTime: '', serverTime: '',
...@@ -344,9 +347,12 @@ ...@@ -344,9 +347,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')
...@@ -361,6 +367,7 @@ ...@@ -361,6 +367,7 @@
} }
}) })
} }
}, },
mounted() { mounted() {
// 这里需要删掉!!! // 这里需要删掉!!!
...@@ -368,7 +375,6 @@ ...@@ -368,7 +375,6 @@
// 这里需要删掉!!! // 这里需要删掉!!!
vm.isWeb = vm.$rocNative.isWeb; vm.isWeb = vm.$rocNative.isWeb;
vm.getTasks();
vm.$rocNative.appInit(); vm.$rocNative.appInit();
vm.getUserInfo(); // 判断是否登录 vm.getUserInfo(); // 判断是否登录
...@@ -380,15 +386,7 @@ ...@@ -380,15 +386,7 @@
} }
} }
}, },
watch: {
clockAward(val){
alert('watch clockAward')
alert(val)
if(val.activityId && val.id && vm.isJoin){
vm.getTaskStatus(vm.clockAward);
}
}
},
methods: { methods: {
// 获取服务器时间 // 获取服务器时间
getServerTime() { getServerTime() {
...@@ -440,7 +438,8 @@ ...@@ -440,7 +438,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){ // 已登录 (有手机号表示 已登录,无手机号表示 未登录)
...@@ -450,6 +449,8 @@ ...@@ -450,6 +449,8 @@
}else{ // 未登录 }else{ // 未登录
vm.isLogin = false; vm.isLogin = false;
} }
// 登录状态确定后,再调任务接口,以便获取打卡状态
vm.getTasks();
}); });
}, },
...@@ -457,7 +458,7 @@ ...@@ -457,7 +458,7 @@
appLogin() { appLogin() {
vm.$rocNative.gotoLogin(); vm.$rocNative.gotoLogin();
}, },
// 登陆ok后 回调: 获取邀请的医生列表等。。 // 登陆ok后 回调: 获取邀请的医生列表 & 检查是否加入机构
loginCallback() { loginCallback() {
vm.getUserActivityInfo(); vm.getUserActivityInfo();
vm.goToCheckJoin(); vm.goToCheckJoin();
...@@ -722,7 +723,11 @@ ...@@ -722,7 +723,11 @@
}) })
} }
}else{ // 非打卡,直接走积木tims跳转逻辑 }else{ // 非打卡,直接走积木tims跳转逻辑
// vm.jumpPage(item.) // alert('去课程或者患者招募 。。。。。。')
if(item.isFinish == 0){ // 已完成 不可点
return;
}
vm.jumpPage(item.linkId);
} }
}, },
...@@ -775,6 +780,9 @@ ...@@ -775,6 +780,9 @@
}; };
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;
...@@ -812,7 +820,7 @@ ...@@ -812,7 +820,7 @@
} }
return true; return true;
}, },
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'){
...@@ -877,79 +885,150 @@ ...@@ -877,79 +885,150 @@
} }
return text; return text;
}, },
// async jumpPage(url, id) { <<<<<<< HEAD
// const _this = this;
// if (!!url) { async jumpPage(url, id) {
// // 判断是否有跳转 const _this = this;
// const { token, isWeb } = _this; if (!!url) {
// _this.videoWatchTime = 0; // 判断是否有跳转
// _this.widgetId = id; const { token } = _this;
// const { data } = await selectAppModuleParam({ const { data } = await selectAppModuleParam({
// id: url, id: url,
// token token
// }); });
// const itemData = data.model; alert('inJumpage'); alert(JSON.stringify(data))
// this.$sendBuriedData({ // 积木组件点击埋点 const itemData = data.model;
// url: this.baseUrl + "/file/log/trace1",
// action: 'ACTION_CLICK', // 增加点击图片时候,是否有loginFlag参数,有,则校验并登录。如未登录去登录,已登录,老逻辑。
// component_tag: `200#${_this.tempId}#0#${_this.widgetId}` const loginFlag = this.checkLoginFlag(itemData.paramList);
// }); if(loginFlag){
// if (isWeb) { _this.refreshFlag = true;
// // TODO: //如果在 web 中在这里写 _this.$rocNative.getToken().then(res => {
// if (itemData.code == 'M300') { const { userToken } = res;
// let paramList = setEventByModuleCode(itemData); // alert('APP拿到的token=:'+userToken)
// if ( checkToken({ token: userToken }).then(res=>{
// paramList[0].value.search('crrspt.') != -1 if(res.code == '200000' || res.code == '200006') {
// ) { _this.$rocNative.gotoLogin();
// // 患者招募 }else{
// paramList[0].value = _this.oldJumpHandle(itemData, userToken);
// paramList[0].value + '?' + this.paramString; }
// } })
// if (paramList[0].value.search('/wjdc/') != -1) { });
// // 问卷调查 }else{
// //console.log(paramList[0].value + '&pageUrl=' + window.location.href) _this.oldJumpHandle(itemData, _this.token);
// location.href = }
// paramList[0].value +
// '&pageUrl=' + }
// window.location.href; },
// return; // 增加一个点击图片请求selectAppModuleParam这个接口时候的 loginFlag 字段校验
// } checkLoginFlag(paramList){
// location.href = paramList[0].value; let flag = false;
// } else { for(let i=0;i<paramList.length;i++){
// this.$dialog if(paramList[i].key === 'loginFlag' && paramList[i].value === '1'){
// .confirm({ flag = true;
// message: '请下载最新app', break;
// confirmButtonText: '去下载', }
// className: 'go-down-msg-box' }
// }) return flag;
// .then(() => { },
// location.href = // 原先的点击图片跳转逻辑
// 'https://www.yunqueyi.com/mobile/share_pica.html?hideQrcode=true'; oldJumpHandle(itemData, token){ alert('oldJUmpHundalsdllksllll')
// }) // 不改动原先逻辑
// .catch(() => {}); if (itemData.code == 'M301') {
// } itemData.code = 'M300';
// } else { //鉴权 自己调用token
// // 增加点击图片时候,是否有loginFlag参数,有,则校验并登录。如未登录去登录,已登录,老逻辑。 this.$rocNative.getToken().then(res => {
// const loginFlag = this.checkLoginFlag(itemData.paramList); const { userToken } = res;
// if(loginFlag){ // setCookie('token', userToken);
// _this.refreshFlag = true; // setCookie('headToken', userToken);
// _this.$rocNative.getToken().then(res => { cookies.set('token', userToken);
// const { userToken } = res; cookies.set('headToken', userToken);
// // alert('APP拿到的token=:'+userToken)
// checkToken({ token: userToken }).then(res=>{ this.setJQ(itemData, userToken);
// if(res.code == '200000' || res.code == '200006') { });
// _this.$rocNative.gotoLogin(); } else {
// }else{ const paramList = setEventByModuleCode(
// _this.oldJumpHandle(itemData, userToken); itemData,
// } token
// }) );
// }); this.$rocNative.dispatchEventByModuleCode({
// }else{ modeCode: itemData.code,
// _this.oldJumpHandle(itemData, _this.token); jsonString: paramList
// } });
// } }
// } },
// }, //鉴权 自己调用token 是否认证
setJQ(itemData, token) {
this.itemData = itemData;
this.getUserInfo2(itemData, token);
},
// 兼容Andriod新版本
getUserInfo2(itemData, token) {
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
});
}
});
});
},
setJQ2(itemData, token) {
let _this = this,
para = {
token: this.token,
setEntry: 'headers'
};
sayHello(para).then(res => {
if (res.code == '000000') {
_this.nonce_str = res.data.nonce_str;
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 {
this.$rocNative.showNativeToast({
message: res.message
});
}
});
},
getHeaderHeight(val){ getHeaderHeight(val){
this.padTop = val; this.padTop = val;
}, },
......
...@@ -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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册