Jelajahi Sumber

登录校验去除

zuypeng 1 tahun lalu
induk
melakukan
591c290d4f
4 mengubah file dengan 107 tambahan dan 73 penghapusan
  1. 3 3
      src/components/station/index.vue
  2. 73 53
      src/pages/index/index.vue
  3. 23 11
      src/pages/user/index.vue
  4. 8 6
      src/utils/https.ts

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

@@ -21,7 +21,7 @@
           <!--              <view class="station_item-content-left-label_func">{{ ['清洁', '泡沫', '吸尘', '消毒', '充电']?.join(" | ") }}</view>-->
         </view>
         <view class="station_item-content-left-position">
-          <uv-icon name="empty-address" size="20" color="#aaa"></uv-icon>
+          <uv-icon name="empty-address" size="18" color="#000"></uv-icon>
           <text>{{ item.address }}</text>
         </view>
       </view>
@@ -31,13 +31,13 @@
                     src="/static/nav.png"
                 />-->
 <!--        <uv-icon name="map" color="#C6171E"></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>
 
     <view class="station_item-distance">
-      <uv-text type="primary" :text="item.parkingFee" size="12"></uv-text>
+      <uv-text  color="#C6171E" :text="item.parkingFee" size="11"></uv-text>
     </view>
   </view>
 </template>

+ 73 - 53
src/pages/index/index.vue

@@ -61,11 +61,11 @@
     <!--    站点清单  end-->
 
 
-<!--    停车券-->
-    <uv-popup ref="parking_popup_ref" closeable>
+    <!--    停车券-->
+    <uv-popup ref="parking_popup_ref">
       <view class="parking_box">
-        <image  show-menu-by-longpress  src="/static/parking-qrcode.png" style="width: 420rpx;height: 420rpx;"/>
         <text>长按识别二维码获取停车优惠</text>
+        <image show-menu-by-longpress src="/static/parking-qrcode.png"/>
       </view>
     </uv-popup>
 
@@ -73,7 +73,7 @@
           <login-bar class="w100 text-center"></login-bar>
         </cover-view>-->
     <!--    <cover-view class="login_bar" v-show="!isLogin">-->
-    <login-bar class="w100 text-center" ></login-bar>
+    <!--    <login-bar class="w100 text-center" ></login-bar>-->
     <!--    </cover-view>-->
     <tab-bar :index="0"></tab-bar>
   </view>
@@ -103,10 +103,10 @@ const initState = () => ({
   bannerList: [],
   swiperList: [],
   menuList: [
-    {name: "photo", title: "洗车", icon: '/static/iconfont/default/fastwash.svg'},
-    {name: "lock", title: "充值", icon: '/static/iconfont/default/recharge.svg'},
-    {name: "star", title: "卡券", icon: '/static/iconfont/default/coupon.svg'},
-    {name: "red-packet", title: "停车", icon: '/static/iconfont/default/parking.svg'},
+    {name: "wash", auth: false, title: "洗车", icon: '/static/iconfont/default/fastwash.svg'},
+    {name: "charge", auth: true, title: "充值", icon: '/static/iconfont/default/recharge.svg'},
+    {name: "coupon", auth: false, title: "消费券", icon: '/static/iconfont/default/coupon.svg'},
+    {name: "parking", auth: false, title: "停车券", icon: '/static/iconfont/default/parking.svg'},
   ],
   qrcodeOption: {
     style: 'round',
@@ -136,7 +136,7 @@ const initState = () => ({
     position: "fixed",
 
   },
-  screenWidth:350
+  screenWidth: 350
 })
 
 const state = reactive(initState())
@@ -210,9 +210,9 @@ onShow(() => {
     loadWashStationList();
   }
 
-  if (isLogin.value) {
-    loadBannerList();
-  } else {
+  loadBannerList();
+
+  if (!isLogin.value) {
     addListener();
   }
 
@@ -227,10 +227,10 @@ onHide(() => {
 const addListener = () => {
   uni.$on('login', function (data) {
     isLogin.value = data.isLogin;
-    if (!state.bannerList || state.bannerList.length === 0) {
-      loadBannerList();
-    }
-    loadWashStationList();
+    // if (!state.bannerList || state.bannerList.length === 0) {
+    //   loadBannerList();
+    // }
+    // loadWashStationList();
 
   })
 
@@ -263,24 +263,38 @@ const handleBannerClick = (index: number) => {
 }
 
 const handleMenuClick = (menu: any) => {
-  checkLogin().then((res) => {
-    if (menu.title === '洗车') {
-      uni.navigateTo({
-        url: '/pages-wash/scan/index'
-      })
-    } else if (menu.title === '充值') {
+  let {auth,name} = menu;
+  if(auth){
+    checkLogin().then((res) => {
+      handleMenuItemNative(menu)
+    }).catch(e => {
+      console.error("handleMenuClick 校验,跳转登录页", e)
       uni.navigateTo({
-        url: '/pages-user/wallet/recharge'
+        url: '/pages-user/login/index'
       })
-    } else if (menu.title === '停车') {
-      parking_popup_ref.value?.open('center');
-    } else {
-      uni.showToast({
-        icon: 'none',
-        title: '敬请期待',
-      })
-    }
-  })
+    })
+  }else{
+    handleMenuItemNative(menu)
+  }
+}
+
+const handleMenuItemNative = (menu:any) => {
+  if (menu.name === 'wash') {
+    uni.navigateTo({
+      url: '/pages-wash/scan/index'
+    })
+  } else if (menu.name === 'charge') {
+    uni.navigateTo({
+      url: '/pages-user/wallet/recharge'
+    })
+  } else if (menu.name === 'parking') {
+    parking_popup_ref.value?.open('center');
+  } else {
+    uni.showToast({
+      icon: 'none',
+      title: '敬请期待',
+    })
+  }
 }
 
 /**
@@ -313,22 +327,20 @@ const loadCurrentLocation = () => {
 }
 
 const loadWashStationList = () => {
-  if (isLogin.value) {
-    if (state.stationList && state.stationList.length > 0) {
-      return;
-    }
-    post(`/wash-station/listStation`, {pageSize: 5}).then((res: any) => {
-      console.log(res)
-      let {list, total} = res;
-      list.forEach((station: any) => {
-        if (station.location) {
-          let stationLocation = JSON.parse(station.location);
-          station.distance = calcMapDistance(state.location.latitude, state.location.longitude, stationLocation.stationLat, stationLocation.stationLng);
-        }
-      })
-      state.stationList = list;
-    })
+  if (state.stationList && state.stationList.length > 0) {
+    return;
   }
+  post(`/wash-station/listStation`, {pageSize: 5}).then((res: any) => {
+    console.log(res)
+    let {list, total} = res;
+    list.forEach((station: any) => {
+      if (station.location) {
+        let stationLocation = JSON.parse(station.location);
+        station.distance = calcMapDistance(state.location.latitude, state.location.longitude, stationLocation.stationLat, stationLocation.stationLng);
+      }
+    })
+    state.stationList = list;
+  })
 }
 
 const handleNavMap = (station: any) => {
@@ -352,12 +364,12 @@ const handleNavStation = (station: any) => {
 
 
 const handleContact = (e: any) => {
-  console.log("handleContact", e)
+  // console.log("handleContact", e)
 }
 
 
 const onChange = (e) => {
-  console.log(e)
+  // console.log(e)
 }
 
 
@@ -476,17 +488,25 @@ movable-area {
   }
 }
 
-.parking_box{
-  width: 500rpx;
-  height: 500rpx;
+.parking_box {
+  width: 450rpx;
+  height: 450rpx;
   display: flex;
   flex-direction: column;
   justify-content: center;
   align-items: center;
   border-radius: 4px;
+  image{
+    //border: 1px solid $uni-color-primary;
+    border-radius: 3px;
+    width: 420rpx;
+    height: 420rpx;
+  }
 
-  text{
+  text {
+    padding-top: 30rpx;
     font-size: 12px;
+    color: $uni-color-primary;
   }
 }
 </style>

+ 23 - 11
src/pages/user/index.vue

@@ -21,13 +21,15 @@
 
           <view class="money" @click="toPage({path: '/pages-user/wallet/index'})">
             <view class="money-left">
-              <image src="/static/iconfont/chongzhi.svg"  mode="widthFit"  style="width: 40rpx;height: 40rpx"></image>
+              <uv-icon name="coupon"  size="24"  color="#C6171E"></uv-icon>
+<!--              <image src="/static/iconfont/chongzhi.svg"  mode="widthFit"  style="width: 40rpx;height: 40rpx"></image>-->
 <!--              <uv-icon name="red-packet" size="24" color="#C6171E"></uv-icon>-->
               <view style="font-size: 16px;margin-left: 10rpx;">钱包 | 充值</view>
             </view>
 
             <view class="money-right">
-              <view class="money-right_balance">¥ {{ ((user.balance || 0) / 100).toFixed(2) }}</view>
+
+              <view class="money-right_balance"> ¥  {{ ((user.balance || 0) / 100).toFixed(2) }}</view>
             </view>
 
           </view>
@@ -56,9 +58,9 @@
     </view>
   </block>
 
-  <cover-view class="login_bar" v-if="!isLogin">
+<!--  <cover-view class="login_bar" v-if="!isLogin">
     <login-bar class="w100 text-center"></login-bar>
-  </cover-view>
+  </cover-view>-->
 
 <!--  <view class="logout-btn">
     <uv-button :custom-style="customStyle" type="error" @click="logoutUser">退出登录</uv-button>
@@ -144,6 +146,11 @@ const toPage = (item: any) => {
     uni.navigateTo({
       url: item.path,
     });
+  }).catch(e => {
+    console.error("handleMenuClick 校验,跳转登录页", e)
+    uni.navigateTo({
+      url: '/pages-user/login/index'
+    })
   })
 
 };
@@ -285,32 +292,37 @@ page{
       //bottom: 0;
       width: 600rpx;
       //height: 98rpx;
-      background: #feffff;
+      background: rgba(221, 82, 77, 0.3);
       border-radius: 120rpx;
-      margin: 0 auto;
-      margin-top: 60rpx;
-      color: #000000;
-      padding: 40rpx;
-
+      margin: 130rpx auto 40rpx auto;
+      //color: #000000;
+      padding: 20rpx;
+      font-size: 22px;
       display: flex;
       align-content: center;
       align-items: center;
       justify-content: space-between;
 
+
       &-left {
+        opacity: 1;
         color: $uni-color-primary;
         display: inline-flex;
         align-items: flex-end;
+        font-size: 22px;
       }
 
       &-right {
+        font-size: 22px;
+        opacity: 1;
         color: $uni-color-primary;
         display: inline-flex;
         align-items: flex-end;
 
         &_balance {
+          padding-left: 5px;
+          font-size: 26px;
           font-weight: 600;
-          font-size: 20px;
           margin-right: 10px;
         }
       }

+ 8 - 6
src/utils/https.ts

@@ -113,13 +113,15 @@ const request = (options: any) => {
             // @ts-ignore
             let response = res.data;
             if (response.code !== 200) {
-                console.error("error=>", options.url, response);
                 let errMsg = response.message || '服务异常,请稍后重试';
-                uni.showToast({
-                    title: errMsg,
-                    icon: 'error',
-                    duration:5000
-                });
+                console.error("error=>", errMsg);
+                if(response.code!==301){
+                    uni.showToast({
+                        title: errMsg,
+                        icon: 'error',
+                        duration:5000
+                    });
+                }
                 if(response.code==1001){
                     //清除登录状态
                     clearToken();