[最新更新]

This commit is contained in:
2024-03-04 15:13:17 +08:00
parent 51a04d53ce
commit ee98f5921d
42 changed files with 1853 additions and 74 deletions

View File

@@ -0,0 +1,178 @@
/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
Page({
/**
* 页面的初始数据
*/
data: {
statusArr : [{ title: '全部订单', id: '' }],
empowerArr : [{ title: '全部课程', id: '' }],
statusIndex : 0,
empowerIndex: 0,
// 报名信息
users : [],
usersTotal : 0,
usersShow : false,
// 订单列表
orders : [],
// 分页
page : {}, // 分页信息
lodingStats : false,// 加载状态
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
wx.$api.empower.orderInit().then(res => {
let { status, empower } = res.data;
this.setData({
statusArr : status,
empowerArr : [...this.data.empowerArr, ...empower]
})
// 获取列表
this.getList()
}).catch(err => {})
},
// 筛选类型
onPickerChange(e){
this.setData({
statusIndex: e.detail.value
})
this.getList()
},
// 筛选类型-课程
onPickerClass(e){
this.setData({
empowerIndex: e.detail.value
})
this.getList()
},
/**
* 获取列表
*/
getList(page) {
wx.$api.empower.orderList({
page : page || 1,
status : this.data.statusArr[this.data.statusIndex].id,
empower : this.data.empowerArr[this.data.empowerIndex].id
}).then(res => {
let listArr = this.data.orders,
newData = []
if(page == 1 || page == undefined) listArr = []
newData = listArr.concat(res.data.data)
newData.map(val => {
val.is_show_type = false
})
this.setData({
orders : newData,
page : res.data.page,
lodingStats : false
})
wx.stopPullDownRefresh()
}).catch(err => {})
},
/**
* 课程数量
*/
typeTap(e) {
let index = e.currentTarget.dataset.index
this.setData({
[`orders[${index}].is_show_type`]: !this.data.orders[index].is_show_type
});
},
/**
* 报名信息
*/
onShowUsers(val) {
let { count, lists } = val.currentTarget.dataset.items
this.setData({
users : lists,
usersTotal : count,
usersShow : true
})
},
/**
* 报名信息弹出关闭
*/
usersHide() {
this.setData({
usersShow: false
})
},
/**
* 取消订单
*/
onCancel(e){
let id = e.currentTarget.dataset.id
wx.showModal({
title : '提示',
content : '取消订单后无法找回,确认取消吗?',
success : modalRes => {
if(modalRes.confirm){
wx.showLoading({
title: '加载中...',
mask : true
})
wx.$api.empower.orderCancel(id).then(res => {
wx.showToast({
title: '订单已取消',
icon : 'none'
})
this.getList()
}).catch(err => {})
}
}
})
},
/**
* 支付
*/
onPay(e){
let data = e.currentTarget.dataset.item
wx.redirectTo({
url: '/pages/pay/index?params=' + encodeURIComponent(JSON.stringify(data))
})
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
// 获取订单列表
this.getList()
},
/**
* 上拉加载
*/
onReachBottom(){
this.setData({
lodingStats: true
})
let pageNumber = this.data.page.current
if(this.data.page.has_more){
pageNumber++
// 获取订单列表
this.getList(pageNumber)
}
},
})