From 455e8a30baa5b8506d7532c2d3c4c43189e9ebc3 Mon Sep 17 00:00:00 2001 From: xy <271556543@qq.com> Date: Wed, 31 Jul 2024 18:07:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=99=E9=95=BF=E7=AB=AF=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/http.api.js | 17 +- common/http.interceptor.js | 22 +- package_sub/pages/callback/callback.vue | 17 + package_sub/pages/customer/customer.vue | 560 ++++++++++++++++++++++++ package_sub/pages/index/index.vue | 297 ++++++++++++- package_sub/pages/schedule/schedule.vue | 558 +++++++++++++++++++++++ pages.json | 20 +- pages/enter/enter.vue | 18 +- pages/login/login.vue | 128 +++++- store/index.js | 20 +- 10 files changed, 1603 insertions(+), 54 deletions(-) create mode 100644 package_sub/pages/callback/callback.vue create mode 100644 package_sub/pages/customer/customer.vue create mode 100644 package_sub/pages/schedule/schedule.vue diff --git a/common/http.api.js b/common/http.api.js index 2d2b500..e5b72a4 100644 --- a/common/http.api.js +++ b/common/http.api.js @@ -18,6 +18,12 @@ let apiTask = { customerAndOrder: "/api/nurse/customer-and-order", scheduleSave: "/api/nurse/schedule-save", }; +//站长 +let apiAdmin = { + login: "/api/admin/auth/login", + me: "/api/admin/auth/me", + scheduleList: "/api/admin/schedule/schedule-index" +} // 此处第二个参数vm,就是我们在页面使用的this,你可以通过vm获取vuex等操作 const install = (Vue, vm) => { //api方法 @@ -36,6 +42,11 @@ const install = (Vue, vm) => { let statistic = (params = {}) => vm.$u.get(apiTask.statistic, params); let customerAndOrder = (params = {}) => vm.$u.get(apiTask.customerAndOrder, params); let scheduleSave = (data = {}) => vm.$u.post(apiTask.scheduleSave, data) + + //站长 + let adminLogin = (data = {}) => vm.$u.post(apiAdmin.login, data); + let adminMe = (data = {}) => vm.$u.post(apiAdmin.me, data); + let adminScheduleList = (data = {}) => vm.$u.get(apiAdmin.scheduleList, data); // 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下 vm.$u.api = { login, @@ -51,7 +62,11 @@ const install = (Vue, vm) => { noticeDetail, statistic, customerAndOrder, - scheduleSave + scheduleSave, + + adminLogin, + adminMe, + adminScheduleList }; }; diff --git a/common/http.interceptor.js b/common/http.interceptor.js index 2defd85..189e49a 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -44,21 +44,23 @@ const install = (Vue, vm) => { if (res.statusCode === 200) { if (res.data.hasOwnProperty("errcode")) { if (res.data.errcode === 40001) { - uni.showToast({ - icon: "none", - title: "登陆过期,请重新登录" - }) - setTimeout(() => { - uni.redirectTo({ - url: '/pages/login/login' + Vue.prototype.$u.debounce(() => { + uni.showToast({ + icon: "none", + title: "登陆过期,请重新登录" }) - }, 1500) + setTimeout(() => { + uni.redirectTo({ + url: '/pages/login/login' + }) + }, 1500) + }) } else { uni.showToast({ icon: "none", title: res.data.errmsg - }) + }) return false } } else @@ -77,4 +79,4 @@ const install = (Vue, vm) => { export default { install -} +} diff --git a/package_sub/pages/callback/callback.vue b/package_sub/pages/callback/callback.vue new file mode 100644 index 0000000..342846f --- /dev/null +++ b/package_sub/pages/callback/callback.vue @@ -0,0 +1,17 @@ + + + + + diff --git a/package_sub/pages/customer/customer.vue b/package_sub/pages/customer/customer.vue new file mode 100644 index 0000000..6f372eb --- /dev/null +++ b/package_sub/pages/customer/customer.vue @@ -0,0 +1,560 @@ + + + + + diff --git a/package_sub/pages/index/index.vue b/package_sub/pages/index/index.vue index e3da14c..fc4dbb9 100644 --- a/package_sub/pages/index/index.vue +++ b/package_sub/pages/index/index.vue @@ -1,25 +1,296 @@ - diff --git a/package_sub/pages/schedule/schedule.vue b/package_sub/pages/schedule/schedule.vue new file mode 100644 index 0000000..0afbf31 --- /dev/null +++ b/package_sub/pages/schedule/schedule.vue @@ -0,0 +1,558 @@ + + + + + diff --git a/pages.json b/pages.json index 9dce92a..15b76df 100644 --- a/pages.json +++ b/pages.json @@ -96,7 +96,25 @@ { "path": "pages/index/index", "style": { - "navigationBarTitleText": "分包页面sub_index" + "navigationStyle": "custom" + } + }, + { + "path": "pages/customer/customer", + "style": { + "navigationStyle": "custom" + } + }, + { + "path": "pages/callback/callback", + "style": { + "navigationStyle": "custom" + } + }, + { + "path": "pages/schedule/schedule", + "style": { + "navigationStyle": "custom" } } ] diff --git a/pages/enter/enter.vue b/pages/enter/enter.vue index e83ef9f..c63cdd9 100644 --- a/pages/enter/enter.vue +++ b/pages/enter/enter.vue @@ -21,12 +21,18 @@ }, onShow() { setTimeout(() => { - uni.switchTab({ - url: "/pages/todayNursing/todayNursing", - complete: (res) => { - console.log(res); - } - }) + if (this.vuex_my_role === 1) { + uni.switchTab({ + url: "/pages/todayNursing/todayNursing", + complete: (res) => { + console.log(res); + } + }) + } else { + uni.redirectTo({ + url: "/package_sub/pages/index/index" + }) + } }, 3000) } } diff --git a/pages/login/login.vue b/pages/login/login.vue index 28c0371..3617000 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -22,6 +22,23 @@ :placeholder-style="placeholderStyle"> + + + + + + + 我是护工 + + + + + + + 我是站长 + + + @@ -70,6 +87,7 @@ form: { username: "", password: "", + myRole: 1, }, }; }, @@ -92,26 +110,65 @@ return false } - this.$u.api.login(this.form).then(res => { - this.$u.vuex("vuex_token", res.access_token); - - this.getInfo(); - }) + if (this.form.myRole === 1) { + this.$u.api.login(this.form).then(res => { + this.$u.vuex("vuex_token", res.access_token); + if (this.isRemeber) { + this.$u.vuex("vuex_saved_username_psd", this.form); + } else { + this.$u.vuex("vuex_saved_username_psd", { + username: "", + password: "", + }); + } + + this.getInfo(); + }) + } else { + this.$u.api.adminLogin(this.form).then(res => { + this.$u.vuex("vuex_token", res.access_token); + if (this.isRemeber) { + this.$u.vuex("vuex_saved_username_psd", this.form); + } else { + this.$u.vuex("vuex_saved_username_psd", { + username: "", + password: "", + }); + } + + this.getInfo(); + }) + } }, async getInfo() { - await this.$store.dispatch('me') - uni.showToast({ - icon: "none", - title: `欢迎回来,${this.vuex_user.name}`, - }); - setTimeout(() => { - uni.switchTab({ - url: "/pages/todayNursing/todayNursing" - }); - }, 1500) + await this.$store.dispatch('me',this.form.myRole) + if (this.form.myRole === 1) { + uni.showToast({ + icon: "none", + title: `欢迎回来,${this.vuex_user.name}`, + }); + setTimeout(() => { + uni.switchTab({ + url: "/pages/todayNursing/todayNursing" + }); + }, 1500) + } else { + uni.showToast({ + icon: "none", + title: `欢迎回来,${this.vuex_user.name}`, + }); + setTimeout(() => { + uni.redirectTo({ + url: "/package_sub/pages/index/index" + }) + },1500) + } }, }, computed: {}, + mounted() { + this.form = this.vuex_saved_username_psd; + }, }; @@ -140,7 +197,7 @@ .title { color: #fff; - padding: 414rpx 0 60rpx 76rpx; + padding: 21vh 0 60rpx 76rpx; .top-word { width: 400rpx; @@ -157,7 +214,7 @@ font-weight: 500; line-height: 46rpx; - padding-top: calc(576 - 414) rpx; + padding-top: calc(576rpx - 470rpx); } } @@ -194,6 +251,37 @@ margin-top: 40rpx; } + .role { + width: 600rpx; + display: flex; + align-items: center; + margin: 40rpx auto 0; + + & > view { + display: flex; + align-items: center; + } + .radio { + width: 28rpx; + height: 28rpx; + border-radius: 6rpx; + border: 2rpx solid #ffffff; + display: flex; + justify-content: center; + align-items: center; + } + + .radio-text { + width: 144rpx; + height: 34rpx; + font-size: 24rpx; + font-weight: 500; + color: #fff; + line-height: 34rpx; + + margin-left: 30rpx; + } + } .save-state { display: flex; @@ -225,14 +313,16 @@ } .bottom { - width: 298rpx; + width: 100%; + text-align: center; height: 34rpx; font-size: 24rpx; font-weight: 500; color: #ffffff; line-height: 34rpx; - margin: 418rpx auto 0 auto; + position: fixed; + bottom: 30rpx; } } diff --git a/store/index.js b/store/index.js index d5a827d..dba774d 100644 --- a/store/index.js +++ b/store/index.js @@ -12,7 +12,7 @@ try { } // 需要永久存储,且下次APP启动需要取出的,在state中的变量名 -let saveStateKeys = ['vuex_user', 'vuex_token']; +let saveStateKeys = ['vuex_user', 'vuex_token', 'vuex_saved_username_psd', 'vuex_my_role']; // 保存变量到本地存储中 const saveLifeData = function(key, value) { @@ -33,11 +33,17 @@ const store = new Vuex.Store({ // 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量 // 加上vuex_前缀,是防止变量名冲突,也让人一目了然 vuex_user: lifeData.vuex_user || null, + vuex_my_role: lifeData.vuex_my_role || 1, vuex_token: lifeData.vuex_token || '', vuex_version: '1.0', vuex_male_img: '/static/male.png', vuex_female_img: '/static/female.png', vuex_list_status: '', + vuex_saved_username_psd: lifeData.vuex_saved_username_psd || { + username: "", + password: "", + myRole: 1 + }, vuex_selected_customer: {},//预约护理下选择的用户信息 }, @@ -74,9 +80,15 @@ const store = new Vuex.Store({ }, actions: { - async me(context, payload) { - let res = await Vue.prototype.$u.api.me() - Vue.prototype.$u.vuex('vuex_user', res) + async me(context, role) { + if (role === 1) { + let res = await Vue.prototype.$u.api.me() + Vue.prototype.$u.vuex('vuex_user', res) + } else { + let res = await Vue.prototype.$u.api.adminMe() + Vue.prototype.$u.vuex('vuex_user', res) + } + Vue.prototype.$u.vuex('vuex_my_role', role) } } })