2025-08-04 16:31:21 +08:00
|
|
|
import { baseUrl } from "../../../request";
|
|
|
|
|
|
|
|
// pages/dashboardModule/userOrderPerformance/userOrderPerformance.js
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
orderNumber: '', // 双向绑定的输入框内容
|
|
|
|
staffUserId: 0, // 后期改为动态注入
|
|
|
|
OrderItems: [] // 接口返回的订单列表
|
|
|
|
},
|
|
|
|
|
|
|
|
onLoad(options) {
|
|
|
|
console.log('options-->',options);
|
|
|
|
this.setData({
|
|
|
|
staffUserId: options.userId
|
|
|
|
})
|
|
|
|
this.searchOrderByStaffId()
|
|
|
|
},
|
|
|
|
|
|
|
|
// 输入框内容变化
|
|
|
|
onOrderNumberInput(e) {
|
|
|
|
this.setData({
|
|
|
|
orderNumber: e.detail.value.trim()
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
// 点击搜索按钮
|
|
|
|
searchOrder() {
|
|
|
|
const { orderNumber, staffUserId } = this.data;
|
|
|
|
|
|
|
|
// 简单校验:非空
|
2025-08-07 19:56:53 +08:00
|
|
|
// if (!orderNumber) {
|
|
|
|
// return wx.showToast({
|
|
|
|
// title: '请输入订单号',
|
|
|
|
// icon: 'none'
|
|
|
|
// });
|
|
|
|
// }
|
2025-08-04 16:31:21 +08:00
|
|
|
|
|
|
|
// 发起 POST 请求
|
|
|
|
wx.request({
|
|
|
|
url: baseUrl + '/perform/query/user',
|
|
|
|
method: 'POST',
|
|
|
|
header: {
|
|
|
|
Authorization: wx.getStorageSync('token')
|
|
|
|
},
|
|
|
|
data: {
|
|
|
|
orderNumber,
|
|
|
|
staffUserId
|
|
|
|
},
|
|
|
|
success: (res) => {
|
|
|
|
if (res.data.code === 1) {
|
|
|
|
// 更新列表
|
|
|
|
this.setData({
|
|
|
|
OrderItems: res.data.data
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
wx.showToast({
|
|
|
|
title: res.data.message || '未找到订单',
|
|
|
|
icon: 'none'
|
|
|
|
});
|
|
|
|
this.setData({ OrderItems: [] });
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fail: () => {
|
|
|
|
wx.showToast({
|
|
|
|
title: '请求失败,请稍后重试',
|
|
|
|
icon: 'none'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
// 根据上级订单搜索
|
|
|
|
searchOrderByStaffId() {
|
|
|
|
const { staffUserId } = this.data;
|
|
|
|
|
|
|
|
// 发起 POST 请求
|
|
|
|
wx.request({
|
|
|
|
url: baseUrl + '/perform/query/user',
|
|
|
|
method: 'POST',
|
|
|
|
header: {
|
|
|
|
Authorization: wx.getStorageSync('token')
|
|
|
|
},
|
|
|
|
data: {
|
|
|
|
staffUserId
|
|
|
|
},
|
|
|
|
success: (res) => {
|
|
|
|
if (res.data.code === 1) {
|
|
|
|
// 更新列表
|
|
|
|
this.setData({
|
|
|
|
OrderItems: res.data.data
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
wx.showToast({
|
|
|
|
title: res.data.message || '未找到订单',
|
|
|
|
icon: 'none'
|
|
|
|
});
|
|
|
|
this.setData({ OrderItems: [] });
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fail: () => {
|
|
|
|
wx.showToast({
|
|
|
|
title: '请求失败,请稍后重试',
|
|
|
|
icon: 'none'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|