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

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

......@@ -207,11 +207,12 @@
</template>
<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 h5header from '@/components/h5header';
import { getShareUrl } from '@/utils/index';
import { Toast } from 'vant';
import { setEventByModuleCode } from '@/utils';
const cookies = require('cookie-universal')();
......@@ -232,6 +233,8 @@
return {
activeOverTimeStr: new Date('2019-12-30 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, // 上线前等产品通知修改默认值
serverTime: '',
......@@ -344,9 +347,12 @@
},
created() {
vm = this;
},
mounted() {
// 取服务器时间,切换不同时间段的显示
vm.getServerTime();
// 经与后端产品确认,默认没传id的话,就取接口;默认有的话就不取接口
// 请求接口获取activityId (经与后端产品确认,默认没传id的话,就取接口;默认有的话就不取接口)
if( !vm.activityId ){
getActivityId().then(res => {
alert('guhui 获取id')
......@@ -361,6 +367,7 @@
}
})
}
},
mounted() {
// 这里需要删掉!!!
......@@ -368,7 +375,6 @@
// 这里需要删掉!!!
vm.isWeb = vm.$rocNative.isWeb;
vm.getTasks();
vm.$rocNative.appInit();
vm.getUserInfo(); // 判断是否登录
......@@ -380,15 +386,7 @@
}
}
},
watch: {
clockAward(val){
alert('watch clockAward')
alert(val)
if(val.activityId && val.id && vm.isJoin){
vm.getTaskStatus(vm.clockAward);
}
}
},
methods: {
// 获取服务器时间
getServerTime() {
......@@ -440,7 +438,8 @@
.then(params => {
// _seft.userToken = params.userToken; // 存到store里
if(params && params.userToken){
cookies.set('token', params.userToken)
cookies.set('token', params.userToken);
vm.token = params.userToken;
}
// alert(JSON.stringify(params));
if(params && params.userMobile){ // 已登录 (有手机号表示 已登录,无手机号表示 未登录)
......@@ -450,6 +449,8 @@
}else{ // 未登录
vm.isLogin = false;
}
// 登录状态确定后,再调任务接口,以便获取打卡状态
vm.getTasks();
});
},
......@@ -457,7 +458,7 @@
appLogin() {
vm.$rocNative.gotoLogin();
},
// 登陆ok后 回调: 获取邀请的医生列表等。。
// 登陆ok后 回调: 获取邀请的医生列表 & 检查是否加入机构
loginCallback() {
vm.getUserActivityInfo();
vm.goToCheckJoin();
......@@ -722,7 +723,11 @@
})
}
}else{ // 非打卡,直接走积木tims跳转逻辑
// vm.jumpPage(item.)
// alert('去课程或者患者招募 。。。。。。')
if(item.isFinish == 0){ // 已完成 不可点
return;
}
vm.jumpPage(item.linkId);
}
},
......@@ -775,6 +780,9 @@
};
vm.taskObj.clock = item;
if(vm.isLogin){ // 登录后,获取打卡状态
vm.goToGetClockStatus(vm.clockAward);
}
}else if( item.resourceType == 1 && item.timeStatus == 1 ){ // 课程 默认奖励 20分 20豆
item.eachInviteAwardMark = 20;
item.eachInviteAwardBean = 20;
......@@ -812,7 +820,7 @@
}
return true;
},
getTaskStatus(params) {
goToGetClockStatus(params) {
vm.isClockFinish = false;
getClockStatus(params).then(res => {
if(res && res.code == '000000'){
......@@ -877,79 +885,150 @@
}
return text;
},
// async jumpPage(url, id) {
// const _this = this;
// if (!!url) {
// // 判断是否有跳转
// const { token, isWeb } = _this;
// _this.videoWatchTime = 0;
// _this.widgetId = id;
// const { data } = await selectAppModuleParam({
// id: url,
// token
// });
// const itemData = data.model;
// this.$sendBuriedData({ // 积木组件点击埋点
// url: this.baseUrl + "/file/log/trace1",
// action: 'ACTION_CLICK',
// component_tag: `200#${_this.tempId}#0#${_this.widgetId}`
// });
// if (isWeb) {
// // TODO: //如果在 web 中在这里写
// if (itemData.code == 'M300') {
// let paramList = setEventByModuleCode(itemData);
// if (
// paramList[0].value.search('crrspt.') != -1
// ) {
// // 患者招募
// paramList[0].value =
// paramList[0].value + '?' + this.paramString;
// }
// if (paramList[0].value.search('/wjdc/') != -1) {
// // 问卷调查
// //console.log(paramList[0].value + '&pageUrl=' + window.location.href)
// location.href =
// paramList[0].value +
// '&pageUrl=' +
// window.location.href;
// return;
// }
// location.href = paramList[0].value;
// } else {
// this.$dialog
// .confirm({
// message: '请下载最新app',
// confirmButtonText: '去下载',
// className: 'go-down-msg-box'
// })
// .then(() => {
// location.href =
// 'https://www.yunqueyi.com/mobile/share_pica.html?hideQrcode=true';
// })
// .catch(() => {});
// }
// } else {
// // 增加点击图片时候,是否有loginFlag参数,有,则校验并登录。如未登录去登录,已登录,老逻辑。
// const loginFlag = this.checkLoginFlag(itemData.paramList);
// 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);
// }
// }
// }
// },
<<<<<<< HEAD
async jumpPage(url, id) {
const _this = this;
if (!!url) {
// 判断是否有跳转
const { token } = _this;
const { data } = await selectAppModuleParam({
id: url,
token
});
alert('inJumpage'); alert(JSON.stringify(data))
const itemData = data.model;
// 增加点击图片时候,是否有loginFlag参数,有,则校验并登录。如未登录去登录,已登录,老逻辑。
const loginFlag = this.checkLoginFlag(itemData.paramList);
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);
});
} else {
const paramList = setEventByModuleCode(
itemData,
token
);
this.$rocNative.dispatchEventByModuleCode({
modeCode: itemData.code,
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){
this.padTop = val;
},
......
......@@ -64,3 +64,39 @@ export const getTimsActivityInfo = (id) => {
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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册