Files
szjs/pages/order/order.js
renjianbo 5d4928cc30 优化
2026-01-06 15:59:20 +08:00

225 lines
5.3 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: [],
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) {
// 用户点击确定
that.go_delete(e)
} else if (res.cancel) {
// 用户点击取消
}
}
})
},
//删除点击
go_delete(e) {
// 列表条目的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,
// });
// }
// 列表条目的item
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 () {
// 页面上拉触底事件的处理函数
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) {
// 当前页码
// 检查列表数量是否等于30
if (this.data.order_list.length === 30){
// 列表数量等于30
that.setData({
order_list: resp.lists,
pageNum: res.data.currentPage + 1
});
}else{
that.setData({
order_list: resp.lists,
});
}
// 页码更新
} else {
// 加载更多数据
that.setData({
order_list: this.data.order_list.concat(resp.lists),
pageNum: res.data.currentPage + 1
});
}
}
}
});
},
})
//遗留问题1:列表分页加载的上拉加载有问题当第一页的数据少于30条的时候会出现空白页解决办法前台参数传page2的时候后台返回的参数页能返回currentPage为2