Browse Source

也买你样式修改

zuypeng 1 year ago
parent
commit
10e4250d39

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

@@ -13,7 +13,7 @@
       <view class="station_item-content-left">
       <view class="station_item-content-left">
         <view class="station_item-content-left-label">
         <view class="station_item-content-left-label">
           <view class="font12 station_item-content-left-label-left">
           <view class="font12 station_item-content-left-label-left">
-            <text class="station_item-content-left-label-left_idle">空闲</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.parkingNum }}/{{ item.parkingNum }}</text>
             <text class="station_item-content-left-label-left_count">{{ item.parkingNum }}/{{ item.parkingNum }}</text>
           </view>
           </view>
           <!--              <uv-tags size="small" class="station_item-content-left-label_tag" text="洗车机" plain shape="circle"></uv-tags>-->
           <!--              <uv-tags size="small" class="station_item-content-left-label_tag" text="洗车机" plain shape="circle"></uv-tags>-->
@@ -43,6 +43,8 @@
 
 
 <script setup lang="ts" name="Station">
 <script setup lang="ts" name="Station">
 
 
+import {fmtDictName} from "@/utils/common"
+
 const props = defineProps({
 const props = defineProps({
   item: {
   item: {
     type: Object,
     type: Object,

+ 10 - 7
src/components/tab-bar/index.vue

@@ -6,7 +6,7 @@
             :class="[item.centerItem ? ' center-item' : '']"
             :class="[item.centerItem ? ' center-item' : '']"
             @click="handleTabbarClick(item)">
             @click="handleTabbarClick(item)">
         <view class="item-top"><image :src="state.currentItem == item.id ? item.selectIcon : item.icon"></image></view>
         <view class="item-top"><image :src="state.currentItem == item.id ? item.selectIcon : item.icon"></image></view>
-        <view class="item-bottom" :class="[state.currentItem == item.id ? 'item-active' : '',state.isIOS?'ios':'']">
+        <view class="item-bottom" :class="[state.currentItem == item.id ? 'item-active' : '',state.isIOS?'ios11':'']">
           <text>{{ item.text }}</text>
           <text>{{ item.text }}</text>
         </view>
         </view>
       </view>
       </view>
@@ -102,8 +102,8 @@ view {
   bottom: 0;
   bottom: 0;
   left: 0;
   left: 0;
   width: 100%;
   width: 100%;
-  height: 110rpx;
-  box-shadow: 0 0 3px #999;
+  height: 140rpx;
+  //box-shadow: 0 0 3px #999;
   display: flex;
   display: flex;
   align-items: center;
   align-items: center;
   padding: 25rpx 0;
   padding: 25rpx 0;
@@ -132,15 +132,18 @@ view {
 }
 }
 .tabbar-container .center-item .item-top {
 .tabbar-container .center-item .item-top {
   flex-shrink: 0;
   flex-shrink: 0;
-  width: 100rpx;
-  height: 100rpx;
+  width: 120rpx;
+  height: 120rpx;
   position: absolute;
   position: absolute;
   top: -60rpx;
   top: -60rpx;
-  left: calc(50% - 50rpx);
+  left: calc(50% - 65rpx);
   border-radius: 50%;
   border-radius: 50%;
-  box-shadow: 0 -1px 0 0 #999;
   background-color: #ffffff;
   background-color: #ffffff;
 }
 }
+.tabbar-container .center-item .item-top image{
+  width: 120% !important;
+  height: 120% !important;
+}
 .tabbar-container .tabbar-item .item-top image {
 .tabbar-container .tabbar-item .item-top image {
   width: 100%;
   width: 100%;
   height: 100%;
   height: 100%;

+ 2 - 2
src/pages-user/profile/index.vue

@@ -6,9 +6,9 @@
                   @click="handleChoosePlate"></uv-list-item>
                   @click="handleChoosePlate"></uv-list-item>
   </uv-list>
   </uv-list>
 
 
-  <view class="logout-btn">
+<!--  <view class="logout-btn">
     <uv-button :custom-style="customStyle" type="error" @click="logoutUser">退出登录</uv-button>
     <uv-button :custom-style="customStyle" type="error" @click="logoutUser">退出登录</uv-button>
-  </view>
+  </view>-->
 </template>
 </template>
 
 
 <script setup lang="ts">
 <script setup lang="ts">

+ 0 - 1
src/pages-user/wallet/index.vue

@@ -54,7 +54,6 @@
 
 
     <view class="wallet-bottom">
     <view class="wallet-bottom">
       <uv-button
       <uv-button
-          shape="circle"
           type="primary"
           type="primary"
           color="#19A497"
           color="#19A497"
           @click="to(`/pages-user/wallet/recharge`)">充值
           @click="to(`/pages-user/wallet/recharge`)">充值

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

@@ -17,7 +17,7 @@
         <text v-if="state.device.state==='idle'">启动</text>
         <text v-if="state.device.state==='idle'">启动</text>
         <text v-else>停止</text>
         <text v-else>停止</text>
       </view>
       </view>
-      <view class="device-body_ops-time">{{ state.time }}</view>
+<!--      <view class="device-body_ops-time">{{ state.time }}</view>-->
     </view>
     </view>
   </view>
   </view>
 </template>
 </template>
@@ -68,7 +68,7 @@ const loadDeviceDetail = (id: number) => {
   }).catch(e => {
   }).catch(e => {
     console.error(e)
     console.error(e)
   })
   })
-  countTime();
+  // countTime();
 }
 }
 
 
 const handleNavigateBack = () => {
 const handleNavigateBack = () => {
@@ -86,7 +86,10 @@ const handleClickDevice = () => {
         mask: true,
         mask: true,
       });
       });
       post(`/wash-device/startDevice/${state.device.shortId}`).then((res:any)=>{
       post(`/wash-device/startDevice/${state.device.shortId}`).then((res:any)=>{
-        uni.hideLoading()
+        uni.hideLoading();
+        uni.showToast({
+          title:'启动成功,请到洗车机面板选择服务项目'
+        })
       })
       })
     }else{
     }else{
       uni.showLoading({
       uni.showLoading({

+ 18 - 3
src/pages/index/index.vue

@@ -79,7 +79,7 @@ import LoginBar from "@/components/login-bar/index.vue";
 import WashStation from "@/components/station/index.vue"
 import WashStation from "@/components/station/index.vue"
 import {get, post} from "@/utils/https";
 import {get, post} from "@/utils/https";
 import {calcMapDistance} from "@/utils/common"
 import {calcMapDistance} from "@/utils/common"
-import {checkLogin} from "@/utils/auth";
+import {checkLogin, fetchToken, loadUserInfo, tryLogin} from "@/utils/auth";
 
 
 const title = ref('Hello')
 const title = ref('Hello')
 const isLogin = ref(false)
 const isLogin = ref(false)
@@ -139,10 +139,25 @@ onLoad((e: any) => {
 })
 })
 
 
 onShow(() => {
 onShow(() => {
-  const userData = getApp<any>().globalData.user;
-  if (userData && userData.id) {
+  let token = fetchToken();
+  if(token){
+    getApp<any>().globalData.token = token;
+    getApp<any>().globalData.isLogin = true;
     isLogin.value = true;
     isLogin.value = true;
+    loadUserInfo();
+  }else{
+    tryLogin().then(token=>{
+      getApp<any>().globalData.token = token;
+      getApp<any>().globalData.isLogin = true;
+      isLogin.value = true;
+    }).catch(e=>{
+      console.error(e)
+    })
   }
   }
+ /* const userData = getApp<any>().globalData.user;
+  if (userData && userData.id) {
+    isLogin.value = true;
+  }*/
 
 
   console.log("show index>>>>", isLogin.value, state.stationList, state.location)
   console.log("show index>>>>", isLogin.value, state.stationList, state.location)
   let locationData = getApp<any>().globalData.location;
   let locationData = getApp<any>().globalData.location;

+ 92 - 9
src/pages/user/index.vue

@@ -20,8 +20,16 @@
           <view class="phone fs-40 fw-500">{{ user.mobilePhone }}</view>
           <view class="phone fs-40 fw-500">{{ user.mobilePhone }}</view>
 
 
           <view class="money" @click="toPage({path: '/pages-user/wallet/index'})">
           <view class="money" @click="toPage({path: '/pages-user/wallet/index'})">
-            <uv-icon name="red-packet" size="24"></uv-icon>
-            <view>¥{{ ((user.balance||0)/100).toFixed(2) }}</view>
+            <view class="money-left">
+              <uv-icon name="red-packet" size="24" color="#19A497"></uv-icon>
+              <view style="font-size: 13px;">钱包|充值</view>
+            </view>
+
+            <view class="money-right">
+              <view>¥</view>
+              <view class="money-right_balance">{{ ((user.balance || 0) / 100).toFixed(2) }}</view>
+            </view>
+
           </view>
           </view>
         </view>
         </view>
       </view>
       </view>
@@ -40,6 +48,10 @@
             </view>
             </view>
           </view>
           </view>
         </block>
         </block>
+
+        <view class="logout-btn" v-if="isLogin">
+          <view class="mt20 logout-btn-wrap"  type="error" @click="logoutUser">退出登录</view>
+        </view>
       </view>
       </view>
     </view>
     </view>
   </block>
   </block>
@@ -48,15 +60,20 @@
     <login-bar class="w100 text-center"></login-bar>
     <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>
+  </view>-->
+
   <tab-bar :index="2"/>
   <tab-bar :index="2"/>
 </template>
 </template>
 
 
 <script setup lang="ts">
 <script setup lang="ts">
 import {onLoad, onShow} from "@dcloudio/uni-app";
 import {onLoad, onShow} from "@dcloudio/uni-app";
-import {ref} from "vue";
+import {computed, ref} from "vue";
 import TabBar from "@/components/tab-bar/index.vue";
 import TabBar from "@/components/tab-bar/index.vue";
 import LoginBar from "@/components/login-bar/index.vue";
 import LoginBar from "@/components/login-bar/index.vue";
-import {checkLogin} from "@/utils/auth"
+import {checkLogin, clearToken} from "@/utils/auth"
+import {get} from "@/utils/https";
 
 
 const containerStyle = ref({});
 const containerStyle = ref({});
 const user = ref<any>({
 const user = ref<any>({
@@ -107,8 +124,9 @@ const menu = ref([
 ]);
 ]);
 
 
 
 
-const toPage =  (item: any) => {
-  checkLogin().then(()=>{
+
+const toPage = (item: any) => {
+  checkLogin().then(() => {
     let {title, path} = item;
     let {title, path} = item;
     if (path.includes('contact')) {
     if (path.includes('contact')) {
       uni.makePhoneCall({
       uni.makePhoneCall({
@@ -133,14 +151,45 @@ const toPage =  (item: any) => {
 const loginListen = () => {
 const loginListen = () => {
   uni.$on('loginEvent', function (data) {
   uni.$on('loginEvent', function (data) {
     isLogin.value = data.isLogin;
     isLogin.value = data.isLogin;
-    console.log("event>>>",data)
+    console.log("event>>>", data)
     if (data.isLogin) {
     if (data.isLogin) {
       user.value = getApp<any>().globalData.user;
       user.value = getApp<any>().globalData.user;
-      console.log("event1111>>>", user.value )
+      console.log("event1111>>>", user.value)
     }
     }
   })
   })
 }
 }
 
 
+const logoutUser = () => {
+  uni.showModal({
+    title: "温馨提示",
+    content: "确定退出登录吗?",
+    confirmColor: "#2d9e95",
+    confirmText: "确定退出",
+    cancelText: "手滑了",
+    success: (res) => {
+      if (res.confirm) {
+        uni.showLoading({
+          title: "退出中",
+        });
+
+        get(`/user/logout`).then(() => {
+          uni.hideLoading();
+          uni.showToast({
+            icon: "success",
+            title: "已退出",
+          });
+
+          clearToken();
+          setTimeout(() => {
+            uni.exitMiniProgram()
+          }, 1500);
+
+        })
+      }
+    },
+  });
+};
+
 onLoad(() => {
 onLoad(() => {
   uni.setNavigationBarTitle({title: '个人中心'})
   uni.setNavigationBarTitle({title: '个人中心'})
   const bound = uni.getMenuButtonBoundingClientRect();
   const bound = uni.getMenuButtonBoundingClientRect();
@@ -152,7 +201,7 @@ onLoad(() => {
 
 
 onShow(() => {
 onShow(() => {
   const userData = getApp<any>().globalData.user;
   const userData = getApp<any>().globalData.user;
-  if (userData&&userData.id) {
+  if (userData && userData.id) {
     isLogin.value = true;
     isLogin.value = true;
     user.value = userData;
     user.value = userData;
   }
   }
@@ -226,6 +275,22 @@ onShow(() => {
       align-items: center;
       align-items: center;
       justify-content: space-between;
       justify-content: space-between;
 
 
+      &-left {
+        color: $uni-color-primary;
+        display: inline-flex;
+        align-items: flex-end;
+      }
+
+      &-right {
+        color: $uni-color-primary;
+        display: inline-flex;
+        align-items: flex-end;
+
+        &_balance {
+          font-weight: 600;
+          font-size: 20px;
+        }
+      }
     }
     }
   }
   }
 }
 }
@@ -273,5 +338,23 @@ onShow(() => {
   }
   }
 }
 }
 
 
+.logout-btn {
+  width: calc(100vw - 60rpx);
+  margin: 60rpx auto;
 
 
+  &-wrap{
+    height: 60rpx;
+    font-size: 24rpx;
+    margin: 20px auto;
+    width: 540rpx;
+    text-align: center;
+    background: #dd524d;
+    color: white;
+    border-radius: 10rpx;
+    display: flex;
+    align-items: center;
+    align-content: center;
+    justify-content: center;
+  }
+}
 </style>
 </style>

+ 35 - 3
src/utils/auth.ts

@@ -98,6 +98,39 @@ export function login(e: any): Promise<string> {
     });
     });
 }
 }
 
 
+export  function tryLogin(){
+    return new Promise(((resolve, reject) => {
+        uni.login({
+            success: (res) => {
+                let data = {
+                    phoneCode: "",
+                    code: res.code,
+                    avatar: "",
+                    nickname: "",
+                }
+                body(`/user/wxLogin`, data).then((res: any) => {
+                    const {satoken, userId} = res;
+                    if (satoken) {
+                        setToken(satoken);
+                        loadUserInfo();
+                        resolve(satoken)
+                    } else {
+                        console.error("tryLogin")
+                        // _resolveTokenQueue({
+                        //     errMsg:  `${JSON.stringify(res)}`,
+                        // });
+                    }
+                }).catch(e => {
+                    reject(e)
+                })
+            },
+            fail: function (){
+                reject('fail')
+            },
+        });
+    }))
+}
+
 
 
 export function checkLogin() {
 export function checkLogin() {
     return new Promise((resolve, reject) => {
     return new Promise((resolve, reject) => {
@@ -114,7 +147,7 @@ export function checkLogin() {
     })
     })
 }
 }
 
 
-function loadUserInfo() {
+export function loadUserInfo() {
     get(`/user/me`).then((res: any) => {
     get(`/user/me`).then((res: any) => {
         getApp<any>().globalData.user = res;
         getApp<any>().globalData.user = res;
         uni.$emit('loginEvent', {isLogin: true})
         uni.$emit('loginEvent', {isLogin: true})
@@ -169,8 +202,7 @@ export function onLogin(cb: (token: string) => void) {
 }
 }
 
 
 export function fetchToken() {
 export function fetchToken() {
-    let token = uni.getStorageSync("token")
-    return token;
+    return uni.getStorageSync("token");
 }
 }
 
 
 export function setToken(token: string) {
 export function setToken(token: string) {

+ 0 - 1
src/utils/common.ts

@@ -72,7 +72,6 @@ export function fmtDictName(code: string, value: string) {
     }
     }
 
 
     let elements = dictStorage[code];
     let elements = dictStorage[code];
-    console.log(elements)
     if (elements) {
     if (elements) {
         let ele = elements.find((k: any) => k.value == value);
         let ele = elements.find((k: any) => k.value == value);
         if (ele) {
         if (ele) {