提交 38101a67 编写于 作者: huangwensu's avatar huangwensu

活动首页任务调试

上级 0d939657
......@@ -33,17 +33,28 @@ export default {
type: Number | String,
default: 300
},
isLogin: {
type: Boolean | String,
default: true
},
// isLogin: {
// type: Boolean | String,
// default: true
// },
statusTextList: {
type: Array,
default: () => ['100勤奋分', '200勤奋分', '300勤奋分']
},
userMobile: {
type: String,
default: ''
}
},
watch: {
userMobile(n, o) {
this.isLogin = n ? true : false;
this.init();
}
},
data() {
return {
isLogin: false,
activeNum: 0,
activeWidth: '0%',
htmlText: '登录后完成任务,就能获得瓜分云鹊豆的资格啦!'
......
......@@ -5,9 +5,12 @@
<div v-if="item.timeStatus == 1 || (item.timeStatus == 2 && item.hideEndFlag == 2)">
<img :src="item.defaultBackgroundImage"/>
<div class="task-item" @click="linkPage(item)">
<img v-if="item.resourceType == 7" src="../static/images/task-one.png" />
<img v-if="item.resourceType == 1" src="../static/images/task-two.png" />
<img v-if="item.resourceType == 3" src="../static/images/task-five.png" />
<!-- 1.课程 2.考试 3.调查问卷 4.患者招募 5.宣教漫画 6.打卡 7.邀请 8.任务排查 9.绑定居民到微信-->
<img v-if="item.resourceType == 1" src="../static/images/task-two.png" />
<img v-if="item.resourceType == 3" src="../static/images/task-five.png" />
<img v-if="item.resourceType == 7" src="../static/images/task-one.png" />
<img v-if="item.resourceType == 8" src="../static/images/task-three.png" />
<img v-if="item.resourceType == 9" src="../static/images/task-four.png" />
<div class="task-l">
<div class="task-t">{{item.ruleName}}</div>
</div>
......@@ -25,14 +28,17 @@
<div class="task-b" v-if="handleData(item.rewardJsonInfo)[0].rewardType == 4">
{{handleData(item.rewardJsonInfo)[0].rewardQuantity}}条短信额度/人
</div>
<span class='has-bg' v-if="item.resourceType == 1">去学习</span>
<span class='has-bg' v-if="item.resourceType == 1 && (item.finishFrequency > item.doctorFinishFrequency)">去学习</span>
<span class='has-bg' v-if="item.resourceType == 1 && (item.finishFrequency == item.doctorFinishFrequency)">已完成</span>
<span class='has-bg' v-if="item.resourceType == 3">去参加</span>
<span class='has-bg' v-if="item.resourceType == 7">去邀请</span>
<span class='has-bg' v-if="item.resourceType == 7 || item.resourceType == 8">去邀请</span>
<span class='has-bg' v-if="item.resourceType == 9">去绑定</span>
<div class="task-b" v-if="item.taskFrequency == 2 && (item.cumulativeFrequency > item.nowCumulativeFrequency)">进度 {{item.nowCumulativeFrequency}}/{{item.cumulativeFrequency}}</div>
<!-- <div class="task-b" v-if="item.taskFrequency == 2 && (item.cumulativeFrequency > item.nowCumulativeFrequency)">进度 {{item.nowCumulativeFrequency}}/{{item.cumulativeFrequency}}</div>
<span v-if="item.taskFrequency == 2 && item.timeStatus == 1 && (item.cumulativeFrequency == item.nowCumulativeFrequency)">已完成</span>
<span class='has-bg' v-if="item.taskFrequency == 2 && item.timeStatus == 1 && (item.cumulativeFrequency > item.nowCumulativeFrequency) && item.nowCumulativeFrequency">继续完成</span>
<span class='has-bg' v-if="item.taskFrequency == 2 && item.timeStatus == 1 && !item.nowCumulativeFrequency">去完成</span>
<span class='has-bg' v-if="item.taskFrequency == 2 && item.timeStatus == 1 && !item.nowCumulativeFrequency">去完成</span> -->
</div>
</div>
......@@ -44,12 +50,12 @@
<script>
// asyncData fetch 在组件中无效
import { getNewActivityDesc } from '@/service';
import { setCookie, getCookie, delCookie } from '@/utils/index';
const cookies = require('cookie-universal')();
export default {
name: 'TaskActivity',
props: {
acTempId: {
type: Number,
type: Number | String,
default: 0
},
acToken: {
......@@ -59,12 +65,18 @@ export default {
userMobile: {
type: String,
default: ''
},
}
},
watch: {
acTempId(n,o) {
if(n != o) {
this.getNewActivityDesc();
}
}
},
data() {
return {
taskList: [],
taskListRefreshFlag: false,
status: true,
statusText: '去完成',
tokenFlag: false,
......@@ -72,53 +84,28 @@ export default {
clickFlag: true
}
},
watch: {
userMobile(n, o) {
if (n !== o) {
this.getNewActivityDesc();
}
},
taskRefreshF(n,o) {
if (n !== o) {
this.getNewActivityDesc();
}
},
webTaskFresh(n,o) {
if (n !== o) {
this.getNewActivityDesc();
}
}
},
created() {
this.getNewActivityDesc();
// this.getNewActivityDesc();
},
methods: {
login() {
this.$emit('taskRefresh',{taskRefreshFlag:true});
},
goRefresh() {
this.getNewActivityDesc();
},
linkPage(item) {
if((!this.isWeb && !this.userMobile) || (this.isWeb && !this.tokenFlag)) {
this.login();
if(!this.userMobile || !this.tokenFlag) {
this.$rocNative.gotoLogin();
}else {
let flag = item.timeStatus == 1 && ((item.finishFrequency == item.doctorFinishFrequency) && item.resourceType != 8);
let flag1 = item.timeStatus == 1 && ((item.finishFrequency == item.doctorFinishFrequency) && item.resourceType == 8 && item.resourceId == 1);
if(item.timeStatus == 2 || flag || flag1) { // 已结束 、 已完成不可点击
return;
}else {
// let flag = item.timeStatus == 1 && ((item.finishFrequency == item.doctorFinishFrequency) && item.resourceType != 8);
// let flag1 = item.timeStatus == 1 && ((item.finishFrequency == item.doctorFinishFrequency) && item.resourceType == 8 && item.resourceId == 1);
// if(item.timeStatus == 2 || flag || flag1) { // 已结束 、 已完成不可点击
// return;
// }else {
if(!this.clickFlag) return;
if(!this.isWeb) { this.clickFlag = false; }
let data = {
id: item.id,
href: item.linkId
href: item.linkId,
resourceType: item.resourceType
};
this.taskListRefreshFlag = !this.taskListRefreshFlag;
this.$emit('taskRef', { taskListRefreshFlag: this.taskListRefreshFlag });
this.$emit('activityTaskJump', data);
}
// }
}
},
// 活动详情
......@@ -140,14 +127,20 @@ export default {
getNewActivityDesc({ id: req.id, token: req.token }).then(res => {
if(res.code == '000000') {
if(res.data.loginStatus == 2) { // 未登录 或者token失效
delCookie('token');
cookies.remove('token');
this.tokenFlag = false;
}else {
this.tokenFlag = true;
}
this.taskList = res.data.taskRuleData;
for(let i = 0; i < this.taskList.length; i++) {
if(this.taskList[i].resourceType == 7 && this.taskList[i].resourceId == 2) {
this.taskList.splice(i,1);
}
}
}
})
},
// 处理数据
handleData(data) {
......
此差异已折叠。
......@@ -6,7 +6,7 @@
"private": true,
"scripts": {
"test": "jest",
"dev": "cross-env NODE_ENV=development NUXT_ENV_APP=dev PORT=3000 nodemon server/index.js --watch server",
"dev": "cross-env NODE_ENV=development NUXT_ENV_APP=dev HOST=0.0.0.0 PORT=3000 nodemon server/index.js --watch server",
"build": "NUXT_ENV_APP=${ENV} nuxt build",
"start": "cross-env NUXT_ENV_APP=${ENV} HOST=0.0.0.0 PORT=3016 NODE_ENV=production node server/index.js",
"generate": "nuxt generate"
......@@ -17,6 +17,7 @@
"koa": "^2.6.2",
"nuxt": "^2.0.0",
"vant": "^2.0.9",
"vconsole": "^3.3.4",
"web-buried-point": "^v2.1.0"
},
"devDependencies": {
......
<template>
<div class="container">
<Header
v-if="!userMobile"
:token="token"
:is-scroll="isScroll"
:share-title1="shareTitle1"
......@@ -16,19 +15,21 @@
<!-- 勤奋分进度 -->
<div class="progress-container">
<div class="score-info">
<div v-if="!userMobile" class="text">
<div v-if="userMobile" class="text">
<img src="../static/images/task-four.png" />
<span class="tc">我的勤奋分<span>{{12345}}</span></span>
<span class="bt" @click="selfInfo">个人明细 ></span>
</div>
<div v-if="userMobile" class="text">
<div v-if="!userMobile" class="text">
<span class="tc">登录可参加活动</span>
<span class="bt" @click="goToLogin">去登录 ></span>
</div>
</div>
<status-bar
class="progress-bar"
:isLogin="isLogin"/>
:userMobile="userMobile"
:minValue="minValue"
:maxValue="maxValue"/>
</div>
</div>
......@@ -72,7 +73,8 @@ import TaskActivity from '../components/task-activity';
import Header from '../components/header/index';
import Step from '../components/step';
import StatusBar from '../components/bussiness/status-bar';
import { getNcovRealReports } from "@/service";
import { checkToken, selectAppModuleParam } from "@/service";
const cookies = require('cookie-universal')();
export default {
components: {
......@@ -88,7 +90,7 @@ export default {
userMobile: '',
stepFlag: true,
isWeb: true,
activityId: 9,
activityId: 0,
token: '',
shareTitle1: '',
shareTitle2: '',
......@@ -105,24 +107,46 @@ export default {
imgSrc3: require('@/static/images/get-award.png'),
numText3: 3,
stepText3: '公布排名获奖名单',
stepTime3:'4月3日10:00-4月7日16:00'
stepTime3:'4月3日10:00-4月7日16:00',
minValue: 50,
maxValue: 200
}
},
async asyncData({ $axios }) {
},
created() {
},
mounted() {
let _this = this;
if (process.client) {
_this.activityId = _this.$route.query.id || 9;
window.__refresh = function() {
_this.getUserInfo();
}
}
},
mounted() {},
methods: {
async getNcovRealReports() {
await getNcovRealReports(100).then(res => {
if (res.code === "000000") {
this.infoData = res.data || this.infoData;
}
});
},
getUserInfo() {
this.$rocNative
.getUserInfo()
.then(params => {
let _t = params.userToken;
let _this = this;
_this.token = params.userToken;
cookies.set('token', _this.token);
checkToken({ _t }).then(res => {
if(res.code == '200000' || res.code == '200006') {
_this.userMobile = '';
cookies.remove('token');
}else {
_this.userMobile = params.userMobile;
cookies.set('token', _this.token);
}
})
});
},
// 查看活动规则
ruleDetail() {
this.$router.push({path: "/login-point/point-result",query: {}});
......@@ -133,19 +157,82 @@ export default {
},
// 去登录
goToLogin() {
this.$rocNative.gotoLogin();
},
// 查看个人明细
selfInfo() {
// this.$router.push({path: "/perdetails",query: {}});
this.$router.push({path: "/login-point",query: {}});
this.$router.push({path: "/perdetails",query: {}});
},
// 活动任务
activityTaskJump(data) {
//this.jumpPage(data.href, data.id);
},
if(data.resourceType == 7) { // 去邀请
}else if(data.resourceType == 8) { // 绑定居民微信
}else {
this.jumpPage(data.href, data.id);
}
},
async jumpPage(url, id) {
const _this = this;
if (!!url) { // 判断是否有跳转
const { token, isWeb } = _this;
const { data } = await selectAppModuleParam({
id: url,
token
});
const itemData = data.model;
// 增加点击图片时候,是否有loginFlag参数,有,则校验并登录。如未登录去登录,已登录,老逻辑。
const loginFlag = this.checkLoginFlag(itemData.paramList);
if(loginFlag){
_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);
}
}
},
// 原先的点击图片跳转逻辑
oldJumpHandle(itemData, token){
// 不改动原先逻辑
if (itemData.code == 'M301') {
itemData.code = 'M300';
//鉴权 自己调用token
this.$rocNative.getToken().then(res => {
const { userToken } = res;
setCookie('token', userToken);
});
} else {
const paramList = setEventByModuleCode(
itemData,
token
);
this.$rocNative.dispatchEventByModuleCode({
modeCode: itemData.code,
jsonString: paramList
});
}
},
// 增加一个点击图片请求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;
}
}
}
</script>
......
......@@ -28,7 +28,7 @@ export default {
props: {
status: {
type: String | Number,
default: 4
default: 1
}
},
data() {
......
......@@ -2,11 +2,17 @@ import Vue from 'vue';
import { BASE_URL } from '@/utils/enumerate';
import rocNative from '@/utils/jsbridge';
import WebBuriedPoint, { sendBuriedData } from 'web-buried-point';
import VConsole from 'vconsole/dist/vconsole.min.js'
const { name } = require('../package.json');
const cookies = require('cookie-universal')();
// const { NUXT_ENV_APP } = process.env;
if(!(process.env.NODE_ENV === 'uat' || process.env.NODE_ENV === 'pro')) {
// if(!(process.env.BUILD_ENV === 'pro')) {
let vConsole = new VConsole() // 初始化
}
Vue.prototype.$cookies = cookies;
Vue.prototype.$rocNative = new rocNative();
Vue.prototype.$sendBuriedData = sendBuriedData;
......
......@@ -8,10 +8,6 @@ export const getHospital = async (params) => {
return request({ url: `/api-ws/hospitals/?${str}` });
};
export const getNcovRealReports = async (pageSize) => {
return request({ url: `ncov/ncovPage/realReports?pageSize=${pageSize}` });
};
// 新的任务列表查询
export const getNewActivityDesc = async (data) => {
const { id, token } = data;
......@@ -21,4 +17,22 @@ export const getNewActivityDesc = async (data) => {
token
}
});
}
\ No newline at end of file
}
// token校验
export const checkToken = async({token}) => {
return request({
url: `campaign/admin/task/checkToken?token=${token}`,
withCredentials: true
})
}
// 获取跳转链接
export const selectAppModuleParam = async ({id, token }) => {
return request({
url: `/contents/contentAppModule/selectAppModuleParam?id=${id}&token=${token}&setEntry=true`,
withCredentials: true
});
}
......@@ -18,16 +18,16 @@ export const JsBridgeOptions = {
NATIVE_ANDROID_NAME: '__rocAndroid',
initMethodsWithCallBack: ['getToken', 'getUserInfo', 'getLocalData'], // value is string
initMethodsWithoutCallBack: [
'gotoLogin',
'appInit',
'goBack',
'shareWechat',
'showNativeToast',
'dispatchEventByModuleCode',
'appBuryingPointEntrust',
'webLoadSuccess',
'sendBuriedPoint',
'openErrorDebug'
'gotoLogin',
'appInit',
'goBack',
'shareWechat',
'showNativeToast',
'dispatchEventByModuleCode',
'appBuryingPointEntrust',
'webLoadSuccess',
'sendBuriedPoint',
'openErrorDebug'
] // value is string
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册