浏览代码

更新获取值方式

wkw 2 周之前
父节点
当前提交
20e775c5bf
共有 10 个文件被更改,包括 128 次插入615 次删除
  1. 4 2
      src/App.vue
  2. 3 3
      src/components/Header/index.vue
  3. 1 1
      src/main.ts
  4. 1 30
      src/pages.json
  5. 0 316
      src/pages/home/index.vue
  6. 0 78
      src/pages/index/index.vue
  7. 0 79
      src/pages/node/index.vue
  8. 4 3
      src/pages/trade/index.vue
  9. 0 79
      src/pages/wgt/index.vue
  10. 115 24
      src/utils/utils.js

+ 4 - 2
src/App.vue

@@ -1,7 +1,9 @@
 
-<script setup lang="ts">
+<script setup>
+import {getWalletInfo} from "@/utils/utils";
 import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
-onLaunch(() => {
+onLaunch(async () => {
+  await getWalletInfo();
   console.log("App Launch");
 });
 onShow(() => {

+ 3 - 3
src/components/Header/index.vue

@@ -22,7 +22,7 @@
 </template>
 <script setup>
 import { ref,defineProps,defineEmits,onMounted } from "vue";
-import { getWalletAddress } from "@/utils/utils";
+import {getWalletInfo} from "@/utils/utils";
 const props = defineProps({
   back: {
     type: Boolean,
@@ -32,9 +32,9 @@ const props = defineProps({
 const emit = defineEmits(['update:address']);
 const address = ref("");
 const getAddress = async () =>{
-  const addr = await getWalletAddress();
+  const obj = await getWalletInfo();
+  const addr = obj.address;
   if (addr) {
-    console.log(addr);
     emit('update:address', addr);
     address.value = `${addr.slice(0, 4)}...${addr.slice(-4)}`;
   } else {

+ 1 - 1
src/main.ts

@@ -10,4 +10,4 @@ export function createApp() {
     app,
     Pinia
   };
-}
+}

+ 1 - 30
src/pages.json

@@ -1,47 +1,18 @@
 {
 	"easycom": {
-		// 注意一定要放在custom里,否则无效,https://ask.dcloud.net.cn/question/131175
 		"custom": {
 			"^u--(.*)": "uview-plus/components/u-$1/u-$1.vue",
 			"^up-(.*)": "uview-plus/components/u-$1/u-$1.vue",
 	        "^u-([^-].*)": "uview-plus/components/u-$1/u-$1.vue"
 		}
 	},
-	"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
+	"pages": [
 		{
 			"path": "pages/trade/index",
 			"style": {
 				"navigationBarTitleText": "AT榜",
 				"navigationStyle": "custom"
 			}
-		},
-		{
-			"path": "pages/home/index",
-			"style": {
-				"navigationBarTitleText": "uni-app",
-				"navigationStyle": "custom"
-			}
-		},
-		{
-			"path": "pages/index/index",
-			"style": {
-				"navigationBarTitleText": "uni-app",
-				"navigationStyle": "custom"
-			}
-		},
-		{
-			"path": "pages/node/index",
-			"style": {
-				"navigationBarTitleText": "uni-app",
-				"navigationStyle": "custom"
-			}
-		},
-		{
-			"path": "pages/wgt/index",
-			"style": {
-				"navigationBarTitleText": "uni-app",
-				"navigationStyle": "custom"
-			}
 		}
 	],
 	"tabBar": {

+ 0 - 316
src/pages/home/index.vue

@@ -1,316 +0,0 @@
-<template>
-  <!-- <view class="home">
-    <view class="content">
-      <Header></Header>
-      <view class="home-img">
-        <image src="@/static/image/home/home-banner.png" mode="widthFix" />
-      </view>
-      <view class="home-btn-box">
-        <view class="home-btn-item">资产兑换</view>
-        <view class="home-btn-item">AT榜</view>
-      </view>
-      <view class="home-code">
-        <view class="home-url">
-          <view class="url">http://www.wgt.cool</view>
-          <view class="btn">分享链接</view>
-        </view>
-        <view class="code-img">
-          <image src="@/static/image/test/code-img.png" mode="scaleToFill" />
-        </view>
-      </view>
-      <view class="home-title-box">
-        <view class="home-title-english">Platformer features</view>
-        <view class="home-title-china">平台游戏特色</view>
-      </view>
-      <view class="home-game-box">
-        <view class="game-item" v-for="item in 4" :key="item">
-          <view class="border-game">
-            <image
-              src="@/static/image/home/game-item-img.png"
-              mode="scaleToFill"
-            />
-          </view>
-          <view class="game-tag">【主播力荐】</view>
-          <view class="game-desc"
-            >主播强推网红大v都爱玩快来指尖和主播一起Happy到底!</view
-          >
-        </view>
-      </view>
-      <view class="home-title-box">
-        <view class="home-title-english">Game Recommendation</view>
-        <view class="home-title-china">游戏推荐</view>
-      </view>
-      <view class="home-swiper">
-        <up-swiper
-          :list="list5"
-          @change="(e) => (current = e.current)"
-          :autoplay="false"
-          height="320rpx"
-        >
-          <view class="swiper-item">
-            <view class="game-item-index" v-for="item in 3" :key="item">
-              <view class="game-icon-name">
-                <image
-                  src="@/static/image/test/jcc-game.png"
-                  mode="scaleToFill"
-                />
-                <view class="name-star">
-                  <view class="name">金铲铲之战</view>
-                  <view class="star">
-                    <up-rate
-                      :count="5"
-                      size="14"
-                      active-color="#FFD339"
-                      inactive-color="#b2b2b2"
-                      gutter="0"
-                      v-model="star"
-                    ></up-rate>
-                  </view>
-                </view>
-              </view>
-              <view class="upload-btn">立即下载</view>
-            </view>
-          </view>
-        </up-swiper>
-      </view>
-    </view>
-  </view> -->
-</template>
-  
-  <script setup>
-// import { ref, onMounted, reactive } from "vue";
-// import Header from "@/components/Header";
-// import { useCounterStore } from "@/stores/counter";
-// const counter = useCounterStore();
-// counter.count++;
-// // 自动补全! ✨
-// counter.$patch({ count: counter.count + 1 });
-// // 或使用 action 代替
-// counter.increment();
-// const star = ref(3);
-// const count = ref(0);
-// const list5 = reactive([1, 2, 3]);
-</script>
-  
-  <style lang="scss" scoped>
-// .home {
-//   position: absolute;
-//   top: 0;
-//   bottom: 0;
-//   right: 0;
-//   left: 0;
-//   overflow-y: auto;
-// }
-// .content {
-//   display: flex;
-//   flex-direction: column;
-//   align-items: center;
-//   width: 100%;
-//   min-height: 100%;
-//   padding: 32rpx;
-//   padding-top: 116rpx;
-//   box-sizing: border-box;
-//   background-image: url("@/static/image/home/page-bg.jpg");
-//   // background: url('../../static/image/home/page-bg.jpg');
-//   background-size: 100%;
-//   background-position: 0 0;
-//   background-repeat: no-repeat;
-//   .home-img {
-//     width: 100%;
-//     display: flex;
-//     justify-content: center;
-//     align-items: center;
-//     image {
-//       width: 100%;
-//     }
-//   }
-//   .home-btn-box {
-//     display: flex;
-//     justify-content: space-between;
-//     align-items: center;
-//     width: 100%;
-//     .home-btn-item {
-//       width: 184rpx;
-//       height: 68rpx;
-//       background-image: url("@/static/image/home/home-btn.png");
-//       background-size: 100% auto;
-//       background-repeat: no-repeat;
-//       text-align: center;
-//       color: #ecb2a8;
-//       font-style: italic;
-//       font-family: DOUYUFONT-2;
-//       font-weight: 400 !important;
-//       display: flex;
-//       justify-content: center;
-//       align-items: center;
-//     }
-//   }
-//   .home-code {
-//     margin: 24rpx 0;
-//     width: 100%;
-//     padding: 20rpx;
-//     box-sizing: border-box;
-//     display: flex;
-//     justify-content: space-between;
-//     align-items: center;
-//     background-image: url("@/static/image/home/home-border.png");
-//     background-position: center;
-//     background-size: 100%;
-//     background-repeat: no-repeat;
-//     .home-url {
-//       padding: 0 12rpx;
-//       flex: 1;
-//       overflow: hidden;
-//       .url {
-//         font-size: 32rpx;
-//         color: #fff;
-//         overflow: hidden;
-//         text-overflow: ellipsis;
-//         white-space: nowrap;
-//       }
-//       .btn {
-//         // width: 254rpx;
-//         margin-top: 24rpx;
-//         width: 300rpx;
-//         height: 70rpx;
-//         background-image: url("@/static/image/home/share-btn.png");
-//         background-position: center;
-//         background-size: 100% 100%;
-//         background-repeat: no-repeat;
-//         display: flex;
-//         justify-content: center;
-//         align-items: center;
-//         color: #4f2917;
-//         font-size: 28rpx;
-//         font-weight: 600;
-//       }
-//     }
-//     .code-img {
-//       flex-shrink: 0;
-//       // background: yellow;
-//       width: 160rpx;
-//       height: 160rpx;
-//       image {
-//         width: 100%;
-//         height: 100%;
-//       }
-//     }
-//   }
-//   .home-title-box {
-//     position: relative;
-//     font-size: 32rpx;
-//     font-weight: 700;
-//     .home-title-english {
-//       color: #534135;
-//       text-transform: uppercase;
-//     }
-//     .home-title-china {
-//       color: #fff;
-//       position: absolute;
-//       left: 0;
-//       right: 0;
-//       display: flex;
-//       justify-content: center;
-//       align-items: center;
-//       top: 18rpx;
-//     }
-//   }
-//   .home-game-box {
-//     width: 100%;
-//     display: grid;
-//     grid-template-columns: repeat(2, minmax(0, 1fr));
-//     gap: 24rpx;
-//     margin-top: 36rpx;
-//     margin-bottom: 24rpx;
-//     .game-item {
-//       display: flex;
-//       flex-direction: column;
-//       align-items: center;
-//       border: 2rpx solid #90645a;
-//       background-color: hsla(0, 0%, 100%, 0.1);
-//       border-radius: 16rpx;
-//       height: 420rpx;
-//       padding: 24rpx;
-//       box-sizing: border-box;
-//       .border-game {
-//         width: 180rpx;
-//         height: 180rpx;
-//         background-image: url("@/static/image/home/game-border.png");
-//         background-position: center;
-//         background-size: 100% 100%;
-//         background-repeat: no-repeat;
-//         display: flex;
-//         justify-content: center;
-//         align-items: center;
-//         image {
-//           width: 100%;
-//           height: 100%;
-//         }
-//       }
-//       .game-tag {
-//         font-size: 32rpx;
-//         font-weight: 700;
-//         color: #bb8a57;
-//       }
-//       .game-desc {
-//         color: #e6b5aa;
-//         line-height: 48rpx;
-//         text-align: center;
-//         font-size: 28rpx;
-//       }
-//     }
-//   }
-//   .home-swiper {
-//     border: 2rpx solid #90645a;
-//     background-color: hsla(0, 0%, 100%, 0.1);
-//     border-radius: 16rpx;
-//     margin-top: 36rpx;
-//     width: 100%;
-//     padding: 24rpx;
-//     box-sizing: border-box;
-//     .swiper-item {
-//       .game-item-index {
-//         display: flex;
-//         justify-content: space-between;
-//         align-items: center;
-//         margin-bottom: 24rpx;
-
-//         .game-icon-name {
-//           display: flex;
-//           align-items: center;
-//           image {
-//             border-radius: 16rpx;
-//             height: 88rpx;
-//             width: 88rpx;
-//             flex-shrink: 0;
-//           }
-//           .name-star {
-//             width: 100%;
-//             padding: 0 24rpx;
-//             box-sizing: border-box;
-//             .name {
-//               color: #fff;
-//               font-size: 28rpx;
-//               margin-bottom: 12rpx;
-//             }
-//           }
-//         }
-//         .upload-btn {
-//           padding: 12rpx 24rpx;
-//           box-sizing: border-box;
-//           border-radius: 100rpx;
-//           background: linear-gradient(to bottom, #fff1ca, #fac21a);
-//           font-size: 28rpx;
-//           color: #4c220f;
-//         }
-//       }
-//       .game-item-index:last-child() {
-//         margin-bottom: 0;
-//       }
-//     }
-//   }
-// }
-// ::v-deep .u-swiper {
-//   background: none !important;
-// }
-</style>

+ 0 - 78
src/pages/index/index.vue

@@ -1,78 +0,0 @@
-<template>
-  <view class="content">
-    <Header>
-      <template #title>ACC <span style="padding:0 12rpx;">|</span>连接钱包</template>
-    </Header>
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-    <image class="logo" src="/static/logo.png" />
-
-    <view class="text-area">
-      <text class="title">{{ title }}</text>
-    </view>
-  </view>
-</template>
-
-<script setup>
-import { ref, onMounted } from "vue";
-import Header from '@/components/Header'
-const title = ref("Hello");
-const address = ref('');
-import {getWalletAddress} from "@/utils/utils";
-onMounted(async () => {
-  const addr = await getWalletAddress();
-  if (addr) {
-    console.log(addr)
-    address.value = `${addr.slice(0, 4)}...${addr.slice(-4)}`;
-  } else {
-    address.value = '未连接钱包';
-  }
-});
-</script>
-
-<style lang="scss" scoped>
-.content {
-  display: flex;
-  flex-direction: column;
-  align-items: center;
-  justify-content: center;
-  width: 100vw;
-}
-
-.logo {
-  height: 200rpx;
-  width: 200rpx;
-  margin-top: 200rpx;
-  margin-left: auto;
-  margin-right: auto;
-  margin-bottom: 50rpx;
-}
-
-.text-area {
-  display: flex;
-  justify-content: center;
-}
-
-.title {
-  font-size: 36rpx;
-  color: #8f8f94;
-}
-</style>

+ 0 - 79
src/pages/node/index.vue

@@ -1,79 +0,0 @@
-<template>
-    <view class="content">
-      <Header>
-        <template #title>ACC <span style="padding:0 12rpx;">|</span>连接钱包</template>
-      </Header>
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-  
-      <view class="text-area">
-        <text class="title">{{ title }}</text>
-      </view>
-    </view>
-  </template>
-  
-  <script setup>
-  import { ref, onMounted } from "vue";
-  import Header from '@/components/Header'
-  const title = ref("Hello");
-  const address = ref('');
-  import {getWalletAddress} from "@/utils/utils";
-  onMounted(async () => {
-    const addr = await getWalletAddress();
-    if (addr) {
-      console.log(addr)
-      address.value = `${addr.slice(0, 4)}...${addr.slice(-4)}`;
-    } else {
-      address.value = '未连接钱包';
-    }
-  });
-  </script>
-  
-  <style lang="scss" scoped>
-  .content {
-    display: flex;
-    flex-direction: column;
-    align-items: center;
-    justify-content: center;
-    width: 100vw;
-  }
-  
-  .logo {
-    height: 200rpx;
-    width: 200rpx;
-    margin-top: 200rpx;
-    margin-left: auto;
-    margin-right: auto;
-    margin-bottom: 50rpx;
-  }
-  
-  .text-area {
-    display: flex;
-    justify-content: center;
-  }
-  
-  .title {
-    font-size: 36rpx;
-    color: #8f8f94;
-  }
-  </style>
-  

+ 4 - 3
src/pages/trade/index.vue

@@ -277,7 +277,7 @@ import { ref, onMounted,computed, reactive } from "vue";
 import Header from "@/components/Header";
 import { sendSingleReward,WGTForToken,STTForToken,getBalance } from "@/utils/web.js";
 import { matchList, matchRank, matchInfo,verifyEnroll,matchEnroll,userPrize,claimPrize,sysSetting,enrollGameMatch,receiveGamePrize } from "@/api/game";
-import { getreportlogger,AES_CBC_ENCRYPT } from "@/utils/utils.js";
+import { getWalletInfo,AES_CBC_ENCRYPT,cryptoDecode } from "@/utils/utils.js";
 import dayjs from "dayjs";
 const timeData = ref({});
 const onChange = (e) => {
@@ -305,8 +305,9 @@ const bgClass = computed(() => {
   if (gameCheck.value === 1) return 'bg2';
   return 'bg3';
 });
-const handleAddressUpdate = (addr) => {
-  privateKey.value = window.android.getPrivateKey();
+const handleAddressUpdate = async (addr) => {
+  const {privateKey} = await getWalletInfo();
+  privateKey.value = privateKey;
   walletAddress.value = addr;
   getSysSetting();
   getGameMatchList();

+ 0 - 79
src/pages/wgt/index.vue

@@ -1,79 +0,0 @@
-<template>
-    <view class="content">
-      <Header>
-        <template #title>ACC <span style="padding:0 12rpx;">|</span>连接钱包</template>
-      </Header>
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-      <image class="logo" src="/static/logo.png" />
-  
-      <view class="text-area">
-        <text class="title">{{ title }}</text>
-      </view>
-    </view>
-  </template>
-  
-  <script setup>
-  import { ref, onMounted } from "vue";
-  import Header from '@/components/Header'
-  const title = ref("Hello");
-  const address = ref('');
-  import {getWalletAddress} from "@/utils/utils";
-  onMounted(async () => {
-    const addr = await getWalletAddress();
-    if (addr) {
-      console.log(addr)
-      address.value = `${addr.slice(0, 4)}...${addr.slice(-4)}`;
-    } else {
-      address.value = '未连接钱包';
-    }
-  });
-  </script>
-  
-  <style lang="scss" scoped>
-  .content {
-    display: flex;
-    flex-direction: column;
-    align-items: center;
-    justify-content: center;
-    width: 100vw;
-  }
-  
-  .logo {
-    height: 200rpx;
-    width: 200rpx;
-    margin-top: 200rpx;
-    margin-left: auto;
-    margin-right: auto;
-    margin-bottom: 50rpx;
-  }
-  
-  .text-area {
-    display: flex;
-    justify-content: center;
-  }
-  
-  .title {
-    font-size: 36rpx;
-    color: #8f8f94;
-  }
-  </style>
-  

+ 115 - 24
src/utils/utils.js

@@ -8,35 +8,126 @@ export const getWeb3 = async () => {
     return web3;
 };
 
-// 获取当前用户钱包地址
-export const getWalletAddress = async () => {
-    let address = null;
-    try {
-        // #ifdef H5
-        const walletAddress = await window.ethereum.request({
-            method: "eth_requestAccounts",
-        });
-        address = Array.isArray(walletAddress)
-            ? walletAddress[0]
-            : walletAddress?.result?.[0];
-        // #endif
-
-        // #ifdef APP-PLUS
-        if (window.android) {
-            address = window.android.getGlobalParam("wallet");
+let address = null;
+let privateKey = null;
+let isNew = false;
+export const getWalletInfo = async () => {
+    // ✅ 新版逻辑:从 URL 参数中解密获取
+    if (!address) {
+        let queryString = window.location.search;
+        if (!queryString || queryString === '?') {
+            const hash = window.location.hash;
+            if (hash.includes('?')) {
+                queryString = '?' + hash.split('?')[1];
+            }
         }
-        // #endif
+        const query = new URLSearchParams(queryString);
+        const encryptedDapp = query.get('dapp');
+
+        if (encryptedDapp) {
+            try {
+                const dappObj = JSON.parse(cryptoDecode(decodeURIComponent(encryptedDapp)));
+                address = dappObj.address;
+                privateKey = dappObj.privateKey;
 
-        if (!address) {
-            console.warn("未获取到钱包地址");
+                if (address) uni.setStorageSync('address', address);
+                if (privateKey) uni.setStorageSync('K', cryptoEncode(privateKey));
+
+                isNew = true;
+            } catch (e) {
+                console.error('解密 dapp 参数失败', e);
+            }
         }
 
-        return address;
-    } catch (e) {
-        console.error("获取钱包地址出错:", e);
-        return null;
     }
+
+    // 2. 兼容旧版本 App 原生注入逻辑
+    // #ifdef APP-PLUS
+    if (!address && window.android) {
+        await syncWait(() => {
+            address = window.android.getGlobalParam('wallet');
+            privateKey = window.android.getPrivateKey();
+        }, 500)
+
+        if (address) uni.setStorageSync('address', address);
+        if (privateKey) uni.setStorageSync('K', cryptoEncode(privateKey));
+    }
+    // #endif
+
+    // 3. H5 环境逻辑(MetaMask、微信)
+    // #ifdef H5
+    if (!address) {
+        const ua = navigator.userAgent.toLowerCase();
+        const isWeChatBrowser = ua.includes('micromessenger');
+
+        // 微信浏览器:使用默认测试地址
+        if (isWeChatBrowser) {
+            address = '0x01Ce8d3Ae9240B029E0868f811dfF77a4F5320f2';
+            uni.setStorageSync('address', address);
+        }
+
+        // 浏览器钱包(如 MetaMask)
+        if (!address && window.ethereum) {
+            try {
+                const accounts = await window.ethereum.request({
+                    method: 'eth_requestAccounts',
+                });
+                address = Array.isArray(accounts) ? accounts[0] : accounts?.result?.[0];
+
+                if (address) uni.setStorageSync('address', address);
+            } catch (e) {
+                console.error('MetaMask 获取地址失败', e);
+            }
+        }
+    }
+    // #endif
+
+    // 获取缓存
+    if (!address && isNew) {
+        address = uni.getStorageSync('address');
+        privateKey = cryptoDecode(uni.getStorageSync('K'));
+    }
+
+    return { address, privateKey }
 };
+const syncWait = (callable, deplay = 1000) => new Promise((res, rej) => {
+    typeof callable === 'function' && callable(rej);
+    setTimeout(() => {
+        res();
+    }, deplay);
+});
+export const cryptoEncode = (data) => {
+    const KEY = 'wkwwkwwkwwkwwkwA';
+    const key = CryptoJS.enc.Utf8.parse(KEY);
+    const iv = CryptoJS.lib.WordArray.random(16); // 随机生成16字节的IV
+    const encrypted = CryptoJS.AES.encrypt(data, key, {
+        mode: CryptoJS.mode.CBC,
+        padding: CryptoJS.pad.Pkcs7,
+        iv: iv,
+    });
+    // 将IV与加密后的数据拼接并以特定格式返回,以便在Java中分离IV和加密后的数据
+    return iv.toString(CryptoJS.enc.Base64) + encrypted.toString();
+};
+export const cryptoDecode = (data) => {
+    const KEY = 'wkwwkwwkwwkwwkwA';
+    const key = CryptoJS.enc.Utf8.parse(KEY);
+    const ivBase64 = data.substring(0, 24); // 16字节的Base64编码是24字符
+    const encryptedBase64 = data.substring(24);
+    const iv = CryptoJS.enc.Base64.parse(ivBase64);
+    const decrypted = CryptoJS.AES.decrypt(encryptedBase64, key, {
+        iv: iv,
+        mode: CryptoJS.mode.CBC,
+        padding: CryptoJS.pad.Pkcs7,
+    });
+    return decrypted.toString(CryptoJS.enc.Utf8);
+};
+
+
+
+
+
+
+
 export const getreportlogger = (logger, level = 'debug', category = 'js') => {
     const error = safeStringify(logger);
     let params = {
@@ -122,7 +213,7 @@ async function getRandomString16() {
 export async function AES_CBC_ENCRYPT(val) {
     // 生成16字节(128位)的随机IV
 	const IV = await getRandomString16();
-	const KEY = window.android.getGlobalParam('key');
+    const KEY = '05f8f563b95103e1';
     if(!KEY){
         uni.showToast({
 			title: '获取失败',