Files
CompanyProject/衣莎项目/源码/YiShaXiYi/view/logistics/logCentre/logCentre.js
2024-09-27 01:32:49 +08:00

183 lines
3.8 KiB
JavaScript

// view/logistics/logistics/logistics.js
const app = getApp();
const regeneratorRuntime = app.loadAsync()
const model = app.loadModel("index")
const http = app.loadHttp()
Page({
/**
* 页面的初始数据
*/
data: {
system: app.globalData.system, //设备相关信息
pageTitle: "物流中心", //头部标题
isBack: true,//显示返回
isLoading: true,//加载显示关闭
topTab: false,//物流状态
orderList: [//物流状态列表数据
{
type: 0,
img: "/static/img/wl-djd.png",
name: "待接单",
num: 0,
status: 1
}, {
type: 1,
img: "/static/img/wl-yjd.png",
name: "已接单",
num: 0,
status: 3
}, {
type: 2,
img: "/static/img/wl-sh.png",
name: "待送回",
num: 0,
status: 7
}, {
type: 2,
img: "/static/img/wl-ysd.png",
name: "已送达",
num: 0,
status: 10
}, {
type: 3,
img: "/static/img/wl-wc.png",
name: "已完成",
num: 0,
status: 8
}
],
logPerInfo: {},//物流个人信息
tabStatus: "",//物流人员当日的状态
},
// 显示和关闭
_topTab() {
this.setData({
topTab: !this.data.topTab
})
},
// 跳转到订单列表
goOrderList(e) {
let item = e.currentTarget.dataset.item
if (!!item) {
wx.navigateTo({
url: "/view/logistics/orderList/orderList?stateId=" + JSON.stringify(item)
})
} else {
wx.navigateTo({
url: "/view/logistics/orderList/orderList"
})
}
},
// 获取物流人员的信息
async logisticsOrderTong() {
let orderList = this.data.orderList
let res = await http.http.request2({ url: `${http.api.logisticsOrderTong}`, method: "POST" })
let rel = res.data.data
orderList.map((v, i) => {
switch (i) {
case 0:
orderList[i].num = rel.count.onready
break;
case 1:
orderList[i].num = rel.count.ready
break;
case 2:
orderList[i].num = rel.count.onreturn
break;
case 3:
orderList[i].num = rel.count.over
break;
case 4:
orderList[i].num = rel.count.allover
break;
default:
break;
}
})
this.setData({
logPerInfo: rel,
orderList: orderList
})
},
// 物流人员状态查询和更改
async logisticsStatus(status = "") {
let data = {}
if (status != "") {
data.status = status
}
let res = await http.http.request2({ url: `${http.api.logisticsStatus}`, method: "POST", data: data })
let upData = {
isLoading: false
}
if (!!res.data.data.status) {
upData.tabStatus = res.data.data.status
}
this.setData(upData)
},
// 切换状态
tabStatus(e) {
let type = e.currentTarget.dataset.type
this.logisticsStatus(type)
this._topTab()
this.setData({
tabStatus: type
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.logisticsStatus()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.logisticsOrderTong()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})