Selaa lähdekoodia

在首页接收小程序传参

wangtao 1 viikko sitten
vanhempi
commit
23b458672d
2 muutettua tiedostoa jossa 14 lisäystä ja 11 poistoa
  1. 12 2
      src/pages/index.vue
  2. 2 9
      src/pages/login.vue

+ 12 - 2
src/pages/index.vue

@@ -446,8 +446,18 @@ function getAppRoutersData() {
 }
 
 onLoad((options) => {
-  uni.hideTabBar(); //隐藏自带tabbar
-  init(options);
+  if(options?.xcxData){
+    useStore.Login(JSON.parse(decrypt(decodeURIComponent(options.xcxData)))).then(() => {
+      useStore.GetInfo().then((res) => {
+        proxy.$settingStore.initThemeColor(storageSystem.get("themeColor")); //初始化默认主题
+        uni.hideTabBar(); //隐藏自带tabbar
+        init(options);
+      });
+    });
+  }else{
+    uni.hideTabBar(); //隐藏自带tabbar
+    init(options);
+  }
 });
 
 onShow(() => {

+ 2 - 9
src/pages/login.vue

@@ -91,6 +91,7 @@
       </view>
     </view>
   </u-modal>
+  
 </template>
 
 <script setup>
@@ -104,7 +105,6 @@ import { useStores, commonStores, xunJianStores } from "@/store/modules/index";
 /*----------------------------------公共方法引入-----------------------------------*/
 import config from "@/config";
 import { storageSystem } from "@/utils/storage";
-import { decrypt, encrypt } from "@/plugins/jsencrypt";
 /*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
 const useStore = useStores();
@@ -259,7 +259,7 @@ function submitRes() {
 
 /** 获取登录数据 */
 function login(data) {
-  proxy.$modal.loading(data?.form == "xcx" ? "加载中,请耐心等待..." : "登录中,请耐心等待...");
+  proxy.$modal.loading( "登录中,请耐心等待...");
 
   useStore.Login(data).then(() => {
     /** 获取用户信息 */
@@ -300,13 +300,6 @@ function handlePrivacy() {
 onShow(() => {
   init();
 });
-
-onLoad((options) => {
-  //微信小程序跳转
-  if (options.xcxData) {
-    login(JSON.parse(decrypt(decodeURIComponent(options.xcxData))))
-  }
-});
 </script>
 
 <style lang="scss" scoped>