import { url } from '../request'; Page({ data: { current: 0, businessName:'', items: [ { title: '全部', }, { title: '待支付', }, { title: '待使用', }, { title: '已完成', }, { title: '已取消', }, { title: '退款', }, ], dingdan:[], paymentStatuses: [ { paymentStatuses: '0', statue: '待支付' }, { paymentStatuses: '1', statue: '待使用' }, { paymentStatuses: '2', statue: '已取消' }, { paymentStatuses: '3', statue: '已退款' }, { paymentStatuses: '4', statue: '已完成' } ] }, 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, current: 1, endTime: "", id: "", pageSize: 10, paymentStatus: "", sortField: "", sortOrder: "", startTime: "" }, headers: { 'content-type': 'application/json', 'Cookie': userInfo.cookie, }, dataType: 'json', success: (res) => { if(res.data&&res.data.data){ this.setData({ dingdan:res.data.data.records, }) } console.log('Response Set-Cookie:', res.header['Set-Cookie']); console.log(res); console.log(this.data.dingdan); 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', }); }, }); } }, }); }, 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, }); }, getPaymentStatusText(status) { const statusObj = this.paymentStatuses.find(item => item.paymentStatuses === status.toString()); return statusObj ? statusObj.statue : '未知状态'; // 如果找不到对应状态,返回 '未知状态' }, });