Files
szjs/pages/order/order.js

225 lines
5.3 KiB
JavaScript
Raw Normal View History

2025-03-07 22:27:18 +08:00
//获取应用实例
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
order_list: [],
height: '',
url: app.globalData.url,
pageNum: 1,
id:''//记录id
},
onClickLeft() {
wx.navigateBack()
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var statusBarHeight = wx.getSystemInfoSync().statusBarHeight;
this.setData({
statusBarHeight: statusBarHeight,
height: 46 + statusBarHeight,
});
},
//跳转订单详情(去付款)
// 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,
// });
// }
// },
//是否登录
delete(e) {
var that = this;
wx.showModal({
title: '提示',
content: '是否删除',
success(res) {
if (res.confirm) {
2026-01-06 15:59:20 +08:00
// 用户点击确定
2025-03-07 22:27:18 +08:00
that.go_delete(e)
} else if (res.cancel) {
2026-01-06 15:59:20 +08:00
// 用户点击取消
2025-03-07 22:27:18 +08:00
}
}
})
},
//删除点击
go_delete(e) {
2026-01-06 15:59:20 +08:00
// 列表条目的index
2025-03-07 22:27:18 +08:00
//去订单详情页
// 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,
// });
// }
2026-01-06 15:59:20 +08:00
// 列表条目的item
2025-03-07 22:27:18 +08:00
this.deleteRecord(e.currentTarget.dataset.item.id)
},
deleteRecord(itemid) {
this.setData({
id: itemid
});
var that = this;
wx.request({
url: app.globalData.url + 'app/Ruilaiwechat/deleteRecord',
data: {
uid: wx.getStorageSync('uid'), //人员id
id: this.data.id, //记录id
},
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
success(res) {
if (res.data.erro == 0) {
that.getOrderList()
} else {
wx.showToast({
title: res.data.msg,
icon: 'error',
duration: 2000
})
}
}
})
},
onClickLeft() {
wx.navigateBack()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
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 + 'app/Ruilaiwechat/selectRecordList',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
method: 'POST',
data: {
page: this.data.pageNum,
uid: wx.getStorageSync('uid') //人员id
},
success: (res) => {
var resp = res.data;
if (res.data.erro == 0) {
that.setData({
pageNum: 1,
order_list: resp.lists,
});
wx.stopPullDownRefresh({
success: (res) => {},
})
}
}
});
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
2026-01-06 15:59:20 +08:00
// 页面上拉触底事件的处理函数
2025-03-07 22:27:18 +08:00
this.getOrderList();
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
getOrderList: function () {
var that = this;
wx.request({
url: app.globalData.url + 'app/Ruilaiwechat/selectRecordList',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
method: 'POST',
data: {
page: this.data.pageNum,
uid: wx.getStorageSync('uid') //人员id
},
success: (res) => {
var resp = res.data;
if (res.data.erro == 0) {
if (res.data.currentPage == 1) {
2026-01-06 15:59:20 +08:00
// 当前页码
2025-03-07 22:27:18 +08:00
// 检查列表数量是否等于30
if (this.data.order_list.length === 30){
2026-01-06 15:59:20 +08:00
// 列表数量等于30
2025-03-07 22:27:18 +08:00
that.setData({
order_list: resp.lists,
pageNum: res.data.currentPage + 1
});
}else{
that.setData({
order_list: resp.lists,
});
}
2026-01-06 15:59:20 +08:00
// 页码更新
2025-03-07 22:27:18 +08:00
} else {
2026-01-06 15:59:20 +08:00
// 加载更多数据
2025-03-07 22:27:18 +08:00
that.setData({
order_list: this.data.order_list.concat(resp.lists),
pageNum: res.data.currentPage + 1
});
}
}
}
});
},
})
//遗留问题1:列表分页加载的上拉加载有问题当第一页的数据少于30条的时候会出现空白页解决办法前台参数传page2的时候后台返回的参数页能返回currentPage为2