diff --git a/CHANGELOG.md b/CHANGELOG.md index daa21fd..42e97ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# 0.1.0 (2021-11-11) +# 0.1.0 (2021-11-12) ### 🌟 新功能 范围|描述|commitId @@ -32,6 +32,7 @@ - | 删除项目 | [00b886c](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/00b886c) - | 升级版本v3.1.0;tailwindcss添加class | [9ef05e1](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/9ef05e1) - | 向右箭头图标变化 | [8e9ca55](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/8e9ca55) + - | 填写用户信息调接口 | [a8f8267](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/a8f8267) - | 字体大小更改 | [82cfdd4](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/82cfdd4) - | 存token | [b8a178d](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/b8a178d) - | 定期任务面板骨架屏添加 | [b2698c0](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/b2698c0) diff --git a/src/apis/yanyuan.js b/src/apis/yanyuan.js index 4e1525f..5c576d0 100644 --- a/src/apis/yanyuan.js +++ b/src/apis/yanyuan.js @@ -18,7 +18,7 @@ const install = (Vue, vm) => { // 申请成为家属 vm.$u.api.applyFamily = param => vm.$u.post(`${yanyuan}/family/apply`, param); // 查询个人信息 - vm.$u.api.getPersonalInfo = param => vm.$u.post(`${yanyuan}/family/personal`, param); + vm.$u.api.getPersonalInfo = () => vm.$u.post(`${yanyuan}/family/personal`); // 绑定工具箱 vm.$u.api.bindTool = param => vm.$u.post(`${yanyuan}/tool/bind`, param); diff --git a/src/components/ChooseElder/ChooseElder.vue b/src/components/ChooseElder/ChooseElder.vue new file mode 100644 index 0000000..557c779 --- /dev/null +++ b/src/components/ChooseElder/ChooseElder.vue @@ -0,0 +1,60 @@ + + + + + diff --git a/src/components/ChooseUser/ChooseUser.vue b/src/components/ChooseUser/ChooseUser.vue new file mode 100644 index 0000000..61b8e11 --- /dev/null +++ b/src/components/ChooseUser/ChooseUser.vue @@ -0,0 +1,60 @@ + + + + + diff --git a/src/components/ConfigInfo/components/ApplyFamily.vue b/src/components/ConfigInfo/components/ApplyFamily.vue new file mode 100644 index 0000000..3ed75ac --- /dev/null +++ b/src/components/ConfigInfo/components/ApplyFamily.vue @@ -0,0 +1,110 @@ + + + + + diff --git a/src/components/ConfigInfo/components/config.js b/src/components/ConfigInfo/components/config.js index 1af1e57..1cb0f50 100644 --- a/src/components/ConfigInfo/components/config.js +++ b/src/components/ConfigInfo/components/config.js @@ -543,43 +543,47 @@ export const familyInfo = [ /** * 是否成为家属 - * 展示类型: showType: 1 标题+折叠, 2 直接展示 - * 试题类型, type:1 单选,2 日期(年月日),3 数字输入框,4 单列下拉框,5 多选,6 日期(年月日时),7 多列下拉选框, 8 文本输入框 9 多列地区选择 11 吸烟 12 饮酒 13 饮茶 + * 试题类型, type:1 文本输入框,2 数字输入框,3 性别, 4 单选, 99 其他 */ export const beFamily = [ - [ - { - name: '姓名', - showType: 2, - type: 8, - value: null, - }, - { - name: '性别', - showType: 1, - type: 1, - radioList: ['男', '女'], - value: null, - }, - { - name: '年龄', - showType: 2, - type: 3, - value: null, - }, - { - name: '职业', - showType: 1, - type: 1, - radioList: ['干部', '军人', '技术人员', '农民', '工人', '运动员', '个体商业人员', '其他'], - value: null, - }, - { - name: '文化程度', - showType: 1, - type: 1, - radioList: ['文盲', '小学', '初中', '高中或中专', '大学或大专', '大学以上', '其他'], - value: null, - }, - ], + { + name: '姓名', + label: 'name', + type: 1, + value: null, + }, + { + name: '性别', + label: 'sex', + type: 3, + radioList: ['男', '女'], + value: null, + show: false, + }, + { + name: '年龄', + label: 'age', + type: 2, + value: null, + }, + { + name: '职业', + label: 'jobTitle', + type: 4, + radioList: ['干部', '军人', '技术人员', '农民', '工人', '运动员', '个体商业人员', '其他'], + value: null, + show: false, + showOther: false, + otherValue: '', + }, + { + name: '文化程度', + label: 'educateLevel', + type: 4, + radioList: ['文盲', '小学', '初中', '高中或中专', '大学或大专', '大学以上', '其他'], + value: null, + show: false, + showOther: false, + otherValue: '', + }, ]; diff --git a/src/mixins/tool.js b/src/mixins/tool.js index 1b1a79e..099b662 100644 --- a/src/mixins/tool.js +++ b/src/mixins/tool.js @@ -1,15 +1,33 @@ // 工具箱相关处理 -import { mapState, mapActions } from 'vuex'; +import { mapState, mapMutations, mapActions } from 'vuex'; export default { - computed: mapState('yanyuan', ['toolInfo']), + data() { + return { + transferContent: '', + showElder: false, + showUser: false, + }; + }, + + watch: { + showChooseElder(val) { + this.showElder = val; + }, + + showSetUser(val) { + this.showUser = val; + }, + }, + + computed: mapState('yanyuan', ['toolInfo', 'showChooseElder', 'keyUserIds', 'applyFamilyInfo', 'showSetUser']), methods: { - ...mapActions('yanyuan', ['getCreateTrainee']), + ...mapMutations('yanyuan', ['setShowChooseElder', 'setIsApplying', 'setShowSetUser', 'setElderlyInfo']), + ...mapActions('yanyuan', ['getCreateTrainee', 'getPersonalInfo']), initTool() { const { toolInfo } = this; - console.log('toolInfo: ', toolInfo); // 工具箱是否被绑定 if (!toolInfo || !toolInfo.bindUserId || toolInfo.isBind !== 1) { console.log('工具箱没有被绑定'); @@ -35,8 +53,6 @@ export default { // 是公司用户 填写用户信息 console.log('是公司用户'); this.$t.page.openPage('/pagesYanyuan/add-info/add-info'); - - // TODO this测试 }, // 不是公司用户 @@ -53,6 +69,7 @@ export default { // 有体验用户 判断体验用户数量 console.log('有体验用户'); this.becomeUser(this.toolInfo.uxUserInfo); + return; } // 满员 已绑定 @@ -64,11 +81,9 @@ export default { becomeFamily(bindUserId) { console.log('判断是否成为家属'); this.$t.ui - .showModal('提示', '是否成为家属?') + .showModal('提示', '是否申请成为家属?') .then(async () => { - console.log('是'); const params = { bindUserId }; - console.log('params: ', params); const res = await this.getCreateTrainee(params); if (!res.length) { this.$t.ui.showToast('提醒工具箱拥有者添加使用者信息'); @@ -76,7 +91,7 @@ export default { uni.redirectTo({ url: '/pages/index/index' }); }, 2000); } else { - this.$t.page.openPage('/pagesYanyuan/be-family/be-family'); + this.setShowChooseElder(true); } }) .catch(() => { @@ -86,23 +101,121 @@ export default { // 判断是否设置为使用者 becomeUser(uxUserInfo) { - // 1个弹框 询问是否将XXX设置为使用者 多个 弹框选择使用者 - if (uxUserInfo && uxUserInfo.length === 1) { - const content = uxUserInfo[0].userName; - console.log('判断是否设置为使用者'); - - this.$t.ui - .showModal('提示', `是否将${content}设置为使用者?`) - .then(() => { - console.log('是'); - }) - .catch(() => { - console.log('否'); - }); + this.$t.ui + .showModal('提示', '是否设置使用者?') + .then(async () => { + this.setElderlyInfo(uxUserInfo); + this.setShowSetUser(true); + }) + .catch(() => { + uni.redirectTo({ url: '/pages/index/index' }); + }); + }, + + // 确定选择老人 + confirmModel() { + if (!this.keyUserIds.length) { + this.setShowChooseElder(true); + this.$t.ui.showToast('请先选择老人!'); + this.$refs.uModal.clearLoading(); + return; } - if (uxUserInfo && uxUserInfo.length > 1) { - console.log('判断是否设置为使用者'); + this.setShowChooseElder(false); + this.handlePersonalInfo(); + }, + + /** + * 查询个人信息 + */ + async handlePersonalInfo() { + try { + const data = await this.getPersonalInfo(); + this.$refs.uModal.clearLoading(); + if (!data || !data.familyId) { + // 填写用户信息 + this.setIsApplying(true); + this.$t.page.openPage('/pagesYanyuan/family-info/family-info'); + return; + } + // 申请成为家属 + this.$t.page.openPage('/pagesYanyuan/transfer-page/transfer-page?type=jiashu'); + } catch (error) { + this.$refs.uModal.clearLoading(); + console.error('error: ', error); + } + }, + + /** + * 申请成为家属 + * @param { array } keyUserIds 老人id + */ + async applyFamily() { + try { + let params = {}; + if (this.applyFamilyInfo && this.applyFamilyInfo.name) { + params = this.applyFamilyInfo; + } else { + params = { keyUserIds: this.keyUserIds }; + } + await this.$u.api.applyFamily(params); + this.transferContent = '申请已提交'; + } catch (error) { + console.error('error: ', error); + const msg = error.msg || '申请失败,稍后请重新申请'; + this.transferContent = msg; } }, + + // 取消选择老人 + cancelModel() { + this.setShowChooseElder(false); + }, + + // 确定设置使用者 + confirmSetUserModel() { + if (!this.keyUserIds.length) { + this.$t.ui.showToast('请先选择使用者!'); + this.$refs.uModal.clearLoading(); + return; + } + this.setShowSetUser(false); + // 体验账号升级 + this.handleUpgrade(); + }, + + /** + * 体验账号升级 + * @param {array} keyUserIds + */ + async handleUpgrade() { + try { + const params = { keyUserIds: this.keyUserIds }; + console.log('params: ', params); + await this.$u.api.upgradeTrainee(params); + this.$refs.uModal.clearLoading(); + this.setAlert('使用者设置成功', 'success'); + } catch (error) { + this.$refs.uModal.clearLoading(); + const msg = error.msg || '使用者设置失败,请稍后重试'; + this.setAlert(msg, 'error'); + } + }, + + // 取消设置使用者 + cancelSetUserModel() { + this.setShowSetUser(false); + }, + + // 跳转首页弹框 + setAlert(title, type) { + this.$refs.uTips.show({ + title: `${title},即将跳转首页`, + type, + duration: '3000', + }); + setTimeout(() => { + uni.redirectTo({ url: '/pages/index/index' }); + }, 2000); + }, }, }; diff --git a/src/pages.json b/src/pages.json index 88dc326..1b9ee99 100644 --- a/src/pages.json +++ b/src/pages.json @@ -81,9 +81,9 @@ } }, { - "path": "be-family/be-family", + "path": "family-info/family-info", "style": { - "navigationBarTitleText": "申请成为家属", + "navigationBarTitleText": "家属信息", "navigationStyle": "default" } } diff --git a/src/pagesYanyuan/add-info/add-info.vue b/src/pagesYanyuan/add-info/add-info.vue index d7c69d8..2441a8e 100644 --- a/src/pagesYanyuan/add-info/add-info.vue +++ b/src/pagesYanyuan/add-info/add-info.vue @@ -10,6 +10,7 @@ - - diff --git a/src/pagesYanyuan/family-info/family-info.vue b/src/pagesYanyuan/family-info/family-info.vue new file mode 100644 index 0000000..f91f788 --- /dev/null +++ b/src/pagesYanyuan/family-info/family-info.vue @@ -0,0 +1,75 @@ + + + + + diff --git a/src/pagesYanyuan/input-code/input-code.vue b/src/pagesYanyuan/input-code/input-code.vue index d293340..85d899e 100644 --- a/src/pagesYanyuan/input-code/input-code.vue +++ b/src/pagesYanyuan/input-code/input-code.vue @@ -9,6 +9,35 @@ 确认 + + + + + + + + + + + + + diff --git a/src/pagesYanyuan/scan-code/scan-code.vue b/src/pagesYanyuan/scan-code/scan-code.vue index 18b484f..60933af 100644 --- a/src/pagesYanyuan/scan-code/scan-code.vue +++ b/src/pagesYanyuan/scan-code/scan-code.vue @@ -1,9 +1,5 @@ diff --git a/src/store/yanyuan/actions.js b/src/store/yanyuan/actions.js index e438429..d8c4e77 100644 --- a/src/store/yanyuan/actions.js +++ b/src/store/yanyuan/actions.js @@ -25,7 +25,22 @@ const actions = { commit('setElderlyInfo', data); return data; } catch (error) { - uni.$t.ui.showToast(error.msg || '查询失败'); + uni.$t.ui.showToast(error.msg || '老人信息查询失败'); + } + }, + + /** + * 查询个人信息 + * @param {*} commit + */ + async getPersonalInfo({ commit }) { + try { + const data = await uni.$u.api.getPersonalInfo(); + commit('setPersonalInfo', data); + console.log('查询个人信息: ', data); + return data; + } catch (error) { + uni.$t.ui.showToast(error.msg || '个人信息查询失败'); } }, }; diff --git a/src/store/yanyuan/mutations.js b/src/store/yanyuan/mutations.js index 210ccfe..6042936 100644 --- a/src/store/yanyuan/mutations.js +++ b/src/store/yanyuan/mutations.js @@ -1,13 +1,4 @@ const mutations = { - /** - * 设置是否绑定工具箱 - * @param {object} state - * @param {array} show 项目列表 - */ - setIsBinding(state, show) { - state.isBinding = show; - }, - /** * 设置工具箱信息 * @param {object} state @@ -25,6 +16,60 @@ const mutations = { setElderlyInfo(state, data) { state.elderlyInfo = data; }, + + /** + * 设置是否显示选择老人弹框 + * @param {object} state + * @param {array} show + */ + setShowChooseElder(state, show) { + state.showChooseElder = show; + }, + + /** + * 设置查询到的个人信息 + * @param {object} state + * @param {array} data + */ + setPersonalInfo(state, data) { + state.personalInfo = data; + }, + + /** + * 设置是否正在申请成为家属 + * @param {object} state + * @param {array} show + */ + setIsApplying(state, show) { + state.isApplying = show; + }, + + /** + * 设置所选老人的id + * @param {object} state + * @param {array} data + */ + setKeyUserIds(state, data) { + state.keyUserIds = data; + }, + + /** + * 设置申请家属信息 + * @param {object} state + * @param {array} data + */ + setApplyFamilyInfo(state, data) { + state.applyFamilyInfo = data; + }, + + /** + * 设置是否设置使用者弹框 + * @param {object} state + * @param {array} show + */ + setShowSetUser(state, show) { + state.showSetUser = show; + }, }; export default mutations; diff --git a/src/store/yanyuan/state.js b/src/store/yanyuan/state.js index 06e8c27..e224704 100644 --- a/src/store/yanyuan/state.js +++ b/src/store/yanyuan/state.js @@ -1,8 +1,13 @@ /* eslint-disable */ const state = { - isBinding: false, // 工具箱是否被绑定 toolInfo: {}, // 绑定过的工具箱信息 - elderlyInfo: {}, // 用户创建的老人信息 + elderlyInfo: [], // 用户创建的老人信息 + showChooseElder: false, // 显示选择老人弹框 + personalInfo: {}, // 个人信息 + isApplying: false, // 是否正在申请成为家属 + keyUserIds: [], // 所选老人的id + applyFamilyInfo: {}, // 申请家属信息 + showSetUser: false, // 显示设置使用者弹框 }; export default state;