Browse Source

fix: 添加分享功能

develop
song 4 years ago
parent
commit
b882484a67
  1. 3
      CHANGELOG.md
  2. 1
      src/App.vue
  3. 42
      src/components/Info/Info.vue
  4. 3
      src/components/Projects/ProjectItem.vue
  5. 16
      src/mixins/tool.js
  6. 6
      src/pagesProject/project/components/ConfigInfo/ConfigInfo.vue
  7. 4
      src/pagesProject/project/components/ConfigInfo/components/Caregiver.vue
  8. 6
      src/pagesProject/project/components/ConfigInfo/components/CaregiverDetail.vue
  9. 4
      src/pagesProject/project/components/ConfigInfo/components/Medicine.vue
  10. 59
      src/pagesProject/project/components/ConfigInfo/components/MedicineDetail.vue
  11. 108
      src/pagesProject/project/project.vue
  12. 3
      src/pagesYanyuan/assess/assess.vue

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 0.1.0 (2021-12-22)
# 0.1.0 (2021-12-27)
### 🌟 新功能
范围|描述|commitId
@ -78,6 +78,7 @@
- | 登录时提示是否合并账号样式修改 | [d82bf1a](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/d82bf1a)
- | 细节调整,添加project-webview | [4d9050b](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/4d9050b)
- | 绑定手机号 | [52e0352](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/52e0352)
- | 给设置角色加小红点 | [c3adab4](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/c3adab4)
- | 缓存修改 | [63e1f0d](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/63e1f0d)
- | 缓存基本信息 | [43bd024](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/43bd024)
- | 获取用户收取那,提交用户信息 | [a3c54f1](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/a3c54f1)

1
src/App.vue

@ -59,6 +59,7 @@ export default {
async signin() {
try {
const data = await this.$u.api.signin();
console.log('登录data: ', data);
if (data && data.token) {
this.setUser(data);
this.setToken(data.token);

42
src/components/Info/Info.vue

@ -59,7 +59,6 @@
每天能睡
<input
class="mx-1 w-12 h-6 text-center border-b"
placeholder="0"
v-model="colItem.value1"
:clearable="false"
type="number"
@ -79,7 +78,6 @@
曾经是但已经戒烟已戒
<input
class="mx-1 w-12 h-6 text-center border-b"
placeholder="0"
v-model="colItem.value1"
:clearable="false"
type="number"
@ -93,7 +91,6 @@
烟龄
<input
class="mx-1 w-12 h-6 text-center border-b"
placeholder="0"
v-model="colItem.value2"
:clearable="false"
type="number"
@ -102,7 +99,6 @@
每天
<input
class="mx-1 w-12 h-6 text-center border-b"
placeholder="0"
:border="true"
v-model="colItem.value3"
type="number"
@ -163,7 +159,6 @@
曾经是但已经不喝已不喝
<input
class="mx-1 w-12 h-6 text-center border-b"
placeholder="0"
v-model="colItem.value1"
:clearable="false"
type="number"
@ -177,7 +172,6 @@
已持续
<input
class="mx-1 w-12 h-6 text-center border-b"
placeholder="0"
v-model="colItem.value2"
:clearable="false"
type="number"
@ -676,30 +670,30 @@ export default {
const item = info[j];
if (item.type !== 5) {
if (item.value === null) {
this.$t.ui.showToast(`请填写${item.name}`);
this.$emit('showToast', 'default', `请填写${item.name}`, false);
isComplete = false;
break;
}
if (item.showOther && !item.otherValue) {
this.$t.ui.showToast(`请填写${item.name}`);
this.$emit('showToast', 'default', `请填写${item.name}`, false);
isComplete = false;
break;
}
if (item.type === 10 || item.type === 11 || item.type === 12 || item.type === 13) {
if (item.value === 1 && !item.value1) {
this.$t.ui.showToast(`请填写${item.name}`);
this.$emit('showToast', 'default', `请填写${item.name}`, false);
isComplete = false;
break;
}
}
if (item.showClasses && !item.classesValue) {
this.$t.ui.showToast(`请填写${item.name}种类`);
this.$emit('showToast', 'default', `请填写${item.name}种类`, false);
isComplete = false;
break;
}
if (item.type === 13) {
if (item.showClasses && !item.frequencyValue) {
this.$t.ui.showToast(`请填写${item.name}频率`);
this.$emit('showToast', 'default', `请填写${item.name}频率`, false);
isComplete = false;
break;
}
@ -707,12 +701,12 @@ export default {
if (item.type === 11) {
if (item.value === 2) {
if (!item.value2) {
this.$t.ui.showToast(`请填写烟龄`);
this.$emit('showToast', 'default', `请填写烟龄`, false);
isComplete = false;
break;
}
if (!item.value3) {
this.$t.ui.showToast(`请填写每天抽烟数量`);
this.$emit('showToast', 'default', `请填写每天抽烟数量`, false);
isComplete = false;
break;
}
@ -720,19 +714,19 @@ export default {
}
if (item.type === 13) {
if (item.value === 2 && !item.value2) {
this.$t.ui.showToast(`请填写持续喝茶时长`);
this.$emit('showToast', 'default', `请填写持续喝茶时长`, false);
isComplete = false;
break;
}
}
} else {
if (item.value.length === 0) {
this.$t.ui.showToast(`请填写${item.name}`);
this.$emit('showToast', 'default', `请填写${item.name}`, false);
isComplete = false;
break;
}
if (item.showOther && !item.otherValue) {
this.$t.ui.showToast(`请填写其他${item.name}`);
this.$emit('showToast', 'default', `请填写其他${item.name}`, false);
isComplete = false;
break;
}
@ -846,47 +840,47 @@ export default {
await this.$u.api.updateTrainee(params);
} catch (error) {
console.error('error: ', error);
this.$t.ui.showToast(`${item.name}修改失败`);
this.$emit('showToast', 'default', `${item.name}修改失败`, false);
}
},
//
validationRequired(item) {
if (item.showOther && !item.otherValue) {
this.$t.ui.showToast(`请填写其他${item.name}`);
this.$emit('showToast', 'default', `请填写其他${item.name}`, false);
return;
}
if (item.type === 10 || item.type === 11 || item.type === 12 || item.type === 13) {
if (item.value === 1 && !item.value1) {
this.$t.ui.showToast(`请填写${item.name}`);
this.$emit('showToast', 'default', `请填写${item.name}`, false);
return;
}
}
if (item.showClasses && !item.classesValue) {
this.$t.ui.showToast(`请填写${item.name}种类`);
this.$emit('showToast', 'default', `请填写${item.name}种类`, false);
return;
}
if (item.type === 13) {
if (item.showClasses && !item.frequencyValue) {
this.$t.ui.showToast(`请填写${item.name}频率`);
this.$emit('showToast', 'default', `请填写${item.name}频率`, false);
return;
}
}
if (item.type === 11) {
if (item.value === 2) {
if (!item.value2) {
this.$t.ui.showToast(`请填写烟龄`);
this.$emit('showToast', 'default', `请填写烟龄`, false);
return;
}
if (!item.value3) {
this.$t.ui.showToast(`请填写每天抽烟数量`);
this.$emit('showToast', 'default', `请填写每天抽烟数量`, false);
return;
}
}
}
if (item.type === 13) {
if (item.value === 2 && !item.value2) {
this.$t.ui.showToast(`请填写持续喝茶时长`);
this.$emit('showToast', 'default', `请填写持续喝茶时长`, false);
return;
}
}

3
src/components/Projects/ProjectItem.vue

@ -122,13 +122,14 @@ export default {
//
openProject(project) {
this.setProject(project);
const { name, id, url } = project;
const { name, id, url, templateCode } = project;
url && (uni.$t.domain = url);
this.$u.route('/pagesProject/project/project', {
u: this.userId,
p: id,
pname: name,
url: encodeURIComponent(url),
code: templateCode,
});
},

16
src/mixins/tool.js

@ -1,5 +1,5 @@
// 工具箱相关处理
import { mapState, mapMutations, mapActions } from 'vuex';
import { mapState, mapMutations, mapActions, mapGetters } from 'vuex';
export default {
data() {
@ -20,7 +20,10 @@ export default {
},
},
computed: mapState('yanyuan', ['toolInfo', 'showChooseElder', 'keyUserIds', 'applyFamilyInfo', 'showSetUser']),
computed: {
...mapState('yanyuan', ['toolInfo', 'showChooseElder', 'keyUserIds', 'applyFamilyInfo', 'showSetUser']),
...mapGetters('user', ['userId']),
},
methods: {
...mapMutations('yanyuan', ['setShowChooseElder', 'setIsApplying', 'setShowSetUser', 'setElderlyInfo']),
@ -87,7 +90,7 @@ export default {
if (!res.length) {
this.$t.ui.showToast('您的亲属还没有添加老人信息,提醒他添加老人信息进行使用吧。');
setTimeout(() => {
uni.redirectTo({ url: '/pages/index/index' });
uni.reLaunch({ url: `/pages/index/index?u=${this.userId}` });
}, 3000);
} else {
this.showElder = true;
@ -95,7 +98,7 @@ export default {
}
})
.catch(() => {
uni.redirectTo({ url: '/pages/index/index' });
uni.reLaunch({ url: `/pages/index/index?u=${this.userId}` });
});
},
@ -108,7 +111,7 @@ export default {
this.setShowSetUser(true);
})
.catch(() => {
uni.redirectTo({ url: '/pages/index/index' });
uni.reLaunch({ url: `/pages/index/index?u=${this.userId}` });
});
},
@ -169,6 +172,7 @@ export default {
// 取消选择老人
cancelModel() {
this.setShowChooseElder(false);
uni.reLaunch({ url: `/pages/index/index?u=${this.userId}` });
},
// 确定设置使用者
@ -213,7 +217,7 @@ export default {
duration: '3000',
});
setTimeout(() => {
uni.redirectTo({ url: '/pages/index/index' });
uni.reLaunch({ url: `/pages/index/index?u=${this.userId}` });
}, 2000);
},
},

6
src/pagesProject/project/components/ConfigInfo/ConfigInfo.vue

@ -31,7 +31,7 @@
<!-- 内容区 -->
<view v-if="item.open" class="w-full mt-3">
<view style="border: 1px solid #e5e5e5" v-if="index === 0">
<Info :personalInfo="personalInfo" :isEdit="true" />
<Info @showToast="showToast" :personalInfo="personalInfo" :isEdit="true" />
</view>
<Medicine @showToast="showToast" ref="medicineChild" v-if="index === 1" />
<Caregiver @showToast="showToast" ref="caregiverChild" v-if="index === 2" />
@ -114,11 +114,11 @@ export default {
},
//
showToast(type, title) {
console.log('type, title: ', type, title);
showToast(type, title, icon) {
this.$refs.uToast.show({
type,
title,
icon,
});
},

4
src/pagesProject/project/components/ConfigInfo/components/Caregiver.vue

@ -86,8 +86,8 @@ export default {
},
//
showToast(type, title) {
this.$emit('showToast', type, title);
showToast(type, title, icon) {
this.$emit('showToast', type, title, icon);
},
//

6
src/pagesProject/project/components/ConfigInfo/components/CaregiverDetail.vue

@ -238,12 +238,14 @@ export default {
for (let j = 0; j < info.length; j++) {
const item = info[j];
if (item.showOther && !item.otherValue) {
this.$t.ui.showToast(`请填写其他${item.name}`);
// this.$t.ui.showToast(`${item.name}`);
this.$emit('showToast', 'default', `请填写其他${item.name}`, false);
isComplete = false;
break;
}
if (!item.value) {
this.$t.ui.showToast(`请填写${item.name}`);
// this.$t.ui.showToast(`${item.name}`);
this.$emit('showToast', 'default', `请填写${item.name}`, false);
isComplete = false;
break;
}

4
src/pagesProject/project/components/ConfigInfo/components/Medicine.vue

@ -67,8 +67,8 @@ export default {
},
//
showToast(type, title) {
this.$emit('showToast', type, title);
showToast(type, title, icon) {
this.$emit('showToast', type, title, icon);
},
//

59
src/pagesProject/project/components/ConfigInfo/components/MedicineDetail.vue

@ -5,7 +5,7 @@
<view class="pl-4 py-3 font-bold border-b">{{ item.title }}</view>
<template v-for="(colItem, itemIndex) in item.date">
<view :key="itemIndex" class="flex justify-between mx-4 items-center text-sm border-b">
<view class="my-3">{{ colItem.name }}</view>
<view class="my-3" :style="{ width: colItem.type === 1 ? '' : '30%' }">{{ colItem.name }}</view>
<!-- 单选 -->
<view v-if="colItem.type === 1">
<u-radio-group v-model="colItem.value" class="flex items-center">
@ -45,6 +45,7 @@
type="number"
:clearable="false"
input-align="right"
@focus="cancelChecked(index, itemIndex, colItem.value, colItem.type)"
@blur="change(colItem.value, index, itemIndex, colItem.type)"
/>
</view>
@ -59,7 +60,7 @@
placeholder="每日总剂量(单位: mg)"
type="number"
input-align="center"
@focus="cancelChecked(index, itemIndex)"
@focus="cancelChecked(index, itemIndex, colItem.value, colItem.type)"
@blur="change(colItem.value, index, itemIndex, colItem.type)"
/>
<u-checkbox-group @change="change($event, index, itemIndex, 99)">
@ -72,15 +73,25 @@
</view>
<view class="flex flex-nowrap border-b mx-4 py-1">
<u-input :clearable="false" style="width: 100px" placeholder="其他药物" v-model="otherName.value" @blur="changeOther(otherName)" />
<u-input
:clearable="false"
style="width: 30%"
placeholder="其他药物"
v-model="otherName.value"
@focus="changeOtherChecked(otherName.value)"
@blur="changeOther(otherName)"
/>
<u-input
:clearable="false"
class="flex-1"
placeholder="每日总剂量(单位: mg)"
type="number"
input-align="center"
v-model="otherMedicine.value"
@focus="changeOtherChecked(otherMedicine.value)"
@blur="changeOther(otherMedicine)"
/>
<view class="w-24"></view>
</view>
<view class="p-4">
@ -122,6 +133,7 @@ export default {
second: true,
},
isShow: false,
originalValue: null,
};
},
@ -142,8 +154,11 @@ export default {
this.medicineInfo[index].date[itemIndex].show = !this.medicineInfo[index].date[itemIndex].show;
},
cancelChecked(index, itemIndex) {
cancelChecked(index, itemIndex, value, type) {
if (type === 4) {
this.medicineInfo[index].date[itemIndex].checked = false;
}
this.originalValue = value;
},
change(e, index, itemIndex, type) {
@ -156,7 +171,11 @@ export default {
// this.medicineInfo[0].date[1].chooseTime = e === 1 ? true : false;
this.isShow = e === 1 ? true : false;
if (!this.show) {
if (item.value === this.originalValue) {
this.originalValue = null;
} else {
this.updateMedicine(item);
}
} else {
this.params[item.label] = item.value;
}
@ -167,7 +186,11 @@ export default {
const valueDay = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second;
item.value = valueDay;
if (!this.show) {
if (item.value === this.originalValue) {
this.originalValue = null;
} else {
this.updateMedicine(item);
}
} else {
this.params[item.label] = item.value;
}
@ -186,7 +209,15 @@ export default {
default: {
item.value = e;
if (!this.show) {
if (type === 4 && !item.checked && !item.value) {
item.checked = true;
} else {
if (item.value === this.originalValue) {
this.originalValue = null;
} else {
this.updateMedicine(item);
}
}
} else {
this.params[item.label] = item.value;
}
@ -195,10 +226,17 @@ export default {
}
},
changeOtherChecked(value) {
this.originalValue = value;
},
changeOther(item) {
console.log(this.show);
if (!this.show) {
if (item.value === this.originalValue) {
this.originalValue = null;
} else {
this.updateMedicine(item);
}
} else {
this.params[item.label] = item.value;
}
@ -233,28 +271,28 @@ export default {
switch (item.type) {
case 2: {
if (this.isShow && !item.value) {
this.$t.ui.showToast(`请选择测评时间`);
this.$emit('showToast', 'default', '请选择测评时间', false);
isComplete = false;
}
break;
}
case 3: {
if (this.isShow && !item.value) {
this.$t.ui.showToast(`请填写${item.name}`);
this.$emit('showToast', 'default', `请填写${item.name}`, false);
isComplete = false;
}
break;
}
case 4: {
if (!item.value && !item.checked) {
this.$t.ui.showToast(`请填写${item.name}`);
this.$emit('showToast', 'default', `请填写${item.name}`, false);
isComplete = false;
}
break;
}
default: {
if (!item.value) {
this.$t.ui.showToast(`请填写${item.name}`);
this.$emit('showToast', 'default', `请填写${item.name}`, false);
isComplete = false;
}
break;
@ -356,6 +394,9 @@ export default {
try {
const params = { id: this.detail.id };
params[item.label] = item.value;
if (item.checked) {
params[item.label] = '未服用';
}
await this.$u.api.updateMedicine(params);
this.$emit('showToast', 'success', '修改成功');
} catch (error) {

108
src/pagesProject/project/project.vue

@ -63,6 +63,7 @@ export default {
chooseItem: false,
showGuide: false,
isSetting: false, //
templateCode: '',
};
},
@ -78,19 +79,37 @@ export default {
},
onLoad(options) {
console.log('AAA: ', options);
this.templateCode = options.code;
if (options.share && options.share === '1') {
console.log('0001');
// TODO:
console.log('options.code: ', options.code);
this.queryGuide(options.code);
this.shareInit(options);
} else {
if ((this.scene === 1007 || this.scene === 1008) && !this.showGuide) {
let timer = null;
timer = setInterval(() => {
if (this.token && this.userId) {
clearInterval(timer);
this.shareWeixinInit(options);
}
}, 300);
} else {
console.log('0002');
this.init(options);
this.shareWeixinInit(options);
// TODO:
// this.queryGuide(options.code);
// this.init(options);
}
}
//
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline'],
});
// wx.showShareMenu({
// withShareTicket: true,
// menus: ['shareAppMessage', 'shareTimeline'],
// });
},
watch: {
@ -100,7 +119,6 @@ export default {
* 永久日常任务不发生改变
*/
timeNode(val) {
console.log('timeNode: ', val);
if (val && this.roleId) {
this.clearTasksData();
this.getGlobalData(); //
@ -119,7 +137,7 @@ export default {
if (this.isSetting) return;
this.setTimeNode(Date.now());
//
const params = { roleId: val, projectId: this.projectId, templateCode: this.project.templateCode };
const params = { roleId: val, projectId: this.projectId, templateCode: this.templateCode };
this.getPermanent(params);
}
},
@ -140,8 +158,6 @@ export default {
this.$nextTick(async () => {
const system = uni.getSystemInfoSync();
this.height = system.windowHeight + 'px';
// TODO:
await this.queryGuide();
});
},
@ -151,6 +167,18 @@ export default {
this.setScrollToTaskId('');
},
onShareAppMessage() {
const { name, id, url, templateCode } = this.project;
url && (uni.$t.domain = url);
return {
u: this.userId,
p: id,
pname: name,
url: encodeURIComponent(url),
code: templateCode,
};
},
methods: {
...mapActions('user', ['getToken']),
...mapActions('task', ['getRegulars', 'getPermanent', 'getGlobal']),
@ -242,7 +270,7 @@ export default {
* @param {object} query getTasks传递的参数
*/
generateGetTaskParam(query) {
const { roleId, timeNode, timeUnit, projectId, project } = this;
const { roleId, timeNode, timeUnit, projectId, templateCode } = this;
return {
roleId,
timeNode: query.timeNode || timeNode,
@ -251,7 +279,7 @@ export default {
queryNum: 3,
queryType: query.queryType,
projectId,
templateCode: project.templateCode,
templateCode: templateCode,
};
},
@ -363,6 +391,7 @@ export default {
* @param {object | null} options
*/
async init(options) {
console.log('init options: ', options);
if (!this.token) {
// tokenuserIdtoken
// token userId
@ -384,17 +413,9 @@ export default {
}
// TODO
// this.getProjectById({ projectId: options.p, num: 0 }); // id
console.log('options: ', options);
// await this.queryFamilyIsMember(options.p);
console.log('this.userId: ', this.userId);
if (this.scene === 1007 || this.scene === 1008) {
console.log('查询用户是否是项目成员', this.userId);
await this.queryFamilyIsMember(options.p);
}
// id
this.getRoles({ projectId: options.p, num: 0, templateCode: this.project.templateCode });
this.getRoles({ projectId: options.p, num: 0, templateCode: options.code });
}
},
@ -419,6 +440,27 @@ export default {
}
},
//
async shareWeixinInit(options) {
console.log('小程序进来的初始化options: ', options);
await this.getProjectById({ projectId: options.p, num: 0, templateCode: options.code }); // id
await this.queryGuide(options.code);
await this.queryFamilyIsMember(options.p);
const obj = {
p: options.p,
u: this.userId,
pname: options.pname,
code: options.code,
};
this.init(obj);
// let timer = null;
// timer = setInterval(() => {
// if (!this.showGuide) {
// clearInterval(timer);
// }
// }, 300);
},
/**
* 点击分享连接
* @param {any} commit
@ -439,12 +481,13 @@ export default {
*/
async getProjectById(params) {
try {
console.log('项目params: ', params);
console.log('项目 api', uni.$u.api.findProjectById);
const data = await uni.$u.api.findProjectById(params);
console.log('项目信息: ', data);
this.setProject(data);
// id
this.getRoles(params);
} catch (error) {
console.error('error: ', error || '获取项目信息失败');
console.error('通过项目id获取项目信息 error: ', error || '获取项目信息失败');
}
},
@ -479,8 +522,8 @@ export default {
//
getGlobalData() {
const { roleId, timeNode, timeUnit, projectId } = this;
const param = { roleId, timeNode, timeUnit, projectId };
const { roleId, timeNode, timeUnit, projectId, templateCode } = this;
const param = { roleId, timeNode, timeUnit, projectId, templateCode };
this.getGlobal(param);
},
@ -500,9 +543,9 @@ export default {
* 查询是否显示引导页
* @param {object} templateCode 模板code
*/
async queryGuide() {
async queryGuide(templateCode) {
try {
const params = { templateCode: this.project.templateCode };
const params = { templateCode };
const data = await this.$u.api.queryGuide(params);
if (data.status === 0) {
this.showGuide = true;
@ -518,7 +561,7 @@ export default {
*/
async quitGuide() {
try {
const params = { templateCode: this.project.templateCode };
const params = { templateCode: this.templateCode };
await this.$u.api.updateGuide(params);
this.showGuide = false;
} catch (error) {
@ -536,16 +579,15 @@ export default {
const data = await this.$u.api.familyIsMember(params);
console.log('data: ', data);
//
if ((data.familyStatus === 1 || data.familyStatus === 2) && data.keyUserId) {
if (data.familyStatus === 2 && data.keyUserId) {
console.log('不是成员 询问是否成为家属');
const arr = [{ keyUserId: data.keyUserId, sex: data.sex, userName: data.userName }];
this.setElderlyInfo(arr);
this.showElder = true;
}
// if (data.familyStatus === 1) {
// console.log(' ');
// this.init(options);
// }
if (data.familyStatus === 1) {
console.log('是 直接打开');
}
if (data.familyStatus === 0) {
console.log('申请已提交,返回首页');
this.transferContent = '家属申请已提交,请等待审核';

3
src/pagesYanyuan/assess/assess.vue

@ -159,13 +159,14 @@ export default {
backProject() {
this.setIsEvaluated(true);
const { name, id, url } = this.project;
const { name, id, url, templateCode } = this.project;
url && (uni.$t.domain = url);
this.$u.route('/pagesProject/project/project', {
u: this.userId,
p: id,
pname: name,
url: encodeURIComponent(url),
code: templateCode,
});
},
},

Loading…
Cancel
Save