Files
coupon/pages/order/order.js
2023-05-23 00:58:40 +08:00

179 lines
4.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//获取应用实例
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
order_list: [],
nav_type: 1,
all: true,
height: '',
url: app.globalData.url,
statusType: ["全部", "待付款", "待服务", "服务中", "已完成","已取消"],
status: ["", "1", "2", "3","8","-2"],
currentType: 0,
tabClass: ["", "", "", "", "", ""],
pageNum: 1
},
statusTap: function (e) {
var curType = e.currentTarget.dataset.index;
this.setData({
currentType: curType,
pageNum: 1
});
this.getOrderList();
},
onClickLeft() {
wx.navigateBack()
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var statusBarHeight = wx.getSystemInfoSync().statusBarHeight;
this.setData({
statusBarHeight: statusBarHeight,
height: 46 + statusBarHeight,
});
},
//条目点击---订单状态:-2已取消 -1拒绝接单 0待接单 1已接单 2已支付待服务3服务中 4已完成 5申请退款 6退款中 7已退款 8已结算
itemclick(e) {
console.log("列表条目的index==" + e.currentTarget.dataset.index)
//去订单详情页
if (e.currentTarget.dataset.item != 0) {
let item = JSON.stringify(e.currentTarget.dataset.item);
//console.log("传递的item" + item);
wx.navigateTo({
url: "/pages/orderdetail/orderdetail?item=" + item,
});
}
},
//跳转订单详情(去付款)
go_pay(e) {
console.log(e.currentTarget.dataset.id)
// wx.navigateTo({
// url: '/pages/orderdetail/orderdetail?' + "type=" + '2' + '&id=' + e.currentTarget.dataset.id,
// })
if (e.currentTarget.dataset.item != 0) {
let item = JSON.stringify(e.currentTarget.dataset.item);
console.log("传递的item" + item);
wx.navigateTo({
url: "/pages/orderdetail/orderdetail?item=" + item,
});
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.setData({
order_list: [],
pageNum: 1
})
this.getOrderList();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
//this.getOrderList();
var that = this;
wx.request({
url: app.globalData.url + '/system/view/list',
header: app.getRequestHeader(),
method: 'GET',
data: {
pageNum: 1,
pageSize: 30,
status: that.data.status[that.data.currentType],
usercId: wx.getStorageSync('uid')
},
success: (res) => {
var resp = res.data;
if (res.data.code == 200) {
that.setData({
pageNum: 1,
order_list: resp.data,
});
wx.stopPullDownRefresh({
success: (res) => {},
})
}
}
});
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
console.log("==页面上拉触底事件的处理函数==")
// this.getOrderList();
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
//订单状态:-2已取消 -1拒绝接单 0待付款 1已付款 2已接单待服务3服务中 4已完成 5申请退款 6退款中 7已退款 8已结算
getOrderList: function () {
var that = this;
wx.request({
url: app.globalData.url + '/system/view/list',
header: app.getRequestHeader(),
method: 'GET',
data: {
pageNum: this.data.pageNum,
pageSize: 30,
status: that.data.status[that.data.currentType],
usercId: wx.getStorageSync('uid')
},
success: (res) => {
var resp = res.data;
if (res.data.code == 200) {
if (this.data.pageNum == 1) {
that.setData({
order_list: resp.data,
pageNum: this.data.pageNum + 1
});
} else {
that.setData({
order_list: this.data.order_list.concat(resp.data),
pageNum: this.data.pageNum + 1
});
}
}
}
});
},
})