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

添加活动主页任务的逻辑

上级 9997b4fe
......@@ -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')();
......@@ -220,7 +221,7 @@
export default {
data () {
return {
token: '',
activityId: 2, // 上线前等产品通知修改默认值
serverTime: '',
......@@ -328,9 +329,12 @@
},
created() {
vm = this;
},
mounted() {
// 取服务器时间,切换不同时间段的显示
vm.getServerTime();
// 经与后端产品确认,默认没传id的话,就取接口;默认有的话就不取接口
// 请求接口获取activityId (经与后端产品确认,默认没传id的话,就取接口;默认有的话就不取接口)
if( !vm.activityId ){
getActivityId().then(res => {
alert('guhui 获取id')
......@@ -345,9 +349,7 @@
}
})
}
},
mounted() {
vm.getUserActivityInfo();
vm.shareObj = {
shareUrl: window.location.href,
title1: '分享title分享title',
......@@ -356,7 +358,6 @@
}
vm.isWeb = vm.$rocNative.isWeb;
vm.getTasks();
vm.$rocNative.appInit();
vm.getUserInfo(); // 判断是否登录
......@@ -368,15 +369,7 @@
}
}
},
watch: {
clockAward(val){
alert('watch clockAward')
alert(val)
if(val.activityId && val.id && vm.isJoin){
vm.getTaskStatus(vm.clockAward);
}
}
},
methods: {
// 获取服务器时间
getServerTime() {
......@@ -428,7 +421,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){ // 已登录 (有手机号表示 已登录,无手机号表示 未登录)
......@@ -438,6 +432,8 @@
}else{ // 未登录
vm.isLogin = false;
}
// 登录状态确定后,再调任务接口,以便获取打卡状态
vm.getTasks();
});
},
......@@ -445,7 +441,7 @@
appLogin() {
vm.$rocNative.gotoLogin();
},
// 登陆ok后 回调: 获取邀请的医生列表等。。
// 登陆ok后 回调: 获取邀请的医生列表 & 检查是否加入机构
loginCallback() {
vm.getUserActivityInfo();
vm.goToCheckJoin();
......@@ -708,7 +704,11 @@
})
}
}else{ // 非打卡,直接走积木tims跳转逻辑
// vm.jumpPage(item.)
// alert('去课程或者患者招募 。。。。。。')
if(item.isFinish == 0){ // 已完成 不可点
return;
}
vm.jumpPage(item.linkId);
}
},
......@@ -757,6 +757,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;
......@@ -784,12 +787,8 @@
vm.$toast(res.message);
}
})
},
getTaskStatus(params) {
goToGetClockStatus(params) {
vm.isClockFinish = false;
getClockStatus(params).then(res => {
if(res && res.code == '000000'){
......@@ -854,60 +853,19 @@
}
return text;
},
<<<<<<< HEAD
async jumpPage(url, id) {
const _this = this;
if (!!url) {
// 判断是否有跳转
const { token, isWeb } = _this;
_this.videoWatchTime = 0;
_this.widgetId = id;
const { token } = _this;
const { data } = await selectAppModuleParam({
id: url,
token
});
alert('inJumpage'); alert(JSON.stringify(data))
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){
......@@ -926,15 +884,121 @@
}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;
},
>>>>>>> c333d6d43d0751c36d403ffb7f9896282838b121
},
}
</script>>
......
......@@ -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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册