Files
coupon/pages/order/order.js
2023-04-25 23:33:40 +08:00

235 lines
5.8 KiB
JavaScript
Raw 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"],
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)
console.log("status==" + e.currentTarget.dataset.status)
//去订单详情页
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,
});
}
if (this.data.order_list[e.currentTarget.dataset.index].status == '已取消订单') {
wx.navigateTo({
url: '/pages/orderdetail/orderdetail?' + "type=" + '1' + '&id=' + this.data.order_list[e.currentTarget.dataset.index].order_id,
})
}
if (this.data.order_list[e.currentTarget.dataset.index].status == '待退款') {
wx.navigateTo({
url: '/pages/reforderdetail/reforderdetail?' + "type=" + '4' + '&id=' + e.currentTarget.dataset.id,
})
}
if (this.data.order_list[e.currentTarget.dataset.index].status == '退款驳回') {
wx.navigateTo({
url: '/pages/reforderdetail/reforderdetail?' + "type=" + '1' + '&id=' + e.currentTarget.dataset.id,
})
}
if (this.data.order_list[e.currentTarget.dataset.index].status == '已退款') {
wx.navigateTo({
url: '/pages/reforderdetail/reforderdetail?' + "type=" + '2' + '&id=' + e.currentTarget.dataset.id,
})
}
// wx.navigateTo({
// url: '/pages/orderdetail/orderdetail?'+"type="+'1'+ '&id=' +e.currentTarget.dataset.id,
// })
},
//跳转订单详情(去付款)
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,
});
}
},
// 导航栏
all_order() {
this.setData({
nav_type: 1,
all: true
})
},
payment_order() {
this.setData({
nav_type: 2,
all: false
})
},
use_order() {
this.setData({
nav_type: 3,
all: false
})
},
refund_order() {
this.setData({
nav_type: 4,
all: false
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
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: 1,
pageSize: 30,
status: that.data.status[that.data.currentType],
usercId: wx.getStorageSync('uid')
},
success: (res) => {
var resp = res.data;
console.log(resp + "===========订单")
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
});
}
}
}
});
},
})