|
@@ -67,7 +67,7 @@ export const initGuidInfo = (): void => {
|
|
|
* @returns {Promise<void>}
|
|
* @returns {Promise<void>}
|
|
|
*/
|
|
*/
|
|
|
export const doWecomLogin = async (code: string): Promise<void> => {
|
|
export const doWecomLogin = async (code: string): Promise<void> => {
|
|
|
- if (isLogging) return; // 正在登录中,忽略重复调用
|
|
|
|
|
|
|
+ if (isLogging) return; // 正在登录中,忽略重复调用
|
|
|
isLogging = true;
|
|
isLogging = true;
|
|
|
try {
|
|
try {
|
|
|
const lastCodeStr = window.localStorage.getItem('lastCode');
|
|
const lastCodeStr = window.localStorage.getItem('lastCode');
|
|
@@ -89,6 +89,25 @@ export const doWecomLogin = async (code: string): Promise<void> => {
|
|
|
if (res && res.StatusCode === 200 && res.Data && res.Data.token) {
|
|
if (res && res.StatusCode === 200 && res.Data && res.Data.token) {
|
|
|
// 登录成功:存储 AIToken
|
|
// 登录成功:存储 AIToken
|
|
|
window.localStorage.setItem('AIToken', res.Data.token);
|
|
window.localStorage.setItem('AIToken', res.Data.token);
|
|
|
|
|
+ // 处理身份,身份可能为多个,只能按身份权限大小来固定为某个身份;
|
|
|
|
|
+ let roleIds = res.Data.roleIds, agent = '';
|
|
|
|
|
+ if (roleIds) {
|
|
|
|
|
+ if (roleIds.includes('2')) {
|
|
|
|
|
+ agent = 'stoneLikePaint';//服务商
|
|
|
|
|
+ } else if (roleIds.includes('0')) {
|
|
|
|
|
+ agent = 'ssb';//经销商
|
|
|
|
|
+ } else if (roleIds.includes('4')) {
|
|
|
|
|
+ agent = 'dg';//导购
|
|
|
|
|
+ } else if (roleIds.includes('1')) {
|
|
|
|
|
+ agent = 'hbs';//好邦手
|
|
|
|
|
+ } else if (roleIds.includes('3')) {
|
|
|
|
|
+ agent = 'goldShop';//金牌店
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log("roleIds=", roleIds)
|
|
|
|
|
+ console.log("agent=", agent)
|
|
|
|
|
+ window.localStorage.setItem('agentFrom', agent);
|
|
|
|
|
+ window.localStorage.setItem('agentFromAI', agent);
|
|
|
|
|
+ }
|
|
|
isLogging = false;
|
|
isLogging = false;
|
|
|
// console.log("router.currentRoute.fullPath=",router.currentRoute.fullPath)
|
|
// console.log("router.currentRoute.fullPath=",router.currentRoute.fullPath)
|
|
|
// 重新跳转目标页面(此时登录状态已满足)
|
|
// 重新跳转目标页面(此时登录状态已满足)
|
|
@@ -133,23 +152,23 @@ export const getQyCode = () => {
|
|
|
|
|
|
|
|
// utils/authLock.js
|
|
// utils/authLock.js
|
|
|
export const authLock = {
|
|
export const authLock = {
|
|
|
- // 内存锁:实时判断
|
|
|
|
|
- isAuthorizing: false,
|
|
|
|
|
- // 初始化:从本地缓存恢复锁状态(防止页面刷新后锁失效)
|
|
|
|
|
- init() {
|
|
|
|
|
- const lock = window.localStorage.getItem('isWechatAuthorizing');
|
|
|
|
|
- this.isAuthorizing = lock === 'true';
|
|
|
|
|
- },
|
|
|
|
|
- // 加锁:同时更新内存和本地缓存
|
|
|
|
|
- lock() {
|
|
|
|
|
- this.isAuthorizing = true;
|
|
|
|
|
- window.localStorage.setItem('isWechatAuthorizing', 'true');
|
|
|
|
|
- },
|
|
|
|
|
- // 解锁:同时更新内存和本地缓存
|
|
|
|
|
- unlock() {
|
|
|
|
|
- this.isAuthorizing = false;
|
|
|
|
|
- window.localStorage.removeItem('isWechatAuthorizing');
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 内存锁:实时判断
|
|
|
|
|
+ isAuthorizing: false,
|
|
|
|
|
+ // 初始化:从本地缓存恢复锁状态(防止页面刷新后锁失效)
|
|
|
|
|
+ init() {
|
|
|
|
|
+ const lock = window.localStorage.getItem('isWechatAuthorizing');
|
|
|
|
|
+ this.isAuthorizing = lock === 'true';
|
|
|
|
|
+ },
|
|
|
|
|
+ // 加锁:同时更新内存和本地缓存
|
|
|
|
|
+ lock() {
|
|
|
|
|
+ this.isAuthorizing = true;
|
|
|
|
|
+ window.localStorage.setItem('isWechatAuthorizing', 'true');
|
|
|
|
|
+ },
|
|
|
|
|
+ // 解锁:同时更新内存和本地缓存
|
|
|
|
|
+ unlock() {
|
|
|
|
|
+ this.isAuthorizing = false;
|
|
|
|
|
+ window.localStorage.removeItem('isWechatAuthorizing');
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 初始化锁
|
|
// 初始化锁
|