refund-after.js 6.5 KB
// pages/all-order/all-order.js
let method = require("../../utils/reuqest.js")
Page({
  data: {
    index: '',
    active: 2,
    status: '',
    orederId: '',
    goodsid: '',
    tabList: [],
    totalList: [],
    payList: [],
    sendList: [],
    evaluateList: [],
    reapList: [],
    orderid: '',
    bottomHint: false //触底提示
  },
  // 导航切换事件
  onClick: function (e) {
    let index = e.detail.index;
    switch (index) {
      case 1:
        this.unPayment()
        break;
      case 2:
        this.unSend()
        break;
      case 3:
        this.unReap()
        break;
      case 4:
        this.unEvaluate()
        break;
      case 0:
        this.allOrder()
        break;
    }
  },
  //订单详情
  orderDetail(e) {
    let orderId = e.currentTarget.dataset.orderid
    wx.navigateTo({
      url: '/pages/order-detail/order-detail?orderId=' + orderId + "&flag=" + "true",
    })
  },

  //全部订单
  allOrder() {
    let postData = {
      page: 1,
      size: 10,
      type: -1
    }
    method.postRequest("/order/list", postData, data => {
      if (data.statusCode == 0) {
        this.setData({
          tabList: data.data
        })
      }
    })
  },
  //待付款
  unPayment() {
    let postData = {
      page: 1,
      size: 10,
      type: 0
    }
    method.postRequest("/order/list", postData, data => {
      if (data.statusCode == 0) {
        this.setData({
          tabList: data.data
        })
      }
    })
  },
  //待发货
  unSend() {
    let postData = {
      page: 1,
      size: 10,
      type: 1
    }
    method.postRequest("/order/list", postData, data => {
      if (data.statusCode == 0) {
        this.setData({
          tabList: data.data
        })
      }
    })
  },
  //待评价
  unEvaluate() {
    let postData = {
      page: 1,
      size: 10,
      type: 5
    }
    method.postRequest("/order/list", postData, data => {
      if (data.statusCode == 0) {
        this.setData({
          tabList: data.data
        })
      }
    })
  },
  //待收货
  unReap() {
    let postData = {
      page: 1,
      size: 10,
      type: 2
    }
    method.postRequest("/order/list", postData, data => {
      if (data.statusCode == 0) {
        this.setData({
          tabList: data.data
        })
      }
    })
  },
  //待退款
  refunds() {
    let postData = {
      page: 1,
      size: 10,
      type: 6
    }
    method.postRequest("/order/list", postData, data => {
      wx.stopPullDownRefresh()
      if (data.statusCode == 0) {
        this.setData({
          tabList: data.data
        })
      }
    })
  },
  //页面首次加载
  fristLoad(index) {
    if (index) {
      this.setData({
        active: Number(index) + 1,
      })
      switch (this.data.active) {
        case 1:
          this.unPayment();
          break;
        case 2:
          this.unSend()
          break;
        case 3:
          this.unReap()
          break;
        case 4:
          this.unEvaluate()
          break;
        case 0:
          this.allOrder()
          break;
      }
    }
  },
  //取消订单
  delOrder(e) {
    let that = this;
    let tabList = that.data.tabList;
    let index = e.currentTarget.dataset.index;
    let orderId = e.currentTarget.dataset.orderid
    wx.showModal({
      title: '提示',
      content: '确定取消这个订单吗?',
      success(res) {
        if (res.confirm) {
          tabList.splice(index, 1)
          that.setData({
            tabList: tabList
          })
          method.getRequest("/order/cancelOrder/" + orderId, data => {
            if (data.statusCode == 0) {}
          })
          console.log('用户点击确定')
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })

  },
  //立即支付
  // payment(e) {
  //   let id = e.currentTarget.dataset.id;
  //   let obj = {};
  //   method.postRequest("/payment/payment/" + id, obj, data => {

  //   })
  // },
  //申请退款
  refund(e) {
    let orderid = e.currentTarget.dataset.orderid;
    wx.navigateTo({
      url: '/pages/apply-after-sale/apply-after-sale?orderid=' + orderid,
    })
  },
  //再次购买
  // buyAgain(e) {
  //   let goodsId = e.currentTarget.dataset.goodsid
  //   wx.navigateTo({
  //     url: '/pages/product-detail/product-detail?goodsid='+goodsId,
  //   })
  // },
  //确认收货
  receipt() {
    wx.showModal({
      title: '提示',
      content: '您是否收到该订单商品',
      concelText: '未收货',
      confirmText: '已收货',
      success(res) {
        if (res.confirm) {
          this.confirm();
        } else if (res.cancel) {
          this.cancel();
        }
      }
    })
  },
  confirm() {
    method.getRequest("/order/goodsReceived/" + this.data.orderId + '/0', data => {
      if (data.statusCode == 0) {
        wx.showToast({
          title: '收货成功',
        })
      }
    })
  },
  cancel() {
    method.getRequest("/order/goodsReceived/" + this.data.orderId + '/1', data => {

    })
  },
  //立即评价
  evaluate() {
    let orderId = e.currentTarget.dataset.orderid
    wx.navigateTo({
      url: '/pages/evaluate/evaluate?goodsid' + goodsId,
    })
  },
  //查看物流
  logistics() {
    wx.navigateTo({
      url: '/pages/look-logistics/look-logistics',
    })
  },
  onLoad: function (options) {
    let that = this;
    //判断第一次加载订单状态
    // that.fristLoad(options.index)
    // if (options.index == null) {
    //   this.setData({
    //     active: 0
    //   })
    //   this.allOrder();
    // } else {
    //   this.fristLoad(options.index)
    // }


    //退款
    that.refunds()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onRefresh() {
    this.setData({
      page: 1,
      tabList: []
    })
    this.refunds();
  },
  onPullDownRefresh: function () {
    this.onRefresh()
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.setData({
      bottomHint: true
    })
    setTimeout(() => {
      this.setData({
        bottomHint: false
      })
    }, 2000)
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})