From dd58c1d3a27ba48a5df050aab7c586bb9b988914 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期三, 09 四月 2025 18:01:22 +0800
Subject: [PATCH] activeTopMenuStyle

---
 src/stores/global.ts |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 56 insertions(+), 4 deletions(-)

diff --git a/src/stores/global.ts b/src/stores/global.ts
index 03e9a3b..4d219e0 100644
--- a/src/stores/global.ts
+++ b/src/stores/global.ts
@@ -10,6 +10,7 @@
 import { handleAfterLogin } from '../layout/component/login/login';
 import { isShowLogin } from './chatRoom';
 import { PostLogin, userBindingWechat } from '../api/ai/user';
+import emitter from '../utils/mitt';
 /**
  * 杩炴帴娑堟伅鍚屾鏈嶅姟
  * @returns
@@ -63,6 +64,7 @@
 
 export const checkWechatLogin = async (wxcode: string) => {
 	isShowLogin.value = false;
+	Local.set('isWechatLogin', true);
 	const loadingInstance = ElLoadingService({
 		// text: '鍔犺浇涓�...',
 		target: '.layout-parent',
@@ -74,20 +76,27 @@
 	});
 	if (res?.json_ok) {
 		handleAfterLogin(res, false);
+		Local.remove('isWechatLogin');
 
 		// 浣跨敤鏂板湴鍧�鏇挎崲褰撳墠椤甸潰,绉婚櫎寰俊鐧诲綍鍙傛暟
 		// const newUrl = window.location.href.split('?')[0];
 		// window.history.replaceState({}, '', SERVE_URL);
 		window.location.href = SERVE_URL;
+
 		// window.location.reload();
 	} else {
-		res?.json_msg && ElMessage.error(res?.json_msg);
-		isShowLogin.value = true;
+		// isShowLogin.value = true;
+		Local.set('wechatLoginMsgInfo', {
+			type: 'error',
+			value: res?.json_msg ?? '鐧诲綍澶辫触锛岃妫�鏌ユ槸鍚﹀凡缁戝畾寰俊',
+		});
+		window.location.href = SERVE_URL;
 	}
 };
 
 export const handleBindWechat = async (wxcode: string) => {
 	const userInfo = Local.get(userInfoKey);
+
 	const loadingInstance = ElLoadingService({
 		// text: '鍔犺浇涓�...',
 		target: '.layout-parent',
@@ -99,11 +108,21 @@
 		loadingInstance.close();
 	});
 	if (res?.json_ok) {
-		window.location.href = SERVE_URL;
-
 		ElMessage.success('缁戝畾鎴愬姛');
+		const userInfo = Local.get(userInfoKey);
+		Local.set(userInfoKey, {
+			...userInfo,
+			isBindWechat: true,
+			wechatNickname:res.json_url
+		});
+		setTimeout(() => {
+			window.location.href = SERVE_URL;
+		}, 700);
 	} else {
 		ElMessage.error(res?.json_msg ?? '缁戝畾澶辫触');
+		setTimeout(() => {
+			window.location.href = SERVE_URL;
+		}, 2000);
 	}
 };
 
@@ -117,3 +136,36 @@
 		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;
\ No newline at end of file

--
Gitblit v1.9.3