| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 | var http = require('../../utils/http.js');var config = require('../../utils/config.js');Page({  /**   * 页面的初始数据   */  data: {    statusObject: {      0: '待支付',      20: '订单已接单',      30: '订单待配送',      40: '订单配送中',      50: '订单取消待审核',      60: '订单已取消',      70: '订单已送达',      80: '订单已完成'    },    list: [],    current: 1,    pages: 0,    sts: 9,//9是自定义的全部  },  /**   * 生命周期函数--监听页面加载   */  onLoad: function (options) {    console.log(options);    if (options.sts) {      this.setData({        sts: options.sts      });    }    this.loadOrderData(this.data.sts, 1);  },  /**   * 生命周期函数--监听页面显示   */  onShow: function () {},  /**   * 加载订单数据   */  loadOrderData: function (sts, current) {    var ths = this;    wx.showLoading();    let data = {      current: current,      size: 10,    }    if(sts!=9){      data.status = sts    }    //加载订单列表    var params = {      url: "/p/myOrder/myOrder",      method: "GET",      data,      callBack: function (res) {        // console.log(res);        let img=''        res.records.forEach(orderItem => {          orderItem.totalCounts = 0          if (orderItem.returnMoneySts == null) {            orderItem.returnMoneySts = 0          }          orderItem.orderItemDtos.forEach(prod => {            img=prod.pic.split(',')            prod.pic=img[0]            orderItem.totalCounts += prod.prodCount          })        })        var list = [];        if (res.current == 1) {          list = res.records;        } else {          list = ths.data.list;          Array.prototype.push.apply(list, res.records);        }        ths.setData({          list: list,          pages: res.pages,          current: res.current,        });        wx.hideLoading();      }    };    http.request(params);  },  /**   * 状态点击事件   */  onStsTap: function (e) {    var sts = e.currentTarget.dataset.sts;    this.setData({      sts: sts    });    this.loadOrderData(sts, 1);  },  /**   * 生命周期函数--监听页面初次渲染完成   */  onReady: function () {  },  /**   * 生命周期函数--监听页面隐藏   */  onHide: function () {  },  /**   * 生命周期函数--监听页面卸载   */  onUnload: function () {  },  /**   * 页面相关事件处理函数--监听用户下拉动作   */  onPullDownRefresh: function () {  },  /**   * 页面上拉触底事件的处理函数   */  onReachBottom: function () {    if (this.data.current < this.data.pages) {      this.loadOrderData(this.data.sts, this.data.current + 1);    }  },  /**   * 用户点击右上角分享   */  onShareAppMessage: function () {  },  /**   * 跳转店铺首页   */  toShopIndex: function (e) {    wx.navigateTo({      url: '/pages/shopPage/shopPage?shopId=' + e.currentTarget.dataset.shopid    })  },  /**   * 查看物流   */  toDeliveryPage: function (e) {    let lat=e.currentTarget.dataset.lat    let long=e.currentTarget.dataset.lon    wx.navigateTo({      url: '/pages/MaterialFlowInfo/MaterialFlowInfo?orderNumber=' + e.currentTarget.dataset.ordernum+'&lat='+lat+'&long='+long    })  },  /**   * 取消订单   */  onCancelOrder: function (e) {    var ordernum = e.currentTarget.dataset.ordernum;    var ths = this;    wx.showModal({      title: '',      content: '要取消此订单?',      confirmColor: "#3e62ad",      cancelColor: "#3e62ad",      cancelText: '否',      confirmText: '是',      success(res) {        if (res.confirm) {          wx.showLoading({            mask: true          });          var params = {            url: "/p/myOrder/cancel/" + ordernum,            method: "PUT",            data: {},            callBack: function (res) {              //console.log(res);              ths.loadOrderData(ths.data.sts, 1);              wx.hideLoading();            }          };          http.request(params);        } else if (res.cancel) {          //console.log('用户点击取消')        }      }    })  },  /**   * 待发货取消订单   * @param {*} e    */  onRefundOrder: function (e) {    var params = {      url: '/p/orderRefund/getIsDistribution',      method: 'GET',      data: {        orderNumber: e.currentTarget.dataset.ordernum      },      callBack: res => {        if (res == true) {          wx.showToast({            title: '商品已在配送中,无法取消',            icon: 'none'          })        } else {          wx.navigateTo({            url: '/pages/order-detail/order-detail?orderNum=' + e.currentTarget.dataset.ordernum,          })        }      }    }    http.request(params);  },  /**   * 付款   */  onPayAgain: function (e) {    wx.showLoading({      mask: true    });    var orderType = e.currentTarget.dataset.ordertype;    var params = {      url: "/p/order/pay",      method: "POST",      data: {        orderType: orderType ? orderType : 0,        payType: 1,        orderNumbers: e.currentTarget.dataset.ordernum      },      callBack: res => {        //console.log(res);        wx.hideLoading();        wx.requestPayment({          timeStamp: res.timeStamp,          nonceStr: res.nonceStr,          package: res.package,          signType: res.signType,          paySign: res.paySign,          success: function () {            wx.navigateTo({              url: '/pages/pay-result/pay-result?sts=1&orderNumbers=' + e.currentTarget.dataset.ordernum,            })          },          fail: function (err) {            //console.log("支付失败");          }        })      }    };    http.request(params);  },  /**   * 查看订单详情   */  toOrderDetailPage: function (e) {    wx.navigateTo({      url: '/pages/order-detail/order-detail?orderNum=' + e.currentTarget.dataset.ordernum,    })  },  /**   * 确认收货   */  onConfirmReceive: function (e) {    var ths = this;    wx.showModal({      title: '',      content: '我已收到货?',      confirmColor: "#006CE8",      success(res) {        if (res.confirm) {          wx.showLoading({            mask: true          });          var params = {            url: "/p/myOrder/receipt/" + e.currentTarget.dataset.ordernum,            method: "PUT",            data: {},            callBack: function (res) {              //console.log(res);              ths.loadOrderData(ths.data.sts, 1);              wx.hideLoading();            }          };          http.request(params);        } else if (res.cancel) {          //console.log('用户点击取消')        }      }    })  },  //删除已完成||已取消的订单  delOrderList: function (e) {    var ths = this    wx.showModal({      title: '',      content: '确定要删除此订单吗?',      confirmColor: "#006CE8",      success(res) {        if (res.confirm) {          var ordernum = e.currentTarget.dataset.ordernum;          wx.showLoading();          var params = {            url: "/p/myOrder/" + ordernum,            method: "DELETE",            data: {},            callBack: function (res) {              ths.loadOrderData(ths.data.sts, 1);              wx.hideLoading();            }          }          http.request(params);        } else if (res.cancel) {          console.log('用户点击取消')        }      }    })  },  /**   * 跳转评价页面   */  onComment: function (e) {    var info = e.currentTarget.dataset.info;    wx.setStorageSync("orderItemInfo", info);    wx.navigateTo({      url: '/pages/prodComm/prodComm',    })  }})
 |