| | |
| | | |
| | | export const checkWechatLogin = async (wxcode: string) => { |
| | | isShowLogin.value = false; |
| | | Local.set('isWechatLogin', true); |
| | | const loadingInstance = ElLoadingService({ |
| | | // text: '加载中...', |
| | | target: '.layout-parent', |
| | |
| | | }); |
| | | if (res?.json_ok) { |
| | | handleAfterLogin(res, false); |
| | | Local.remove('isWechatLogin'); |
| | | |
| | | // 使用新地址替换当前页面,移除微信登录参数 |
| | | // const newUrl = window.location.href.split('?')[0]; |
| | |
| | | |
| | | // window.location.reload(); |
| | | } else { |
| | | ElMessage.error(res?.json_msg ?? '登录失败,请检查是否已绑定微信'); |
| | | |
| | | emitter.emit('setWechatTipInfo', { |
| | | // isShowLogin.value = true; |
| | | Local.set('wechatLoginMsgInfo', { |
| | | type: 'error', |
| | | value: res?.json_msg ?? '登录失败,请检查是否已绑定微信', |
| | | }); |
| | | |
| | | isShowLogin.value = true; |
| | | setTimeout(() => { |
| | | window.location.href = SERVE_URL; |
| | | }, 2500); |
| | | window.location.href = SERVE_URL; |
| | | } |
| | | }; |
| | | |
| | | export const handleBindWechat = async (wxcode: string) => { |
| | | const userInfo = Local.get(userInfoKey); |
| | | |
| | | const loadingInstance = ElLoadingService({ |
| | | // text: '加载中...', |
| | | target: '.layout-parent', |
| | |
| | | Local.set(userInfoKey, { |
| | | ...userInfo, |
| | | isBindWechat: true, |
| | | wechatNickname:res.json_url |
| | | }); |
| | | setTimeout(() => { |
| | | window.location.href = SERVE_URL; |
| | |
| | | handleBindWechat(result.wxcode); |
| | | } |
| | | }; |
| | | |
| | | |
| | | /** |
| | | * 返回一个对象,给 parent 调用 |
| | | * 此对象包含多个函数 |
| | | * @returns |
| | | */ |
| | | const childCallObj = { |
| | | /** @description 测试函数 */ |
| | | test: (msg: string) => { |
| | | console.log('test 函数来自 child', msg); |
| | | }, |
| | | execute: (obj: any) => { |
| | | console.log('execute 函数来自 child', obj); |
| | | }, |
| | | }; |
| | | export class ParentRegister { |
| | | static notify = null; |
| | | static setRegisterFunc() { |
| | | if (!window.parent) return; |
| | | (window as any).registerNotifyFunction = (notifyFunc: any) => { |
| | | ParentRegister.notify = notifyFunc; |
| | | return childCallObj; |
| | | }; |
| | | } |
| | | |
| | | static updateChildCallObj(key:string,callback:Function) { |
| | | childCallObj[key] = callback; |
| | | } |
| | | } |
| | | |
| | | |
| | | window.callObj = childCallObj; |