|
|
@@ -1,66 +1,112 @@
|
|
|
-// pages/voyageManage/voyageManage.js
|
|
|
-Page({
|
|
|
+const {
|
|
|
+ postApi
|
|
|
+} = require("../../apis/api")
|
|
|
|
|
|
- /**
|
|
|
- * 页面的初始数据
|
|
|
- */
|
|
|
+Page({
|
|
|
data: {
|
|
|
-
|
|
|
+ cargoOwnerId: 0,
|
|
|
+ defaultParams: {
|
|
|
+ loginAccountId: wx.getStorageSync('loginAccountId')
|
|
|
+ },
|
|
|
+ maintab: 1,
|
|
|
+ status: 1,
|
|
|
+ currentPage: 1,
|
|
|
+ size: 20,
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
+ isFreshing: false,
|
|
|
+ currentApi: "/voyage/list"
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面加载
|
|
|
- */
|
|
|
- onLoad(options) {
|
|
|
-
|
|
|
+ selectCargoOwner(e) {
|
|
|
+ this.setData({
|
|
|
+ cargoOwnerId: e.detail.value,
|
|
|
+ list: [],
|
|
|
+ currentPage: 1,
|
|
|
+ })
|
|
|
+ this.getList()
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面初次渲染完成
|
|
|
- */
|
|
|
- onReady() {
|
|
|
-
|
|
|
+ changeMainTab(e) {
|
|
|
+ this.setData({
|
|
|
+ maintab: e.currentTarget.dataset.maintab,
|
|
|
+ currentApi: e.currentTarget.dataset.api,
|
|
|
+ status: 1,
|
|
|
+ list: [],
|
|
|
+ currentPage: 1
|
|
|
+ })
|
|
|
+ if (!this.data.cargoOwnerId) return
|
|
|
+ this.getList()
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面显示
|
|
|
- */
|
|
|
- onShow() {
|
|
|
-
|
|
|
+ async getList(isScroll) {
|
|
|
+ this.setData({
|
|
|
+ isFreshing: true
|
|
|
+ })
|
|
|
+ let res = await postApi(this.data.currentApi, {
|
|
|
+ loginAccountId: wx.getStorageSync('loginAccountId'),
|
|
|
+ status: this.data.status,
|
|
|
+ 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() {
|
|
|
-
|
|
|
+ changeStatus(e) {
|
|
|
+ let {
|
|
|
+ status
|
|
|
+ } = e.currentTarget.dataset
|
|
|
+ this.setData({
|
|
|
+ status,
|
|
|
+ currentPage: 1,
|
|
|
+ size: 20,
|
|
|
+ total: 0
|
|
|
+ })
|
|
|
+ this.getList()
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面卸载
|
|
|
- */
|
|
|
- onUnload() {
|
|
|
-
|
|
|
+ goToDetail(e) {
|
|
|
+ let {
|
|
|
+ id
|
|
|
+ } = e.currentTarget.dataset
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `/pages/voyages/detail/detail?id=${id}`,
|
|
|
+ })
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 页面相关事件处理函数--监听用户下拉动作
|
|
|
- */
|
|
|
- onPullDownRefresh() {
|
|
|
-
|
|
|
+ scrollList() {
|
|
|
+ if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return
|
|
|
+ this.data.currentPage += 1
|
|
|
+ this.getList(true)
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 页面上拉触底事件的处理函数
|
|
|
- */
|
|
|
- onReachBottom() {
|
|
|
-
|
|
|
+ scrollDownList() {
|
|
|
+ this.setData({
|
|
|
+ total: 0,
|
|
|
+ currentPage: 1,
|
|
|
+ list: []
|
|
|
+ })
|
|
|
+ this.getList()
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 用户点击右上角分享
|
|
|
- */
|
|
|
- onShareAppMessage() {
|
|
|
+ onLoad() {
|
|
|
|
|
|
}
|
|
|
})
|