2024-12-01 11:56:54 +00:00
|
|
|
import { url } from '../request';
|
2024-11-10 07:01:22 +00:00
|
|
|
Page({
|
2024-12-01 11:56:54 +00:00
|
|
|
data: {
|
|
|
|
current: 0,
|
2024-12-03 11:59:36 +00:00
|
|
|
businessName:'',
|
2024-12-01 11:56:54 +00:00
|
|
|
items: [
|
|
|
|
{
|
|
|
|
title: '全部',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '待支付',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '待使用',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '已完成',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '已取消',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '退款',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
dingdan:[],
|
2024-12-10 10:35:22 +00:00
|
|
|
paymentStatuses: [
|
|
|
|
{ paymentStatuses: '0', statue: '待支付' },
|
|
|
|
{ paymentStatuses: '1', statue: '待使用' },
|
|
|
|
{ paymentStatuses: '2', statue: '已取消' },
|
|
|
|
{ paymentStatuses: '3', statue: '已退款' },
|
|
|
|
{ paymentStatuses: '4', statue: '已完成' }
|
|
|
|
]
|
|
|
|
|
2024-12-01 11:56:54 +00:00
|
|
|
},
|
|
|
|
onShow(){
|
|
|
|
my.getStorage({
|
|
|
|
key: 'userInfo',
|
|
|
|
success: (res) => {
|
|
|
|
const userInfo = res.data;
|
|
|
|
this.setData({
|
|
|
|
id: userInfo.id, // 获取 id
|
|
|
|
});
|
|
|
|
|
|
|
|
if (userInfo && userInfo.cookie) {
|
|
|
|
my.request({
|
|
|
|
url: url + '/api/orders/my/page',
|
|
|
|
method: 'POST',
|
|
|
|
data: {
|
|
|
|
claimStatus: 0,
|
2024-12-03 11:59:36 +00:00
|
|
|
current: 1,
|
2024-12-01 11:56:54 +00:00
|
|
|
endTime: "",
|
2024-12-03 11:59:36 +00:00
|
|
|
id: "",
|
|
|
|
pageSize: 10,
|
2024-12-10 10:35:22 +00:00
|
|
|
paymentStatus: "",
|
2024-12-01 11:56:54 +00:00
|
|
|
sortField: "",
|
|
|
|
sortOrder: "",
|
2025-01-13 13:07:00 +00:00
|
|
|
startTime: "",
|
|
|
|
userId: userInfo.id,
|
|
|
|
userRole: 0,
|
2024-12-01 11:56:54 +00:00
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Cookie': userInfo.cookie,
|
|
|
|
},
|
|
|
|
dataType: 'json',
|
|
|
|
success: (res) => {
|
2024-12-17 11:46:10 +00:00
|
|
|
if(res.data.code===0){
|
2024-12-01 11:56:54 +00:00
|
|
|
this.setData({
|
2024-12-03 11:59:36 +00:00
|
|
|
dingdan:res.data.data.records,
|
|
|
|
|
2024-12-01 11:56:54 +00:00
|
|
|
})
|
|
|
|
}
|
2024-12-17 11:46:10 +00:00
|
|
|
else if(res.data.code===40100){
|
|
|
|
my.alert({
|
|
|
|
content: '登录信息已过期,请重新登录'
|
|
|
|
});
|
|
|
|
my.navigateTo({
|
|
|
|
url:'/pages/denglu/denglu'
|
|
|
|
})
|
|
|
|
}
|
2024-12-03 11:59:36 +00:00
|
|
|
console.log(res);
|
|
|
|
console.log(this.data.dingdan);
|
2024-12-01 11:56:54 +00:00
|
|
|
},
|
|
|
|
fail: (error) => {
|
|
|
|
console.error('请求失败: ', JSON.stringify(error));
|
|
|
|
my.alert({ content: '请求失败,请稍后重试' });
|
|
|
|
},
|
|
|
|
});
|
2024-12-17 11:46:10 +00:00
|
|
|
}
|
|
|
|
else {
|
2024-12-01 11:56:54 +00:00
|
|
|
my.alert({
|
|
|
|
content: '您未登录,请先登录。',
|
|
|
|
success: () => {
|
|
|
|
my.navigateTo({
|
|
|
|
url: '/pages/denglu/denglu',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onSwipeChange(e) {
|
|
|
|
this.setData({
|
|
|
|
current: e.detail.current,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onChange(current) {
|
|
|
|
this.setData({
|
|
|
|
current,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handleChange(current) {
|
|
|
|
this.setData({
|
|
|
|
current,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onPlus() {
|
|
|
|
this.alert('plus');
|
|
|
|
},
|
|
|
|
alert(content) {
|
|
|
|
my.alert({
|
|
|
|
title: content,
|
|
|
|
});
|
|
|
|
},
|
2024-12-10 10:35:22 +00:00
|
|
|
getPaymentStatusText(status) {
|
|
|
|
const statusObj = this.paymentStatuses.find(item => item.paymentStatuses === status.toString());
|
|
|
|
return statusObj ? statusObj.statue : '未知状态'; // 如果找不到对应状态,返回 '未知状态'
|
|
|
|
},
|
2025-01-13 13:07:00 +00:00
|
|
|
quxiao(e){
|
|
|
|
const orderId = e.currentTarget.dataset.id;
|
|
|
|
console.log(orderId,'zheshiorderid');
|
|
|
|
my.getStorage({
|
|
|
|
key: 'userInfo',
|
|
|
|
success: (res) => {
|
|
|
|
const userInfo = res.data;
|
|
|
|
this.setData({
|
|
|
|
id: userInfo.id, // 获取 id
|
|
|
|
});
|
|
|
|
|
|
|
|
if (userInfo && userInfo.cookie) {
|
|
|
|
my.request({
|
|
|
|
url: url + '/api/orders/cancel',
|
|
|
|
method: 'POST',
|
|
|
|
data: {
|
|
|
|
"id": 0
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Cookie': userInfo.cookie,
|
|
|
|
},
|
|
|
|
dataType: 'json',
|
|
|
|
success: (res) => {
|
|
|
|
if(res.data.code===0){
|
|
|
|
my.showToast({
|
|
|
|
content: '订单已取消',
|
|
|
|
});
|
|
|
|
this.fetchOrders()
|
|
|
|
}
|
|
|
|
else if(res.data.code===40100){
|
|
|
|
my.alert({
|
|
|
|
content: '登录信息已过期,请重新登录'
|
|
|
|
});
|
|
|
|
my.navigateTo({
|
|
|
|
url:'/pages/denglu/denglu'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
console.log(res);
|
|
|
|
console.log(this.data.dingdan);
|
|
|
|
},
|
|
|
|
fail: (error) => {
|
|
|
|
console.error('请求失败: ', JSON.stringify(error));
|
|
|
|
my.alert({ content: '请求失败,请稍后重试' });
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
my.alert({
|
|
|
|
content: '您未登录,请先登录。',
|
|
|
|
success: () => {
|
|
|
|
my.navigateTo({
|
|
|
|
url: '/pages/denglu/denglu',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
fetchOrders() {
|
|
|
|
my.getStorage({
|
|
|
|
key: 'userInfo',
|
|
|
|
success: (res) => {
|
|
|
|
const userInfo = res.data;
|
|
|
|
if (userInfo && userInfo.cookie) {
|
|
|
|
my.request({
|
|
|
|
url: url + '/api/orders/my/page',
|
|
|
|
method: 'POST',
|
|
|
|
data: {
|
|
|
|
claimStatus: 0,
|
|
|
|
current: 1,
|
|
|
|
endTime: "",
|
|
|
|
id: "",
|
|
|
|
pageSize: 10,
|
|
|
|
paymentStatus: "",
|
|
|
|
sortField: "",
|
|
|
|
sortOrder: "",
|
|
|
|
startTime: "",
|
|
|
|
userId: userInfo.id,
|
|
|
|
userRole: 0,
|
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Cookie': userInfo.cookie,
|
|
|
|
},
|
|
|
|
dataType: 'json',
|
|
|
|
success: (res) => {
|
|
|
|
if (res.data.code === 0) {
|
|
|
|
this.setData({
|
|
|
|
dingdan: res.data.data.records,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fail: (error) => {
|
|
|
|
console.error('请求失败: ', JSON.stringify(error));
|
|
|
|
my.alert({ content: '请求失败,请稍后重试' });
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2024-11-10 07:01:22 +00:00
|
|
|
});
|
2024-12-01 11:56:54 +00:00
|
|
|
|