diff --git a/common/utils.js b/common/utils.js index 0b50694..d45ffd2 100644 --- a/common/utils.js +++ b/common/utils.js @@ -280,9 +280,9 @@ a = '下午'; } if(String(year) === String(yearNow)) { - return String(month)+String(date)+ ' ' + a + String(hour) + String(minute); + return String(month)+String(date) + ' ' + String(hour) + String(minute); } - let str = String(year)+String(month)+String(date)+ ' ' + a + String(hour) + String(minute); + let str = String(year)+String(month)+String(date) + ' ' + String(hour) + String(minute); return str; } diff --git a/common/utils.js b/common/utils.js index 0b50694..d45ffd2 100644 --- a/common/utils.js +++ b/common/utils.js @@ -280,9 +280,9 @@ a = '下午'; } if(String(year) === String(yearNow)) { - return String(month)+String(date)+ ' ' + a + String(hour) + String(minute); + return String(month)+String(date) + ' ' + String(hour) + String(minute); } - let str = String(year)+String(month)+String(date)+ ' ' + a + String(hour) + String(minute); + let str = String(year)+String(month)+String(date) + ' ' + String(hour) + String(minute); return str; } diff --git a/pages/index/index.vue b/pages/index/index.vue index c15f990..15cf0ff 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -67,6 +67,7 @@ await getLogin(); } if(id === 'submit') { + this.phone = uni.getStorageSync("registerPhone"); if (this.phone) { this.checkphone(); } else { diff --git a/common/utils.js b/common/utils.js index 0b50694..d45ffd2 100644 --- a/common/utils.js +++ b/common/utils.js @@ -280,9 +280,9 @@ a = '下午'; } if(String(year) === String(yearNow)) { - return String(month)+String(date)+ ' ' + a + String(hour) + String(minute); + return String(month)+String(date) + ' ' + String(hour) + String(minute); } - let str = String(year)+String(month)+String(date)+ ' ' + a + String(hour) + String(minute); + let str = String(year)+String(month)+String(date) + ' ' + String(hour) + String(minute); return str; } diff --git a/pages/index/index.vue b/pages/index/index.vue index c15f990..15cf0ff 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -67,6 +67,7 @@ await getLogin(); } if(id === 'submit') { + this.phone = uni.getStorageSync("registerPhone"); if (this.phone) { this.checkphone(); } else { diff --git a/store/getters.js b/store/getters.js index 795f235..540b2d9 100644 --- a/store/getters.js +++ b/store/getters.js @@ -1,5 +1,6 @@ const getters = { - tabBarList: state => state.tabBar.list + tabBarList: state => state.tabBar.list, + type: state => state.tabBar.type, } export default getters; \ No newline at end of file diff --git a/common/utils.js b/common/utils.js index 0b50694..d45ffd2 100644 --- a/common/utils.js +++ b/common/utils.js @@ -280,9 +280,9 @@ a = '下午'; } if(String(year) === String(yearNow)) { - return String(month)+String(date)+ ' ' + a + String(hour) + String(minute); + return String(month)+String(date) + ' ' + String(hour) + String(minute); } - let str = String(year)+String(month)+String(date)+ ' ' + a + String(hour) + String(minute); + let str = String(year)+String(month)+String(date) + ' ' + String(hour) + String(minute); return str; } diff --git a/pages/index/index.vue b/pages/index/index.vue index c15f990..15cf0ff 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -67,6 +67,7 @@ await getLogin(); } if(id === 'submit') { + this.phone = uni.getStorageSync("registerPhone"); if (this.phone) { this.checkphone(); } else { diff --git a/store/getters.js b/store/getters.js index 795f235..540b2d9 100644 --- a/store/getters.js +++ b/store/getters.js @@ -1,5 +1,6 @@ const getters = { - tabBarList: state => state.tabBar.list + tabBarList: state => state.tabBar.list, + type: state => state.tabBar.type, } export default getters; \ No newline at end of file diff --git a/store/modules/tabBar.js b/store/modules/tabBar.js index e9048f8..34eb4a1 100644 --- a/store/modules/tabBar.js +++ b/store/modules/tabBar.js @@ -5,16 +5,17 @@ import tabBar from '../../utils/tabBar.js'; import { getUserProfile } from '@/utils/auth.js'; -let temp = 'user_applicant'; +let type = 'user_applicant'; if (uni.getStorageSync("userInfo")) { const userInfo = JSON.parse(uni.getStorageSync("userInfo")); if (userInfo.salt === "物业人员") { - temp = 'user_manager'; + type = 'user_manager'; } else { - temp = 'user_applicant'; + type = 'user_applicant'; } } -let type = temp; + + const state = { type: 'user_applicant', @@ -24,11 +25,12 @@ const mutations = { changeType(state, payload) { state.type = payload.type; + state.list = tabBar[ payload.type]; } } export default { - namespaced: true, + // namespaced: true, state, mutations } \ No newline at end of file diff --git a/common/utils.js b/common/utils.js index 0b50694..d45ffd2 100644 --- a/common/utils.js +++ b/common/utils.js @@ -280,9 +280,9 @@ a = '下午'; } if(String(year) === String(yearNow)) { - return String(month)+String(date)+ ' ' + a + String(hour) + String(minute); + return String(month)+String(date) + ' ' + String(hour) + String(minute); } - let str = String(year)+String(month)+String(date)+ ' ' + a + String(hour) + String(minute); + let str = String(year)+String(month)+String(date) + ' ' + String(hour) + String(minute); return str; } diff --git a/pages/index/index.vue b/pages/index/index.vue index c15f990..15cf0ff 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -67,6 +67,7 @@ await getLogin(); } if(id === 'submit') { + this.phone = uni.getStorageSync("registerPhone"); if (this.phone) { this.checkphone(); } else { diff --git a/store/getters.js b/store/getters.js index 795f235..540b2d9 100644 --- a/store/getters.js +++ b/store/getters.js @@ -1,5 +1,6 @@ const getters = { - tabBarList: state => state.tabBar.list + tabBarList: state => state.tabBar.list, + type: state => state.tabBar.type, } export default getters; \ No newline at end of file diff --git a/store/modules/tabBar.js b/store/modules/tabBar.js index e9048f8..34eb4a1 100644 --- a/store/modules/tabBar.js +++ b/store/modules/tabBar.js @@ -5,16 +5,17 @@ import tabBar from '../../utils/tabBar.js'; import { getUserProfile } from '@/utils/auth.js'; -let temp = 'user_applicant'; +let type = 'user_applicant'; if (uni.getStorageSync("userInfo")) { const userInfo = JSON.parse(uni.getStorageSync("userInfo")); if (userInfo.salt === "物业人员") { - temp = 'user_manager'; + type = 'user_manager'; } else { - temp = 'user_applicant'; + type = 'user_applicant'; } } -let type = temp; + + const state = { type: 'user_applicant', @@ -24,11 +25,12 @@ const mutations = { changeType(state, payload) { state.type = payload.type; + state.list = tabBar[ payload.type]; } } export default { - namespaced: true, + // namespaced: true, state, mutations } \ No newline at end of file diff --git a/utils/auth.js b/utils/auth.js index 73e2b20..3975ef0 100644 --- a/utils/auth.js +++ b/utils/auth.js @@ -1,19 +1,30 @@ import store from '@/store/index.js'; import {login} from '@/api/user.js'; import { getUserInfo } from "@/api/index.js"; +import getters from '../store/getters.js' + //获取用户信息 -export function getUserProfile() { - getUserInfo().then(resporse => { - // let temp; - // if (resporse.salt === "物业人员") { - // temp = 'user_manager'; - // this.$store.commit('changeType', {type: temp}); - // } else { - // temp = 'user_applicant'; - // this.$store.commit('changeType', {type: temp}); - // } - uni.setStorageSync('userInfo', JSON.stringify(resporse)); - }) +export async function getUserProfile() { + // getUserInfo().then(function (resporse) { + // let temp; + // if (resporse.salt === "物业人员") { + // temp = 'user_manager'; + // this.$store.commit('changeType', {type: temp}); + // console.log(this.$store.getters.type) + // } else { + // temp = 'user_applicant'; + // this.$store.commit('changeType', {type: temp}); + // } + // uni.setStorageSync('userInfo', JSON.stringify(resporse)); + // }) + const resporse = await getUserInfo(); + if (resporse.salt === "物业人员") { + store.commit('changeType', {type: 'user_manager'}); + console.log(store.getters.type) + } else { + store.commit('changeType', {type: 'user_applicant'}); + } + uni.setStorageSync('userInfo', JSON.stringify(resporse)); } export function getLogin() {