|
@@ -858,9 +858,9 @@ Page({
|
|
|
|
|
|
async click_scan_control(scanResult,inner) {
|
|
|
if (this.data.isLogin) {
|
|
|
- this.queryParkOrder(3).then(res=>{
|
|
|
- console.log("查询未支付成功",res);
|
|
|
- if (res.total > 0) {
|
|
|
+ const resultOrder = await this.queryParkOrder(3);
|
|
|
+ console.log("查询未支付成功",resultOrder);
|
|
|
+ if (resultOrder.total > 0) {
|
|
|
wx.showModal({
|
|
|
showCancel: false,
|
|
|
confirmText: '去支付',
|
|
@@ -876,8 +876,8 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+ return;
|
|
|
}
|
|
|
- })
|
|
|
const result = await this.queryParkOrder(2);
|
|
|
if (result.total > 0) { // 有占位费订单不启动扫码充电
|
|
|
this.setData({
|
|
@@ -1280,35 +1280,39 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
// 根据状态查询占位费订单
|
|
|
- queryParkOrder(status) {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- let that = this;
|
|
|
- wx.request({
|
|
|
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/queryOccupyFeeOrder',
|
|
|
- data: {
|
|
|
- userId: wx.getStorageSync('userInfo').userId,
|
|
|
- searchIndex: status,
|
|
|
- pagenum: that.data.pagenum++,
|
|
|
- pagesize: 10,
|
|
|
- },
|
|
|
- method: 'POST',
|
|
|
- success(res) {
|
|
|
- console.log('请求成功,处理数据');
|
|
|
- if(res.data.code==200){
|
|
|
- if (res.data.result.total > 0) {
|
|
|
- resolve(res.data.result);
|
|
|
- }
|
|
|
- }else{
|
|
|
- resolve(res.data);
|
|
|
- }
|
|
|
- },
|
|
|
- fail(err) {
|
|
|
- console.error('请求失败', err);
|
|
|
- reject(err);
|
|
|
+ async queryParkOrder(status) {
|
|
|
+ let that = this;
|
|
|
+ let userId = wx.getStorageSync('userInfo').userId;
|
|
|
+ let pagenum = that.data.pagenum; // 先取值,防止影响下一次请求
|
|
|
+ that.data.pagenum++; // 递增页码
|
|
|
+
|
|
|
+ try {
|
|
|
+ let res = await new Promise((resolve, reject) => {
|
|
|
+ wx.request({
|
|
|
+ url: getApp().globalData.postHeadAgreement + '/restapi/wechat/queryOccupyFeeOrder',
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ userId,
|
|
|
+ searchIndex: status,
|
|
|
+ pagenum,
|
|
|
+ pagesize: 10
|
|
|
+ },
|
|
|
+ success: resolve,
|
|
|
+ fail: reject
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log('请求成功,处理数据');
|
|
|
+ if (res.data && res.data.code === 200) {
|
|
|
+ return res.data.result.total > 0 ? res.data.result : res.data;
|
|
|
+ } else {
|
|
|
+ return res.data || {}; // 确保返回的是对象,防止 undefined
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
+ } catch (err) {
|
|
|
+ console.error('请求失败', err);
|
|
|
+ throw err;
|
|
|
+ }
|
|
|
+},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|