2 lines
825 B
JavaScript
2 lines
825 B
JavaScript
"use strict";const e=require("../common/vendor.js"),t=require("../request/identity.js"),n=require("../request/three_one_api/info.js"),r=require("./userInfo.js");exports.performIdentitySwitch=async function(i){const o=function(e){if(!e)return{};const t=e.data;return t&&"object"==typeof t&&(t.token||t.identities||t.currentIdentity||t.roles)?t:e}(await t.switchIdentity(i));return o.token&&e.index.setStorageSync("token",o.token),o.currentIdentity&&e.index.setStorageSync("currentIdentity",JSON.stringify(o.currentIdentity)),await async function(){const e=await n.getProfileDetail();return 0===e.code&&e.data?r.saveUserInfoToStorage(e.data):null}(),o},exports.reLaunchAfterSwitch=function(){e.index.showToast({title:"身份切换成功",icon:"success"}),setTimeout((()=>{e.index.reLaunch({url:"/pages/index/index"})}),1500)};
|