//获取应用实例 var app = getApp(); var WXAPI = require('../../utils/server.js'); Page({ data: { animation: {}, // 动画 animation_mask: {}, // 动画 showModalStatus: false, // modal是否需要渲染 currentIndex: 0, navTab: [{'type':'全部','status':'','num':0}, {'type':'待付款','status':'payment','num':0}, {'type':'待发货','status':'send','num':0}, {'type':'待收货','status':'receipt','num':0}, {'type':'待评价','status':'evaluete','num':0}], currentStatus: '', listArray: [], page: 1, loading: false, complete: false, scrollTop: 0, scrollHeight: 0, sortingList: [{ key: 1, value: "全部订单", otype: 'pay' }, { key: 3, value: "拼团", otype: 'pay6' }], isPay: 0, }, switchTab: function(e) { var dataset = e.currentTarget.dataset this.setData({ currentIndex: dataset.idx, currentStatus: dataset.item.status, scrollTop: 0, page: 1, loading: false, complete: false }); this.getOderList(); }, scroll: function (e) { if (this.data.toView == "top") { this.setData({ toView: "" }) } }, getOderList: function() { //在当前页面显示导航条加载动画 wx.showNavigationBarLoading(); wx.showLoading({ title: '加载中...', }) var that = this WXAPI.orderList({ accessId: app.globalData.accessId, storeId: 239, storeType: 1, queryOrderType: that.data.currentStatus, page : that.data.page, }).then(res => { if (res.code == 200) { var result = res.data.order || [] var list = (this.data.page == 1 ? [] : this.data.listArray).concat(result) // var complete = (this.data.page >= res.data.page.pages) var complete = (this.data.listArray.length >= res.data.order_num) var loading = !complete // console.log(res); that.setData({ listArray: list, loading: loading, complete: complete, }) //隐藏loading 提示框 wx.hideLoading(); // //隐藏导航条加载动画 wx.hideNavigationBarLoading(); //停止下拉刷新 wx.stopPullDownRefresh(); } }) }, reloadData: function() { this.setData({ page: 1 }) this.getOderList(); }, loadMoreData: function() { if (this.data.loading && !this.data.complete) { this.setData({ page: this.data.page + 1 }) this.getOderList(); } }, //详情页跳转 lookDetail:function(e){ var goodsId = e.currentTarget.dataset.id; wx.navigateTo({ url:"/pages/order/detail?id="+goodsId }) }, toast: function(msg) { wx.showToast({ title: msg, icon: 'none', duration: 2000 }) }, // 取消订单 removeOrder: function(e) { var that = this; var info = e.currentTarget.dataset.info wx.showModal({ title: '提示', content: '你确定要取消订单吗?', success: function (res) { WXAPI.removeOrder({ accessId: app.globalData.accessId, storeId: 239, storeType: 1, order_id: info.id, }).then(res => { if (res.code == 200) { that.reloadData(); } }) } }); }, //立即支付 payNow: function(e) { var data = e.currentTarget.dataset.info wx.navigateTo({ url: "/pages/order/payment?orderId="+data.sNo+"&price="+data.z_price, }) }, //提醒发货 orderRemind: function(e) { var that = this; var info = e.currentTarget.dataset.info WXAPI.orderRemind({ accessId: app.globalData.accessId, storeId: 239, storeType: 1, order_id: info.id, }).then(res => { if (res.code == 200) { that.reloadData(); } }) }, // 确认收货 confirmOrder: function(e) { var that = this; var info = e.currentTarget.dataset.info wx.showModal({ title: '提示', content: '请确认你已收到货物', success: function (res) { WXAPI.confirmOrder({ accessId: app.globalData.accessId, storeId: 239, storeType: 1, order_id: info.id, }).then(res => { if (res.code == 200) { that.reloadData(); } }) } }); }, //删除订单 deleteOrder: function(e) { var that = this; var info = e.currentTarget.dataset.info wx.showModal({ title: '提示', content: '确定要删除订单吗', success: function (res) { WXAPI.deleteOrder({ accessId: app.globalData.accessId, storeId: 239, storeType: 1, order_id: info.id, }).then(res => { if (res.code == 200) { that.reloadData(); } }) } }); }, //查看物流 orderLogistics: function(e) { var info = e.currentTarget.dataset.info wx.navigateTo({ url:"/pages/logistics/logistics?orderId="+info.sNo }) }, //去评价 evaluateOrder: function(e) { var that = this; var info = e.currentTarget.dataset.info wx.navigateTo({ url:"/pages/comment/comment?id="+info.id }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { var that = this that.setData({ currentIndex: options.index, currentStatus: options.status, isPay: options.isPay }) that.reloadData(); that.getWXTemplate() }, getWXTemplate() { WXAPI.getWXTemplate({ storeId: 239, storeType: 1, type: 2, }).then(res => { if (res.code == 200) { var data = res.data wx.setStorageSync('logmsgId', [data.template_id]) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { this.reloadData(); }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { if (this.data.isPay == 1) { wx.navigateBack({ delta: 2 }) } }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })