zuypeng преди 1 година
родител
ревизия
f5633803ab
променени са 3 файла, в които са добавени 26 реда и са изтрити 12 реда
  1. 15 9
      src/components/station/index.vue
  2. 5 3
      src/pages-wash/device/index.vue
  3. 6 0
      src/utils/auth.ts

+ 15 - 9
src/components/station/index.vue

@@ -13,7 +13,7 @@
       <view class="station_item-content-left">
         <view class="station_item-content-left-label">
           <view class="font12 station_item-content-left-label-left">
-            <text class="station_item-content-left-label-left_idle">{{ fmtDictName('WashStation.status',item.stationStatus) }}</text>
+            <text class="station_item-content-left-label-left_idle">{{ fmtDictName('WashStation.status', item.stationStatus) }}</text>
             <text class="station_item-content-left-label-left_count">{{ item.idleParkingNum }}/{{ item.parkingNum }}</text>
           </view>
           <!--              <uv-tags size="small" class="station_item-content-left-label_tag" text="洗车机" plain shape="circle"></uv-tags>-->
@@ -25,12 +25,12 @@
         </view>
       </view>
       <view class="station_item-content-right">
-<!--        <image
-            style="width: 20px; height: 20px;color: #eeeeee;"
-            src="/static/nav.png"
-        />-->
+        <!--        <image
+                    style="width: 20px; height: 20px;color: #eeeeee;"
+                    src="/static/nav.png"
+                />-->
         <uv-icon name="map" color="#19A497"></uv-icon>
-        <text class="font12"  @click.stop="handleNavMap(item)">{{ item.distance }}km</text>
+        <text class="font12" @click.stop="handleNavMap(item)">{{ item.distance }}km</text>
         <!--            <uv-tags text="1222km" type="warning" plain size="mini"></uv-tags>-->
       </view>
     </view>
@@ -52,8 +52,7 @@ const props = defineProps({
 })
 
 
-
-const handleNavMap = (station:any) => {
+const handleNavMap = (station: any) => {
   let location = JSON.parse(station.location)
   uni.openLocation({
     latitude: location.stationLat,
@@ -65,9 +64,16 @@ const handleNavMap = (station:any) => {
 }
 
 const handleNavStation = (station: any) => {
+  let currentPages = getCurrentPages();
+  let currentPageRoute = currentPages[currentPages.length - 1].route;
+  console.log("route", currentPageRoute)
+  if (currentPageRoute?.includes('pages-wash/station/index')) {
+    return;
+
+  }
   getApp<any>().globalData.last.station = station
   uni.navigateTo({
-    url: '/pages-wash/station/index?id='+station.id
+    url: '/pages-wash/station/index?id=' + station.id
   })
   console.log(station)
 }

+ 5 - 3
src/pages-wash/device/index.vue

@@ -2,7 +2,7 @@
   <view :class="['page']">
     <view class="device-header">
       <view class="device-header_name">
-        <text>洗车机编号:No.{{ state.device.shortId }}</text>
+        <text>洗车机编号:No.{{ state.device?.shortId }}</text>
       </view>
       <view class="device-header_fun">
         <view class="device-header_func-tag" v-for="f in state.device.functionList" :key="f" style="margin-right: 10px;">
@@ -45,7 +45,7 @@ import {onHide, onLoad, onShow} from "@dcloudio/uni-app";
 import {reactive, ref} from "vue";
 import {debounce, fmtDictName} from "@/utils/common";
 import {get, post} from "@/utils/https";
-import {tryLogin} from "@/utils/auth";
+import {fetchToken, tryLogin} from "@/utils/auth";
 import LoginBar from "@/components/login-bar/index.vue";
 
 const initState = () => ({
@@ -91,7 +91,7 @@ onLoad((options: any) => {
 onShow(() => {
   addListener();
   if (!state.deviceId) {
-    console.log(getApp<any>().globalData.deviceId)
+    console.log("deviceId",getApp<any>().globalData.deviceId)
     let deviceId = getApp<any>().globalData.deviceId;
     if (deviceId) {
       loadDeviceDetail(deviceId);
@@ -121,6 +121,8 @@ const removeListener = () => {
 
 const loadDeviceDetail = (id: any) => {
   state.deviceId =id;
+  let ft = fetchToken();
+  console.log("device token ",ft)
   get(`/wash-device/queryDevice/${id}`).then((res: any) => {
     if (res.currentUserId && res.currentUserId != getApp<any>().globalData.user.id) {
       uni.showToast({

+ 6 - 0
src/utils/auth.ts

@@ -100,6 +100,12 @@ export function login(e: any): Promise<string> {
 
 export  function tryLogin(){
     return new Promise(((resolve, reject) => {
+        let ftoken = fetchToken();
+        console.log("ftoken",ftoken)
+        if(ftoken){
+            resolve(ftoken)
+            return;
+        }
         uni.login({
             success: (res) => {
                 let data = {