Parcourir la source

新增 天气查询

wzh il y a 3 ans
Parent
commit
817e749898

+ 93 - 53
miniprogram/pages/index/weather/weatherList.js

@@ -1,66 +1,106 @@
-// pages/index/weather/weatherList.js
-Page({
+const {
+  postApi
+} = require("../../../apis/api")
 
-  /**
-   * 页面的初始数据
-   */
-  data: {
+import {
+  datetimeFormat
+} from "../../../utils/utils"
 
-  },
-
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad(options) {
+const app = getApp()
 
+Page({
+  data: {
+    cargoOwnerId: 0,
+    defaultParams: {
+      loginAccountId: wx.getStorageSync('loginAccountId')
+    },
+    maintab: 1,
+    status: 0,
+    currentPage: 1,
+    size: 20,
+    list: [],
+    total: 0,
+    term: "",
+    isFreshing: false,
+    apiArr: ['/voyage/wx/list', '/dayReport/list', '/bill/list'],
+    discPortId: '',
+    discPort: ''
   },
-
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady() {
-
+  selectDiscPort(e) {
+    this.data.discPortId = e.detail.value
+    this.data.discPort = e.detail.label
+    this.getList()
   },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow() {
-
+  async getList(isScroll) {
+    if (!wx.getStorageSync('loginAccountId')) {
+      wx.showToast({
+        title: '尚未登录',
+        icon: "error"
+      })
+      return
+    }
+    this.setData({
+      isFreshing: true
+    })
+    let res = await postApi('/port/weather/list', {
+      loginAccountId: wx.getStorageSync('loginAccountId'),
+      portId: this.data.discPortId,
+      currentPage: this.data.currentPage,
+      size: this.data.size,
+    })
+    this.setData({
+      currentPage: this.data.currentPage,
+      isFreshing: false
+    })
+    if (res.data.status == 0) {
+      if (isScroll) {
+        this.setData({
+          list: [...this.data.list, ...res.data.result],
+          total: res.data.total
+        })
+      } else {
+        this.setData({
+          list: res.data.result,
+          total: res.data.total
+        })
+      }
+    } else {
+      this.setData({
+        list: [],
+        total: 0
+      })
+      wx.showToast({
+        icon: "none",
+        title: res.data.msg,
+      })
+    }
   },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide() {
-
+  goToDetail(e) {
+    return
+    let {
+      id,
+    } = e.currentTarget.dataset
+    wx.navigateTo({
+      url: `/pages/index/declarePort/detail?id=${id}`
+    })
   },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload() {
-
+  scrollList() {
+    if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return
+    this.data.currentPage += 1
+    this.getList(true)
   },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh() {
-
+  scrollDownList() {
+    this.setData({
+      total: 0,
+      currentPage: 1,
+      list: []
+    })
+    this.getList()
   },
 
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom() {
+  onLoad() {
+    this.getList()
 
   },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage() {
-
-  }
+  onShow() {}
 })

+ 3 - 1
miniprogram/pages/index/weather/weatherList.json

@@ -1,3 +1,5 @@
 {
-  "usingComponents": {}
+  "usingComponents": {
+    "RemotePicker": "/components/remotePicker/remotePicker"
+  }
 }

+ 15 - 2
miniprogram/pages/index/weather/weatherList.wxml

@@ -1,2 +1,15 @@
-<!--pages/index/weather/weatherList.wxml-->
-<text>pages/index/weather/weatherList.wxml</text>
+<view class="df aic jcsb line">
+  <view>卸货搜索</view>
+  <view>
+    <RemotePicker placeholder="选择卸货港" bind:selectItem="selectDiscPort" url="/port/getCol"></RemotePicker>
+  </view>
+</view>
+<scroll-view bindrefresherrefresh="scrollDownList" refresher-triggered="{{isFreshing}}" refresher-enabled="{{true}}" scroll-y="true" bindscrolltolower="scrollList" style="height:calc(100vh - 140rpx);padding-bottom: 100rpx;background: #fff;">
+  <view class="df aic jcsb list" wx:for="{{list}}" wx:key="index" bindtap="goToDetail" data-id="{{item.id}}">
+    <view class="col-1 ml30">{{item.portName}}</view>
+    <view class="col-2">{{item.weather}}</view>
+    <view class="col-3">{{item.temperature}} ℃</view>
+    <view class="col-4">{{item.winddirection}} 风 / {{item.windpower}} 级</view>
+  </view>
+  <view bindtap="scrollList" class="bottom-text">{{total==0?'暂无数据':(total>size*currentPage?'点击或滑动加载更多...':'已加载完毕')}}</view>
+</scroll-view>

+ 99 - 1
miniprogram/pages/index/weather/weatherList.wxss

@@ -1 +1,99 @@
-/* pages/index/weather/weatherList.wxss */
+/* pages/voyageManage/voyageManage.wxss */
+
+.line {
+  width: 80%;
+  margin: 20rpx auto;
+  font-size: 28rpx;
+  position: relative;
+}
+
+.bottom-tabs>view {
+  height: 90rpx;
+  border-top: 1rpx solid grey;
+  border-bottom: 1rpx solid grey;
+  line-height: 86rpx;
+  font-size: 27rpx;
+}
+
+.current-bottom-tab {
+  background: #0094FE;
+  color: #fff;
+  border: none;
+}
+
+.maintab1 {
+  width: 33vw;
+  border-left: none;
+}
+
+.maintab2 {
+  width: 34vw;
+  border-left: 1rpx solid grey;
+  border-right: 1rpx solid grey;
+}
+
+.maintab3 {
+  width: 33vw;
+  border-right: none;
+}
+
+/* --- */
+
+.tabs {
+  width: 100%;
+  height: 80rpx;
+  background: #fff;
+  box-shadow: rgb(209, 206, 206) 5rpx 5rpx 10rpx;
+  border-bottom: 2rpx solid grey;
+  font-size: 28rpx;
+}
+
+.tabsview {
+  height: 50rpx;
+  text-align: center;
+}
+
+.p10 {
+  padding: 10rpx 20rpx;
+}
+
+.m30a {
+  margin: 30rpx auto;
+}
+
+.list {
+  padding: 20rpx;
+  font-size: 28rpx;
+}
+
+.col-1 {
+  width: 25vw;
+}
+
+.col-2 {
+  width: 15vw;
+}
+
+
+.col-3 {
+  width: 20vw;
+}
+
+.col-4 {
+  width: 30vw;
+}
+
+.bottom-text {
+  text-align: center;
+  padding-top: 30rpx;
+  padding-bottom: 50rpx;
+  font-size: 26rpx;
+  color: #777;
+}
+
+.new-seach {
+  padding-left: 20rpx;
+  border: 1px solid grey;
+  height: 80rpx;
+  width: 50vw;
+}

+ 7 - 0
project.private.config.json

@@ -57,6 +57,13 @@
           "query": "id=244",
           "launchMode": "default",
           "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/index/weather/weatherList",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
         }
       ]
     }