myorder.js 8.0 KB
// pages/myorder/myorder.js
// const app = getApp();
// import menu from '../template/template'
const app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navbar: [{
      name: '全部'
    },
    {
      name: '未付款'
    },
    {
      name: '已付款'
    },
    {
      name: '已完成'
    },
    ],
    currentTab:0,
    myorder:false,
    class:'',
    num:4,
    navbarjingxiao: [{
      name: '全部'
    },
    {
      name: '已提交'
    },
    {
      name: '已完成'
    },
    
    ],
    jingxiaocurrentTab:0,
    orderlist:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    
    // if(options.current!=undefined){
    //   this.setData({
    //     currentTab:options.current,
    //     jingxiaocurrentTab:options.current,
    //     class: options.kind
    //   })
    // }
    // if(options.kind!=undefined){
    //   this.setData({
        
    //     class: options.kind
    //   })
    // }
    
  },

  //确认收货
  sureshouhuo(e){
    console.log(e)
    let that = this;
    let statusid = e.currentTarget.dataset.statusid
    
    let orderno=e.currentTarget.dataset.orderno
    let url = '/OrderManagement/UpdateOrderStatusByOrderNo', params = {
      statusId: statusid,
      orderNo: orderno,
      payStatus:''
    }
    app.post(url, params).then((res) => {
      console.log(res);
      wx.showToast({
        title: '收货成功',
        icon:'none'
      })



    }).catch((err) => {
          wx.showToast({
            title: err.ResultMsg,
            icon:'none'
          })
    })
    

     
   
  },

  //获取订单 散客  导购
  getorderlist(){
    let that = this;
    let url = '/OrderManagement/SelectOrderListBySUIDAndOrderStatus', params = {
      suid: wx.getStorageSync('Suid'),
      //suid:'A28F3A32-912E-4948-9439-9C985C7D87F6',
      orderStatus: that.data.currentTab
    }
    app.post(url, params).then((res) => {
      console.log(res);
      let neworder=res.order;
      for(var obj of neworder){
        let total = 0;
       
        for (var p of obj.orderGoodsInfo){
          total =total+Number(p.totalGoodsPrice);
        
           p.totalGoodsPrice = Number(p.goodsPrice)*Number(p.numbers)
         
          }
          obj.moretotalmoney=total
      }
      that.setData({
        orderlist: neworder
      })

      console.log(that.data.orderlist)
    }).catch((err) => {

    })
  },

  //获取订单经销商

  getjingxiaolist(){
    let that = this;
    let url = '/OrderManagement/SelectOrderListBySUIDAndOrderStatus', params = {
      suid: wx.getStorageSync('Suid'),
      //suid:'A28F3A32-912E-4948-9439-9C985C7D87F6',
      orderStatus: that.data.jingxiaocurrentTab
    }
    app.post(url, params).then((res) => {
      console.log(res);
      let neworder = res.order;
      for (var obj of neworder) {
        let total = 0;

        for (var p of obj.orderGoodsInfo) {
          total = total + Number(p.totalGoodsPrice)
        }
        obj.moretotalmoney = total
      }
      that.setData({
        orderlist: neworder
      })

      console.log(that.data.orderlist)
    }).catch((err) => {

    })
  },
  //底部导航跳转
  jump(e) {
    console.log(e)
    var that = this;
    wx.setStorageSync('num', e.currentTarget.dataset.num)
    let number = e.currentTarget.dataset.num
    console.log(number)
    if (number == 1) {
      wx.reLaunch({
        url: '/pages/homeindex/homeindex',
      })

    } else if (number == 2) {
      wx.redirectTo({
        url: '/pages/shopgoods/shopgoods',
      })
    } else if (number == 3) {

      wx.reLaunch({
        url: '/pages/shopcar/shopcar',
      })
    } else if (number == 4) {
      wx.reLaunch({
        url: '/pages/myorder/myorder',
      })
    } else if (number == 5) {
      let type = e.currentTarget.dataset.type;
      if (type == 1) {
        wx.reLaunch({
          //url: '/pages/visitormine/visitormine',
          url: '/pages/guidemine/guidemine'
        })
      }

    }
  },
  navbarTap: function (e) {
    let that = this;
    this.setData({
      currentTab: e.currentTarget.dataset.idx,
    })

    that.getorderlist()
  },

  jingxiaonavbarTap: function (e) {
    let that = this;
    console.log(e)
    this.setData({
      currentTab: e.currentTarget.dataset.idx,
      
    })

    if(that.data.currentTab==0){
      that.setData({
        jingxiaocurrentTab:0
      })
    } else if (that.data.currentTab == 1){
      that.setData({
        jingxiaocurrentTab: 1
      })
    } else if (that.data.currentTab == 2) {
      that.setData({
        jingxiaocurrentTab: 3
      })
    }

    that.getjingxiaolist()
  },

  //立即支付
  paynow(e){
    console.log(e)
    // let that=this;
    // wx.setStorageSync('addressinfo', '');
    // wx.setStorageSync('drawbill', '');
    //  let orderno=e.currentTarget.dataset.orderno;
    //  console.log(oederno)
    // let statusid=e.currentTarget.dataset.statusid;
    // console.log(e)
    // let id=e.currentTarget.dataset.id;
    // console.log(id)
    // let neworderlist=that.data.orderlist;
    // for(var obj of neworderlist){
    //   console.log(obj.$id)
    //   if(id==obj.$id){ 
    //     console.log(obj.orderGoodsInfo)
    //     wx.setStorageSync('listgood', obj.orderGoodsInfo);
    //   }
    // }

    // wx.navigateTo({
    //   url:'/pages/ordercontainer/sureorderone/sureorderone?statusid='+statusid+'&orderno='+orderno
    // })


  },

  buyagain(e){
   let that=this;
    wx.setStorageSync('addressinfo', '');
    wx.setStorageSync('drawbill', '');
    let orderno=e.currentTarget.dataset.orderno;
    let statusid=e.currentTarget.dataset.statusid;
    console.log(e)
    let id=e.currentTarget.dataset.id;
    console.log(id)
    let neworderlist=that.data.orderlist;
    for(var obj of neworderlist){
      console.log(obj.$id)
      if(id==obj.$id){ 
        console.log(obj.orderGoodsInfo)
        wx.setStorageSync('listgood', obj.orderGoodsInfo);
      }
    }

    wx.navigateTo({
      url:'/pages/ordercontainer/sureorderone/sureorderone?statusid='+statusid+'&orderno='+orderno
    })

  },

  //订单详情

  //kind 订单身份 1普通客户  2 导购  type 订单状态  1 未付款 2已付款 3 已完成
  
  ordertail(e){
    console.log(e)
    let isReplaceOrder = e.currentTarget.dataset.isreplaceorder
    let type=e.currentTarget.dataset.type;
    let orderno=e.currentTarget.dataset.orderno;
    let statusid = e.currentTarget.dataset.statusid;
    console.log(isReplaceOrder)
    let kind =e.currentTarget.dataset.kind
      wx.navigateTo({
        url: '/pages/ordercontainer/orderdetail/orderdetail?kind=' + kind + '&type=' + type + '&orderno=' + orderno + '&statusid=' + statusid + '&isReplaceOrder=' + isReplaceOrder,
      })
   
  },
  //经销商订单详情
  jingxiaoordertail(e){
    let type = e.currentTarget.dataset.type;
    let statusid=e.currentTarget.dataset.statusid
    wx.navigateTo({
      url: '/pages/ordercontainer/jingxiaoorderdetail/jingxiaoorderdetail?type=' + type+'&statusid='+statusid,
    })
  },

// 提交
  submitbtn(){
    wx.navigateTo({
      url: '/pages/ordercontainer/shopsureorder/shopsureorder',
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let current = wx.getStorageSync('current');
    let usertype = wx.getStorageSync('UserType');
    console.log(current);
    console.log(usertype)
    this.setData({
      currentTab: current,
      jingxiaocurrentTab:current,
      class: usertype,
    })

    this.getorderlist()
  },

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

  },

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

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

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

  }
})