Browse Source

微信小程序跳转h5登录失效修复

wangtao 5 months ago
parent
commit
b34405e597
3 changed files with 9 additions and 25 deletions
  1. 1 0
      package.json
  2. 6 22
      src/pages/index.vue
  3. 2 3
      src/pages/login.vue

+ 1 - 0
package.json

@@ -54,6 +54,7 @@
         "@dcloudio/uni-mp-xhs": "3.0.0-alpha-4020320240703001",
         "@dcloudio/uni-quickapp-webview": "3.0.0-alpha-4020320240703001",
         "echarts": "^5.3.3",
+        "jsencrypt": "^3.3.2",
         "pinia": "2.0.14",
         "pinia-plugin-persistedstate": "^3.1.0",
         "vue": "^3.4.21",

+ 6 - 22
src/pages/index.vue

@@ -1,30 +1,20 @@
 <template>
-        <web-view :src="url"></web-view>
+  <web-view :src="url"></web-view>
 </template>
 
 <script setup>
 import { onLoad, onShow, onHide, onLaunch, onReady } from "@dcloudio/uni-app";
-import { encrypt ,decrypt} from "@/utils/jsencrypt";
-
-uni.getStorageSync("data2" )
-
+import { encrypt } from "@/utils/jsencrypt";
 // 原始数据
 const data=JSON.parse(uni.getStorageSync("data" ))
-console.log(data)
-
+data.form = "xcx"
 // 加密数据
-const encryptedData = encrypt(JSON.stringify(data));
-
-const dataToken=uni.getStorageSync("App-Token" )
-
+const encryptedData = encodeURIComponent(encrypt(JSON.stringify(data)));
 // 构造URL
-const url = `https://manager.usky.cn/mobile/#/pages/login?dataToken=${dataToken}&xcx=${encodeURIComponent(encryptedData)}`;
-console.log(url)
+const url = `https://manager.usky.cn/mobile/#/pages/index?xcxData=${encryptedData}`;
 uni.hideHomeButton()
 
- 
 onShow(() => {
-
   // 设置导航栏颜色和背景色
   uni.setNavigationBarColor({
     frontColor:"#ffffff",
@@ -32,10 +22,4 @@ onShow(() => {
   });
 
 })
-
-
-</script> 
-
-<style lang="scss" scoped>
-
-</style>
+</script> 

+ 2 - 3
src/pages/login.vue

@@ -114,7 +114,7 @@ const state = reactive({
   /** login数据 */
   phone: undefined,
   verify: undefined,
-  switchText: "验证码登录",
+  switchText: "账号密码登录",
   username: undefined,
   password: undefined,
   isPassword: true,
@@ -236,7 +236,7 @@ function submitRes() {
     verify: state.switchText == "验证码登录" ? state.verify : undefined,
     tenantId: useStore.tenantId,
     cids: proxy.$settingStore.pushClientId || undefined,
-    type: proxy.$common.isWechatMp() ? "wx" : "app",
+    type: "wx",
     openId: proxy.$common.isWechatMp() ? localStorage.getItem("wxOpenId") : undefined,
   });
 }
@@ -302,7 +302,6 @@ onShow(() => {
 });
 
 onLoad((options) => {
-  console.log(options)
   if(options.type){
     console.log('退出小程序,清缓存')
     uni.clearStorageSync()