|
@@ -171,156 +171,6 @@ Page({
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- // // 抽取的核心逻辑,封装Promise
|
|
|
- // fetchOrderStatus(chargPileId, userId, orderid) {
|
|
|
- // const that = this;
|
|
|
-
|
|
|
- // log.info('[充电中]', '[获取订单状态]', '[请求]', { chargPileId, userId, orderid });
|
|
|
- // wx.request({
|
|
|
- // url: getApp().globalData.postHeadAgreement + '/restapi/pileLog/wechatchargstatus',
|
|
|
- // data: { chargPileId, userId, orderid },
|
|
|
- // method: 'POST',
|
|
|
- // success(res) {
|
|
|
- // let { data } = res;
|
|
|
- // log.info('[充电中]', '[获取订单状态]', '[响应]', data);
|
|
|
- // // data.code = 500
|
|
|
- // if (data && data.code === 200) {
|
|
|
- // let { result: chargingOrder } = data;
|
|
|
- // let { chargPileId } = chargingOrder;
|
|
|
- // let orderid_r = chargingOrder.orderid;
|
|
|
-
|
|
|
- // // 顺序执行:先获取充电桩信息再处理订单状态
|
|
|
- // that.fetchChargPile(chargPileId, userId)
|
|
|
- // .then((chargPile) => {
|
|
|
- // log.info('[充电中]', '[获取充电桩完成,开始处理订单状态]', { chargPile });
|
|
|
- // that.handleOrderStatus(chargingOrder, orderid_r, chargPileId, chargPile);
|
|
|
- // })
|
|
|
- // .catch((err) => {
|
|
|
- // log.error('[充电中]', '[获取充电桩失败]', err);
|
|
|
- // });
|
|
|
- // } else if (data && data.code === 500) {
|
|
|
- // console.log("data.code为500",data.code);
|
|
|
- // // clearInterval(chargingStatus);
|
|
|
- // log.info('[充电中]', '[充电轮训]', '[再次尝试获取订单状态]', data);
|
|
|
-
|
|
|
- // // 再次调用 fetchOrderStatus
|
|
|
- // // that.fetchOrderStatus(chargPileId, userId, orderid);
|
|
|
- // } else {
|
|
|
- // console.log(res);
|
|
|
- // }
|
|
|
- // },
|
|
|
- // fail(err) {
|
|
|
- // log.error('[充电中]', '[获取订单状态失败]', err);
|
|
|
- // },
|
|
|
- // });
|
|
|
- // },
|
|
|
-
|
|
|
- // // 获取充电桩信息(返回 Promise)
|
|
|
- // fetchChargPile(chargPileId, userId) {
|
|
|
- // return new Promise((resolve, reject) => {
|
|
|
- // log.info('[充电中]', '[获取充电桩]', '[请求]', { chargPileId, userId });
|
|
|
- // wx.request({
|
|
|
- // url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargPile',
|
|
|
- // data: { chargPileId, userId },
|
|
|
- // method: 'POST',
|
|
|
- // success(res) {
|
|
|
- // let chargPile = res.data.result;
|
|
|
- // if (chargPile) {
|
|
|
- // log.info('[充电中]', '[获取充电桩]', '[响应]', chargPile);
|
|
|
- // resolve(chargPile);
|
|
|
- // } else {
|
|
|
- // reject(new Error('获取充电桩数据失败'));
|
|
|
- // }
|
|
|
- // },
|
|
|
- // fail(err) {
|
|
|
- // reject(err);
|
|
|
- // },
|
|
|
- // });
|
|
|
- // });
|
|
|
- // },
|
|
|
-
|
|
|
- // // 根据订单状态处理逻辑(返回 Promise)
|
|
|
- // handleOrderStatus(chargingOrder, orderid_r, chargPileId, chargPile) {
|
|
|
- // const that = this;
|
|
|
-
|
|
|
- // return new Promise((resolve) => {
|
|
|
- // if (chargingOrder.chargPileStatus === 1) {
|
|
|
- // log.info('[充电中]', '[订单状态]', '[状态1:启动中,继续轮训]', chargingOrder);
|
|
|
- // that.setData({
|
|
|
- // chargingOrder,
|
|
|
- // chargPileId,
|
|
|
- // orderid: orderid_r,
|
|
|
- // chargPile,
|
|
|
- // });
|
|
|
- // resolve();
|
|
|
- // } else if (chargingOrder.chargPileStatus === 2) {
|
|
|
- // let chargingTime = that.formatChargingTime(chargingOrder.ljcdsj);
|
|
|
- // let totalMoney = (
|
|
|
- // parseFloat(chargingOrder.ycdfje) + parseFloat(chargingOrder.ycfwfje)
|
|
|
- // ).toFixed(2);
|
|
|
- // let cdscdl = parseFloat(chargingOrder.cdscdl).toFixed(2);
|
|
|
- // let cdscdy = parseFloat(chargingOrder.cdscdy).toFixed(2);
|
|
|
- // let yczds = parseFloat(chargingOrder.yczds).toFixed(2);
|
|
|
-
|
|
|
- // that.setData({
|
|
|
- // chargingOrder,
|
|
|
- // chargPileId,
|
|
|
- // chargingTime,
|
|
|
- // orderid: orderid_r,
|
|
|
- // totalMoney,
|
|
|
- // cdscdl,
|
|
|
- // cdscdy,
|
|
|
- // yczds,
|
|
|
- // chargPile,
|
|
|
- // });
|
|
|
- // that.showChargingPng();
|
|
|
- // resolve();
|
|
|
- // } else if (chargingOrder.chargPileStatus === 3) {
|
|
|
- // clearInterval(chargingStatus);
|
|
|
- // log.info('[充电中]', '[订单状态]', '[状态3:跳转到订单支付界面]', chargingOrder);
|
|
|
-
|
|
|
- // let { userId } = that.data;
|
|
|
- // let url = `/pages/order/order?orderid=${orderid_r}&userId=${userId}&chargPileId=${chargPileId}`;
|
|
|
- // wx.redirectTo({ url });
|
|
|
- // resolve();
|
|
|
- // } else if (chargingOrder.chargPileStatus === 4) {
|
|
|
- // clearInterval(chargingStatus);
|
|
|
- // log.info('[充电中]', '[订单状态]', '[状态4:启动异常,删除订单]', chargingOrder);
|
|
|
-
|
|
|
- // wx.showModal({
|
|
|
- // showCancel: false,
|
|
|
- // content: '开启充电失败',
|
|
|
- // confirmColor: '#00AADD',
|
|
|
- // });
|
|
|
- // that.delOrder(orderid_r);
|
|
|
- // resolve();
|
|
|
- // }
|
|
|
- // });
|
|
|
- // },
|
|
|
-
|
|
|
- // // 格式化充电时间
|
|
|
- // formatChargingTime(minutes) {
|
|
|
- // let chargingTimeHour = Math.floor(minutes / 60);
|
|
|
- // if (chargingTimeHour <= 9) {
|
|
|
- // chargingTimeHour = '0' + chargingTimeHour;
|
|
|
- // }
|
|
|
- // let chargingTimeMinute = minutes % 60;
|
|
|
- // if (chargingTimeMinute <= 9) {
|
|
|
- // chargingTimeMinute = '0' + chargingTimeMinute;
|
|
|
- // }
|
|
|
- // return `${chargingTimeHour}:${chargingTimeMinute}:00`;
|
|
|
- // },
|
|
|
- // onLoad: function(options) {
|
|
|
- // let { orderid, userId, chargPileId } = options;
|
|
|
- // log.info('[充电中]', '[加载完成]', '[参数]', { orderid, userId, chargPileId });
|
|
|
-
|
|
|
- // this.setData({ orderid, userId, chargPileId });
|
|
|
- // if (!orderid || orderid === "null") {
|
|
|
- // orderid = undefined;
|
|
|
- // }
|
|
|
-
|
|
|
- // this.fetchOrderStatus(chargPileId, userId, orderid);
|
|
|
- // },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|