You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
622 B
24 lines
622 B
import ui from '@/utils/ui.js';
|
|
|
|
const actions = {
|
|
/**
|
|
* 通过userId获取token
|
|
* @param {any} commit
|
|
* @param {string} userId 用户id
|
|
*/
|
|
async getTokenByUserId({ commit }, userId) {
|
|
try {
|
|
const res = await uni.$u.api.getToken(userId);
|
|
commit('setToken', res.token);
|
|
commit('setUser', res);
|
|
uni.$storage.setStorageSync('anyringToken', res.token || '');
|
|
uni.$storage.setStorageSync('user', JSON.stringify(res));
|
|
return res;
|
|
} catch (error) {
|
|
ui.showToast(error.msg || '获取个人信息失败');
|
|
throw error;
|
|
}
|
|
},
|
|
};
|
|
|
|
export default actions;
|
|
|