From 1a6e5131d4199a0311759adf03a8228e4f0cc9ae Mon Sep 17 00:00:00 2001 From: song Date: Wed, 10 Nov 2021 18:29:03 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=A7=A3=E5=86=B3error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 9 +- .env.production | 1 + .gitignore | 1 + .hbuilderx/launch.json | 17 +- CHANGELOG.md | 3 +- src/App.vue | 23 +- src/apis/yanyuan.js | 30 +++ src/common/styles/tailwind.scss | 6 + .../ConfigInfo/components/config.js | 43 ++++ src/components/Modal/Modal.vue | 13 ++ src/components/myp-one/myp-one.vue | 221 ++++++++++++++++++ src/main.js | 2 + src/mixins/tool.js | 108 +++++++++ src/mixins/userAuth.js | 1 + src/pages.json | 14 ++ src/pages/index/index.vue | 2 +- src/pagesUser/phone-bind/phone-bind.vue | 5 +- src/pagesYanyuan/be-family/be-family.vue | 18 ++ src/pagesYanyuan/input-code/input-code.vue | 54 ++--- .../transfer-page/transfer-page.vue | 33 +++ src/store/index.js | 3 +- src/store/yanyuan/actions.js | 33 +++ src/store/yanyuan/getters.js | 3 + src/store/yanyuan/index.js | 12 + src/store/yanyuan/mutations.js | 30 +++ src/store/yanyuan/state.js | 8 + 26 files changed, 634 insertions(+), 59 deletions(-) create mode 100644 src/apis/yanyuan.js create mode 100644 src/components/Modal/Modal.vue create mode 100644 src/components/myp-one/myp-one.vue create mode 100644 src/mixins/tool.js create mode 100644 src/pagesYanyuan/be-family/be-family.vue create mode 100644 src/pagesYanyuan/transfer-page/transfer-page.vue create mode 100644 src/store/yanyuan/actions.js create mode 100644 src/store/yanyuan/getters.js create mode 100644 src/store/yanyuan/index.js create mode 100644 src/store/yanyuan/mutations.js create mode 100644 src/store/yanyuan/state.js diff --git a/.env.development b/.env.development index c2ca9a4..36d7655 100644 --- a/.env.development +++ b/.env.development @@ -1,6 +1,7 @@ VUE_APP_NODE_ENV=development -VUE_APP_BASE_URL=https://www.tall.wiki -VUE_APP_API_URL=https://www.tall.wiki/gateway -VUE_APP_MSG_URL=wss://www.tall.wiki/websocket/message/v4.0/ws -VUE_APP_PROJECT_PATH=https://www.tall.wiki/tall-project +VUE_APP_BASE_URL=https://test.tall.wiki +VUE_APP_API_URL=https://test.tall.wiki/gateway +VUE_APP_MSG_URL=wss://test.tall.wiki/websocket/message/v4.0/ws +VUE_APP_PROJECT_PATH=https://test.tall.wiki/tall-project +VUE_APP_YY_API_URL=http://192.168.0.99/gateway VUE_APP_VERSION=v3.2.0 diff --git a/.env.production b/.env.production index 2743a51..4ea1f34 100644 --- a/.env.production +++ b/.env.production @@ -3,4 +3,5 @@ VUE_APP_BASE_URL=https://www.tall.wiki VUE_APP_API_URL=https://www.tall.wiki/gateway VUE_APP_MSG_URL=wss://www.tall.wiki/websocket/message/v4.0/ws VUE_APP_PROJECT_PATH=https://www.tall.wiki/tall-project +VUE_APP_YY_API_URL=http://192.168.0.99/gateway VUE_APP_VERSION=v3.2.0 diff --git a/.gitignore b/.gitignore index ccf2ca7..e12703e 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ yarn-error.log* yarn.lock package-lock.json +pages.json # Editor directories and files .project diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json index e5aaa3e..dd4ad0b 100644 --- a/.hbuilderx/launch.json +++ b/.hbuilderx/launch.json @@ -1,11 +1,16 @@ { // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/ // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数 "version": "0.0", - "configurations": [{ - "type": "uniCloud", - "default": { - "launchtype": "local" - } - } + "configurations": [{ + "default" : + { + "launchtype" : "local" + }, + "mp-weixin" : + { + "launchtype" : "local" + }, + "type" : "uniCloud" + } ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b257f1..20b1ce1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# 0.1.0 (2021-11-09) +# 0.1.0 (2021-11-10) ### 🌟 新功能 范围|描述|commitId @@ -59,6 +59,7 @@ - | 添加时间轴上下滚动 | [2b81bbc](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/2b81bbc) - | 添加药物使用记录界面 | [425cb63](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/425cb63) - | 添加设置界面 | [7ca0c59](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/7ca0c59) + - | 添加输入工具码界面 | [8c120bc](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/8c120bc) - | 添加项目排序 | [a0b491b](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/a0b491b) - | 添加首页弹出按钮及界面 | [edd56cd](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/edd56cd) - | 点击日历日期查询项目列表 | [c458385](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/c458385) diff --git a/src/App.vue b/src/App.vue index 917a006..5570548 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,13 +1,14 @@ + + diff --git a/src/components/myp-one/myp-one.vue b/src/components/myp-one/myp-one.vue new file mode 100644 index 0000000..6209b3f --- /dev/null +++ b/src/components/myp-one/myp-one.vue @@ -0,0 +1,221 @@ + + + + + diff --git a/src/main.js b/src/main.js index 5fa4fac..f190502 100644 --- a/src/main.js +++ b/src/main.js @@ -12,6 +12,7 @@ import tall from '@/apis/tall.js'; import task from '@/apis/task.js'; import uView from 'uview-ui'; import wbs from '@/apis/wbs.js'; +import yanyuan from '@/apis/yanyuan.js'; //#ifdef H5 // import './registerServiceWorker'; @@ -45,5 +46,6 @@ Vue.use(task, app); Vue.use(plugin, app); Vue.use(role, app); Vue.use(wbs, app); +Vue.use(yanyuan, app); app.$mount(); diff --git a/src/mixins/tool.js b/src/mixins/tool.js new file mode 100644 index 0000000..1b1a79e --- /dev/null +++ b/src/mixins/tool.js @@ -0,0 +1,108 @@ +// 工具箱相关处理 +import { mapState, mapActions } from 'vuex'; + +export default { + computed: mapState('yanyuan', ['toolInfo']), + + methods: { + ...mapActions('yanyuan', ['getCreateTrainee']), + + initTool() { + const { toolInfo } = this; + console.log('toolInfo: ', toolInfo); + // 工具箱是否被绑定 + if (!toolInfo || !toolInfo.bindUserId || toolInfo.isBind !== 1) { + console.log('工具箱没有被绑定'); + this.$t.page.openPage('/pagesYanyuan/scan-code/scan-code'); + // this.$t.page.openPage('/pagesYanyuan/input-code/input-code'); + return; + } + + // 不是自己 弹出是否申请成为家属 + if (toolInfo.isMine !== 1) { + console.log('绑定者不是自己'); + this.becomeFamily(toolInfo.bindUserId); + return; + } + + // 不是公司用户 + if (toolInfo.isCompany !== 1) { + console.log('不是公司用户'); + this.isNotCompany(); + return; + } + + // 是公司用户 填写用户信息 + console.log('是公司用户'); + this.$t.page.openPage('/pagesYanyuan/add-info/add-info'); + + // TODO this测试 + }, + + // 不是公司用户 + isNotCompany() { + if (this.toolInfo.isMax !== 1) { + console.log('没有满员'); + // 没有体验用户 + if (this.toolInfo.isUx !== 1) { + console.log('没有体验用户'); + // 添加新用户 + this.$t.page.openPage('/pagesYanyuan/add-info/add-info'); + return; + } + // 有体验用户 判断体验用户数量 + console.log('有体验用户'); + this.becomeUser(this.toolInfo.uxUserInfo); + } + + // 满员 已绑定 + console.log('满员'); + this.$t.page.openPage('/pagesYanyuan/transfer-page/transfer-page?type=manyuan'); + }, + + // 判断是否成为家属 + becomeFamily(bindUserId) { + console.log('判断是否成为家属'); + this.$t.ui + .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('提醒工具箱拥有者添加使用者信息'); + setTimeout(() => { + uni.redirectTo({ url: '/pages/index/index' }); + }, 2000); + } else { + this.$t.page.openPage('/pagesYanyuan/be-family/be-family'); + } + }) + .catch(() => { + uni.redirectTo({ url: '/pages/index/index' }); + }); + }, + + // 判断是否设置为使用者 + 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('否'); + }); + } + if (uxUserInfo && uxUserInfo.length > 1) { + console.log('判断是否设置为使用者'); + } + }, + }, +}; diff --git a/src/mixins/userAuth.js b/src/mixins/userAuth.js index ffbe93f..4c09e27 100644 --- a/src/mixins/userAuth.js +++ b/src/mixins/userAuth.js @@ -6,6 +6,7 @@ export default { computed: mapState('user', ['token', 'user']), methods: { ...mapMutations('user', ['setUser']), + // 获取授权 openAuth() { if (this.user && this.user.wxInfo && this.user.wxInfo.nickname) return; // 用户信息里有微信信息就不用再获取了 diff --git a/src/pages.json b/src/pages.json index 0892005..88dc326 100644 --- a/src/pages.json +++ b/src/pages.json @@ -72,6 +72,20 @@ "navigationBarTitleText": "脑力测评", "navigationStyle": "default" } + }, + { + "path": "transfer-page/transfer-page", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "default" + } + }, + { + "path": "be-family/be-family", + "style": { + "navigationBarTitleText": "申请成为家属", + "navigationStyle": "default" + } } ] }, diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 64b6504..ac1416a 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -1,5 +1,5 @@ diff --git a/src/pagesYanyuan/transfer-page/transfer-page.vue b/src/pagesYanyuan/transfer-page/transfer-page.vue new file mode 100644 index 0000000..dd8737d --- /dev/null +++ b/src/pagesYanyuan/transfer-page/transfer-page.vue @@ -0,0 +1,33 @@ + + + + + diff --git a/src/store/index.js b/src/store/index.js index fb6e482..09302b6 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -6,6 +6,7 @@ import socket from './socket/index'; import project from './project/index'; import role from './role/index'; import task from './task/index'; +import yanyuan from './yanyuan/index'; // 不属于具体模块的 应用级的 store内容 const state = { @@ -48,4 +49,4 @@ const mutations = { }; Vue.use(Vuex); -export default new Vuex.Store({ state, getters, mutations, modules: { user, messages, socket, project, role, task } }); +export default new Vuex.Store({ state, getters, mutations, modules: { user, messages, socket, project, role, task, yanyuan } }); diff --git a/src/store/yanyuan/actions.js b/src/store/yanyuan/actions.js new file mode 100644 index 0000000..e438429 --- /dev/null +++ b/src/store/yanyuan/actions.js @@ -0,0 +1,33 @@ +const actions = { + /** + * 绑定工具箱 + * @param {*} commit + * @param {object} params + */ + async getBindTool({ commit }, params) { + try { + const data = await uni.$u.api.bindTool(params); + commit('setToolInfo', data); + return data; + } catch (error) { + uni.$t.ui.showToast(error.msg || '工具箱绑定失败'); + } + }, + + /** + * 查询用户创建的老人信息 + * @param {*} commit + * @param {object} params + */ + async getCreateTrainee({ commit }, params) { + try { + const data = await uni.$u.api.createTrainee(params); + commit('setElderlyInfo', data); + return data; + } catch (error) { + uni.$t.ui.showToast(error.msg || '查询失败'); + } + }, +}; + +export default actions; diff --git a/src/store/yanyuan/getters.js b/src/store/yanyuan/getters.js new file mode 100644 index 0000000..56c8c75 --- /dev/null +++ b/src/store/yanyuan/getters.js @@ -0,0 +1,3 @@ +const getters = {}; + +export default getters; diff --git a/src/store/yanyuan/index.js b/src/store/yanyuan/index.js new file mode 100644 index 0000000..d22f64a --- /dev/null +++ b/src/store/yanyuan/index.js @@ -0,0 +1,12 @@ +import state from './state'; +import getters from './getters'; +import mutations from './mutations'; +import actions from './actions'; + +export default { + namespaced: true, + state, + getters, + mutations, + actions, +}; diff --git a/src/store/yanyuan/mutations.js b/src/store/yanyuan/mutations.js new file mode 100644 index 0000000..210ccfe --- /dev/null +++ b/src/store/yanyuan/mutations.js @@ -0,0 +1,30 @@ +const mutations = { + /** + * 设置是否绑定工具箱 + * @param {object} state + * @param {array} show 项目列表 + */ + setIsBinding(state, show) { + state.isBinding = show; + }, + + /** + * 设置工具箱信息 + * @param {object} state + * @param {array} data 项目列表 + */ + setToolInfo(state, data) { + state.toolInfo = data; + }, + + /** + * 设置用户创建的老人信息 + * @param {object} state + * @param {array} data 项目列表 + */ + setElderlyInfo(state, data) { + state.elderlyInfo = data; + }, +}; + +export default mutations; diff --git a/src/store/yanyuan/state.js b/src/store/yanyuan/state.js new file mode 100644 index 0000000..06e8c27 --- /dev/null +++ b/src/store/yanyuan/state.js @@ -0,0 +1,8 @@ +/* eslint-disable */ +const state = { + isBinding: false, // 工具箱是否被绑定 + toolInfo: {}, // 绑定过的工具箱信息 + elderlyInfo: {}, // 用户创建的老人信息 +}; + +export default state;