ソースを参照

小程序优化修改

zuypeng 1 年間 前
コミット
81dc00fdb2

+ 21 - 6
src/pages-order/list/index.vue

@@ -1,6 +1,5 @@
 <template>
   <view class="container">
-    <scroll-view scroll-y="true" class="orders-scroll1">
       <uv-list>
         <uv-list-item
             clickable show-arrow v-for="(item,index) in state.orderList" :key="index" @click="handleClickDetail(item)">
@@ -27,14 +26,17 @@
           </template>
         </uv-list-item>
       </uv-list>
-    </scroll-view>
+
+      <uv-load-more :status="computedLoadMoreStatus"
+                    bgColor="#fff"
+                    @loadmore="loadMore" dashed :height="30"/>
     <!--    <login-bar class="w100 text-center"></login-bar>-->
     <!--    <tab-bar :index="3"/>-->
   </view>
 </template>
 
 <script lang="ts" setup>
-import {reactive} from 'vue'
+import {computed, reactive} from 'vue'
 import {onHide, onShow, onPullDownRefresh, onReachBottom,} from "@dcloudio/uni-app";
 import {get} from "@/utils/https";
 import {fmtDictName, fmtDateTime} from "@/utils/common";
@@ -64,7 +66,12 @@ onHide(() => {
   Object.assign(state, initState());
 })
 
+const computedLoadMoreStatus =computed(()=>{
+  return state.hasNext?'loadmore':'nomore'
+})
+
 onPullDownRefresh(() => {
+  console.log("onPullDownRefresh")
   setTimeout(function () {
     state.query.pageNum = 1;
     loadOrderList()
@@ -72,17 +79,25 @@ onPullDownRefresh(() => {
 })
 
 onReachBottom(() => {
+  console.log("onReachBottom")
+  loadMore()
+})
+
+const loadMore = () => {
   if (state.hasNext) {
     state.query.pageNum++
     loadOrderList()
   }
-})
+}
 
 const loadOrderList = () => {
   //load order list
   get(`/wash-order/listMyWashOrder`, state.query).then((res: any) => {
-    state.orderList = res.list;
-    state.hasNext = res.list.length == state.query.pageSize
+    if(res.list){
+      state.orderList = state.orderList.concat(res.list);
+      state.hasNext = res.pages>state.query.pageNum;
+    }
+
     uni.stopPullDownRefresh();
   }).catch(e => {
     uni.stopPullDownRefresh();

+ 2 - 4
src/pages-user/agreement/index.vue

@@ -25,10 +25,8 @@ const call = () => {
 };
 
 
-onShow((options:any) => {
-  if (options) {
-    state.servicerPhone = options.servicerPhone;
-  }
+onShow(() => {
+  state.servicerPhone =getApp<any>().globalData.config?.servicePhone;
 });
 
 onHide(() => {

+ 2 - 4
src/pages-user/faq/index.vue

@@ -48,10 +48,8 @@ const toggle = (index: number) => {
   });
 };
 
-onShow((options:any) => {
-  if (options) {
-    state.servicerPhone = options.servicerPhone;
-  }
+onShow(() => {
+  state.servicerPhone =getApp<any>().globalData.config?.servicePhone;
   body(`/faq/list`).then((res: any) => {
     state.questions = res.list;
   })

+ 2 - 4
src/pages-user/feedback/index.vue

@@ -87,12 +87,10 @@ const toggle = (index: number) => {
   });
 };
 
-onShow((options: any) => {
+onShow(() => {
   let gd = getApp<any>().globalData;
   console.log(gd)
-  if (options) {
-    state.servicerPhone = options.servicePhone;
-  }
+  state.servicerPhone =getApp<any>().globalData.config?.servicePhone;
   loadDataList()
 });
 

+ 3 - 2
src/pages-user/login/index.vue

@@ -45,7 +45,7 @@
 import { ref } from 'vue'
 import { useRouter } from 'vue-router'
 import {login} from "@/utils/auth";
-import {onShow} from "@dcloudio/uni-app";
+import {onLoad} from "@dcloudio/uni-app";
 
 const router = useRouter()
 const isAgreePrivacy = ref([])
@@ -53,7 +53,8 @@ const redirectUrl =ref ("")
 const shortId =ref ("")
 
 
-onShow((options:any)=>{
+
+onLoad((options:any)=>{
   console.log(options)
   redirectUrl.value = options?.query?.redirectUrl
   shortId.value = options?.query?.shortId

+ 2 - 4
src/pages-user/policy/index.vue

@@ -93,10 +93,8 @@ const call = () => {
 };
 
 
-onShow((options:any) => {
-  if (options) {
-    state.servicerPhone = options.servicerPhone;
-  }
+onShow(() => {
+  state.servicerPhone =getApp<any>().globalData.config?.servicePhone;
 });
 
 onHide(() => {

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

@@ -112,7 +112,7 @@ onLoad((options: any) => {
   }
 })
 
-onShow((options: any) => {
+onShow(() => {
   checkLogin().then(() => {
     loadData();
   })

+ 12 - 2
src/pages-user/wallet/recharge.vue

@@ -26,13 +26,23 @@ import {get, post,body} from "@/utils/https";
 
 const initState = () => ({
   configList: [],
-  chosenIdx: -1
+  chosenIdx: -1,
+  stationId:'000'
 })
 
 const state = reactive(initState())
 
+
+onLoad((options:any)=>{
+  console.log(options)
+  if(options.stationId){
+    state.stationId = options.stationId;
+  }
+})
+
 onShow(() => {
   loadRechargeConfig();
+
 })
 
 onHide(() => {
@@ -62,7 +72,7 @@ const confirm = () => {
   });
 
   let recharge = state.configList[state.chosenIdx]
-  get("/payment/wxPay", {rechargeConfigId:recharge.id}).then((res: any) => {
+  get("/payment/wxPay", {rechargeConfigId:recharge.id,stationId:state.stationId}).then((res: any) => {
     // #ifdef MP-WEIXIN
     wx.requestPayment({
       timeStamp: `${res.timeStamp}`,

+ 39 - 17
src/pages-wash/device/index.vue

@@ -20,7 +20,7 @@
         <text v-else>停止设备</text>
       </view>
 
-      <view class=device-body_guide>
+      <view class="device-body_guide">
         <view>●点击上方【启动设备】按钮启动设备;
         </view>
         <view>●设备启动后,请在设备功能面板按下功能按键以选择服务项目;
@@ -34,8 +34,17 @@
 
       </view>
       <!--      <view class="device-body_ops-time">{{ state.time }}</view>-->
+
+      <view class="device-body_recharge">
+        <uv-button
+            type="default"
+            color="#19A497"
+            @click="handleGotoRechage">充值
+        </uv-button>
+      </view>
     </view>
 
+
     <login-bar class="w100 text-center"></login-bar>
   </view>
 </template>
@@ -52,11 +61,12 @@ const initState = () => ({
   device: {
     functions: [],
     deviceName: '',
-    state: ''
+    state: '',
+    stationId: ''
   },
   time: "00:00:00",
   start: new Date(),
-  deviceId:null
+  deviceId: null
 })
 
 const state = reactive(initState())
@@ -77,7 +87,7 @@ onLoad((options: any) => {
     console.log(query, scanTime)
     if (query) {
       id = query.split("#")[1].split("?")[0]
-      state.deviceId =id;
+      state.deviceId = id;
     } else {
       return;
     }
@@ -87,10 +97,10 @@ onLoad((options: any) => {
     setTimeout(() => {
       loadDeviceDetail(id);
     }, 200)
-  }).catch(e=>{
+  }).catch(e => {
     console.error("onLoad 校验登录失败,自动跳转登录页")
     uni.navigateTo({
-      url:`/pages-user/login/index?shortId=${state.deviceId}&redirectUrl=/pages-wash/device/index`
+      url: `/pages-user/login/index?shortId=${state.deviceId}&redirectUrl=/pages-wash/device/index`
     })
   })
 });
@@ -101,23 +111,23 @@ onShow(() => {
   // uni.showToast({
   //   title:'onShow,'
   // })
-  checkLogin().then(()=>{
+  checkLogin().then(() => {
     // uni.showToast({
     //   title:'onShow,loaded'
     // })
     if (!state.deviceId) {
-      console.log("deviceId",getApp<any>().globalData.deviceId)
+      console.log("deviceId", getApp<any>().globalData.deviceId)
       let deviceId = getApp<any>().globalData.deviceId;
       if (deviceId) {
         loadDeviceDetail(deviceId);
       }
-    }else{
+    } else {
       loadDeviceDetail(state.deviceId);
     }
-  }).catch(e=>{
+  }).catch(e => {
     console.error("校验登录失败,自动跳转登录页")
     uni.navigateTo({
-      url:`/pages-user/login/index?shortId=${state.deviceId}&redirectUrl=/pages-wash/device/index`
+      url: `/pages-user/login/index?shortId=${state.deviceId}&redirectUrl=/pages-wash/device/index`
     })
   })
 
@@ -125,12 +135,11 @@ onShow(() => {
 })
 
 
-
 const addListener = () => {
   uni.$on('login', function (data) {
-      if(state.deviceId && data.isLogin){
-        loadDeviceDetail(state.deviceId);
-      }
+    if (state.deviceId && data.isLogin) {
+      loadDeviceDetail(state.deviceId);
+    }
   })
 
   uni.$on('logout', function (data) {
@@ -144,9 +153,9 @@ const removeListener = () => {
 
 
 const loadDeviceDetail = (id: any) => {
-  state.deviceId =id;
+  state.deviceId = id;
   let ft = fetchToken();
-  console.log("device token ",ft)
+  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({
@@ -229,6 +238,13 @@ const countTime = () => {
 }
 
 
+const handleGotoRechage = () => {
+  console.log(state.device.stationId)
+  uni.navigateTo({
+    url: `/pages-user/wallet/recharge?stationId=${state.device.stationId}`
+  })
+}
+
 </script>
 
 <style lang="scss" scoped>
@@ -272,6 +288,12 @@ const countTime = () => {
   align-items: center;
   align-content: center;
 
+  &_recharge {
+    margin-top: 30px;
+    width: 96%;
+    height: 36px;
+  }
+
   &_ops {
     display: flex;
     justify-content: center;

+ 1 - 1
src/pages-wash/station/index.vue

@@ -61,7 +61,7 @@ onHide(() => {
   }
 });*/
 
-onShow((options) => {
+onShow(() => {
   let station = getApp<any>().globalData.last.station;
   if (station) {
     state.station = station;