Browse Source

Merge branch 'master' of https://gitee.com/ccsens_s/healthyCode

remotes/origin/HEAD
songsong428 5 years ago
parent
commit
526dec7162
  1. 8
      App.vue
  2. 24
      main.js
  3. 4
      store/modules/user/actions.js
  4. 6
      utils/user.js

8
App.vue

@ -16,6 +16,7 @@ export default {
},
});
try {
await this.login();
const startTime = +this.$moment()
@ -28,11 +29,14 @@ export default {
param: {
startTime,
endTime,
token: this.token
}
token: this.token,
},
};
await this.getUserInfo(params);
await this.getHealthTypeStatus();
} catch (error) {
console.log('error: ', error);
}
},
computed: mapState('user', ['token']),

24
main.js

@ -4,6 +4,17 @@ import { http } from 'plugins/request/index';
import App from './App';
import store from './store';
// 白名单页面
const whitePathList = ['basic-info', 'statistics', 'user-code'];
/**
* 检查url是否在是否在白名单内
* @param {string} url path+query
*/
const checkWhitePath = url => {
let str = url.slice(7).split('/')[0];
return whitePathList.includes(str);
};
Vue.config.productionTip = false;
Vue.prototype.$http = http;
Vue.prototype.$moment = moment;
@ -23,14 +34,17 @@ Vue.prototype.goHome = () => {
*/
// 白名单页面
const whiteListPath = ['/pages/basic-info/basic-info','/pages/statistics/statistics','/pages/user-code/user-code']
const whiteListPath = [
'/pages/basic-info/basic-info',
'/pages/statistics/statistics',
'/pages/user-code/user-code',
];
Vue.prototype.openPage = function(path, query = '') {
let url = query ? `${path}?${query}` : path;
store.commit('user/setPagePath',url)
const choosePath = whiteListPath.indexOf(path)
if(!store.state.user.userInfo.id && choosePath === -1) {
store.commit('user/setPagePath', url);
const isWhite = checkWhitePath(url);
if (!store.state.user.userInfo.id && !isWhite) {
url = '/pages/basic-info/basic-info';
}

4
store/modules/user/actions.js

@ -12,7 +12,7 @@ const actions = {
mpLogin()
.then(params => signIn(params))
.then(data => {
// console.log('login data: ', data);
console.log('login data: ', data);
commit('setToken', data.token);
commit('setUser', data);
@ -20,7 +20,7 @@ const actions = {
})
.catch(err => {
console.log('login err: ', err);
// showModal(err.msg || '登录失败');
showModal(err.msg || '登录失败');
reject(err);
});
// #endif

6
utils/user.js

@ -8,14 +8,14 @@ import { SIGN_IN_CLIENTS, SIGN_IN_TYPES } from 'config/config.user';
* @param {string} token 服务端返回的token数据
*/
export const setToken = token => {
uni.setStorageSync('anyringToken', token);
uni.setStorageSync('token', token);
};
/**
* 获取token
* @return {string} 本地保存的token
*/
export const getToken = () => uni.getStorageSync('anyringToken');
export const getToken = () => uni.getStorageSync('token');
/**
* 提交登录信息
@ -69,7 +69,7 @@ export const wxLogin = () => {
});
};
// 微信登录
// 企业微信登录
export const wxWorkLogin = () => {
return new Promise((resolve, reject) => {
wx.qy.login({

Loading…
Cancel
Save