Browse Source

fix:扫码

needcode 2 năm trước cách đây
mục cha
commit
3865c2a6a0
3 tập tin đã thay đổi với 22 bổ sung11 xóa
  1. 5 0
      src/App.vue
  2. 5 1
      src/pages-user/profile/profile.vue
  3. 12 10
      src/pages/map/map.vue

+ 5 - 0
src/App.vue

@@ -14,6 +14,11 @@ export default <any>{
       }
     });
   },
+  onPageNotFound() {
+    uni.switchTab({
+      url: "/pages/map/map",
+    });
+  },
 };
 </script>
 <style lang="scss">

+ 5 - 1
src/pages-user/profile/profile.vue

@@ -5,7 +5,7 @@
       open-type="chooseAvatar"
       @chooseavatar="chooseAvatar"
     >
-      <image class="avatar_image" :src="avatar"></image>
+      <image class="avatar_image" :src="avatar" @error="errorHandle"></image>
       <view class="avatar_text flex-center">编辑</view>
     </button>
   </view>
@@ -219,6 +219,10 @@ const logoutUser = () => {
   });
 };
 
+const errorHandle = (e: any) => {
+  console.log(e);
+};
+
 onLoad(() => {
   refresh();
 });

+ 12 - 10
src/pages/map/map.vue

@@ -150,6 +150,7 @@ const pointSize = {
   androidX: -14,
   androidCurrentX: -20,
 };
+import { deCode } from "../../utils/code";
 import { fetchToken, login, onLogin } from "@/api/auth";
 import { fetchStations } from "@/api/charge";
 import { fetchCollectList } from "@/api/user";
@@ -248,7 +249,7 @@ const refreshStation = (location: any) => {
   let available = 0;
   const { latitude, longitude } = location;
   if (!token.value) {
-    return
+    return;
   }
   return fetchStations(
     stationPage.value.page,
@@ -266,14 +267,14 @@ const refreshStation = (location: any) => {
     const _markers: any[] = res.map((item, index) => {
       length = 0;
       available = 0;
-      item.EquipmentInfos &&
-        item.EquipmentInfos.forEach((eq: any) => {
-          eq.ConnectorInfos &&
-            eq.ConnectorInfos.forEach((co: any) => {
+      item.equipmentInfos &&
+        item.equipmentInfos.forEach((eq: any) => {
+          eq.connectorInfos &&
+            eq.connectorInfos.forEach((co: any) => {
               length += 1;
               if (
-                co.ConnectorStatusInfo &&
-                co.ConnectorStatusInfo.Status === 1
+                co.connectorStatusInfo &&
+                co.connectorStatusInfo.status === 1
               ) {
                 available += 1;
               }
@@ -334,7 +335,7 @@ const refreshStation = (location: any) => {
 };
 
 const refresh = () => {
-  console.log('刷新电站')
+  console.log("刷新电站");
   uni.showLoading({
     title: "加载中",
   });
@@ -371,6 +372,7 @@ onLoad((query: any) => {
   console.log(fetchToken, login, onLogin);
   // 扫普通码
   if (query.q) {
+    console.log("扫普通码", decodeURIComponent(query.q));
     getApp<any>().globalData.normalCode = decodeURIComponent(query.q); // 获取到二维码原始链接内容
   }
   const menu = uni.getMenuButtonBoundingClientRect();
@@ -408,7 +410,7 @@ onLoad((query: any) => {
         if (getApp<any>().globalData.normalCode) {
           const code: string = getApp<any>().globalData.normalCode;
           getApp<any>().globalData.normalCode = "";
-          getApp<any>().deCode(code);
+          deCode(code);
         }
         token.value = _token;
         fetchCollectList().then(() => {
@@ -421,7 +423,7 @@ onLoad((query: any) => {
       if (getApp<any>().globalData.normalCode) {
         const code: string = getApp<any>().globalData.normalCode;
         getApp<any>().globalData.normalCode = "";
-        getApp<any>().deCode(code);
+        deCode(code);
       }
       refresh();
     });