Преглед изворни кода

更新 登录手机号;初始化逻辑;滑动翻页

wzh пре 3 година
родитељ
комит
83f6e9d9ab

+ 1 - 1
miniprogram/components/getPhoneButton/getPhoneButton.js

@@ -33,7 +33,7 @@ Component({
           } = result
           let res = await postApi("/user/wx/login", {
             openId: wx.getStorageSync('openId'),
-            phone: '13331872076'
+            phone
           })
           if (res.data.status == 0) {
             let data = res.data.result

+ 17 - 3
miniprogram/components/voyages/voyages.js

@@ -16,7 +16,8 @@ Component({
     size: 20,
     list: [],
     total: 0,
-    cargoOwnerId: 0
+    cargoOwnerId: 0,
+    isFreshing: false
   },
   methods: {
     async getVoyageList(isScroll) {
@@ -59,9 +60,13 @@ Component({
         return
       } else {
         this.setData({
-          cargoOwnerId
+          cargoOwnerId,
+          list: []
         })
       }
+      this.setData({
+        isFreshing: true
+      })
       let res = await postApi('/voyage/list', {
         cargoOwnerId: wx.getStorageSync('cargoOwnerId'),
         term: this.data.term,
@@ -70,7 +75,8 @@ Component({
         size: this.data.size
       })
       this.setData({
-        currentPage: this.data.currentPage
+        currentPage: this.data.currentPage,
+        isFreshing: false
       })
       if (res.data.status == 0) {
         if (isScroll) {
@@ -124,6 +130,14 @@ Component({
       if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return
       this.data.currentPage += 1
       this.getVoyageList(true)
+    },
+    scrollDownList() {
+      this.setData({
+        total: 0,
+        currentPage: 1,
+        list: []
+      })
+      this.getVoyageList()
     }
   }
 })

+ 3 - 1
miniprogram/components/voyages/voyages.wxml

@@ -3,7 +3,9 @@
   <view class="tabsview" bindtap="changeStatus" data-status="{{1}}" style="color:{{status==1?'#0d8fcc':''}};border-bottom:{{status==1?'4rpx solid #0d8fcc':''}}">运输中</view>
   <view class="tabsview" bindtap="changeStatus" data-status="{{2}}" style="color:{{status==2?'#0d8fcc':''}};border-bottom:{{status==2?'4rpx solid #0d8fcc':''}}">卸货中</view>
 </view>
-<scroll-view scroll-y="true" style="height:calc(100vh - {{height}}rpx);background: #fff;">
+<scroll-view bindrefresherrefresh="scrollDownList"
+refresher-triggered="{{isFreshing}}"
+refresher-enabled="{{true}}" scroll-y="true" style="height:calc(100vh - {{height}}rpx);background: #fff;">
   <view class="df aic jcsb list" wx:for="{{list}}" wx:key="index" data-id="{{item.id}}" bindtap="goToDetail">
     <view class="col-1">{{item.shipName}}</view>
     <view class="col-2">{{item.loadPort}}-{{item.dischargeProt}}</view>

+ 5 - 0
miniprogram/pages/index/index.js

@@ -20,6 +20,11 @@ Page({
 
   },
   onLoad() {
+    wx.removeStorageSync('voyageDetailId')
+  },
+  onShow() {
+    if (wx.getStorageSync('voyageDetailId')) return
+    wx.removeStorageSync('voyageDetailId')
     let cargoOwnerId = wx.getStorageSync('cargoOwnerId')
     if (cargoOwnerId) {
       this.getIndexInfo()

+ 5 - 1
miniprogram/pages/voyages/detail/detail.js

@@ -207,8 +207,12 @@ Page({
 
 
   onLoad(options) {
+    let {
+      id
+    } = options
+    wx.setStorageSync('voyageDetailId', id)
     this.setData({
-      id: options.id
+      id
     })
     this.getVoyageDetail()
     this.getCarLoadRecordList()

+ 6 - 1
miniprogram/pages/voyages/voyages.js

@@ -4,7 +4,12 @@ Page({
   data: {
 
   },
-  onLoad: function (options) {
+  onLoad(){
+    wx.removeStorageSync('voyageDetailId')
+  },
+  onShow: function (options) {
+    if (wx.getStorageSync('voyageDetailId')) return
+    wx.removeStorageSync('voyageDetailId')
     const child = this.selectComponent('.voyages');
     child.getVoyageList()
   },