// pages/order-list/index.js let app = getApp() Page({ /** * 页面的初始数据 */ data: { statusType: ["全部", "待支付", "待确认", "已确认"], currentType:0, tabClass:["","","",""] }, statusTap(e){ let index = e.currentTarget.dataset.index this.setData({ currentType: index }) this.onShow() }, //取消 toQuxiao(e){ let orderId = e.currentTarget.dataset.id let that = this let postData = { oid: orderId } postData.status = '已取消' wx.request({ url: app.data.resturl + '/orderstate.action', data: postData, method: 'post', header: { 'content-type': 'application/x-www-form-urlencoded' }, success:(res)=>{ let code = res.data; if(code=='yes'){ let postData = { openid: app.globalData.openid } postData.status = '已取消' wx.request({ url: app.data.resturl + '/olist.action', data: postData, method: 'post', header: { 'content-type': 'application/x-www-form-urlencoded' }, success: (res) => { that.setData({ orderList: res.data.dlist }); that.setData({ currentType: 0 }) } }) } } }) }, //支付 toPay(e) { let orderId = e.currentTarget.dataset.id let that = this let postData = { oid: orderId } postData.status = '待接单' wx.request({ url: app.data.resturl + '/orderstate.action', data: postData, method: 'post', header: { 'content-type': 'application/x-www-form-urlencoded' }, success: (res) => { let code = res.data; if (code == 'yes') { let postData = { openid: app.globalData.openid } postData.status = '待接单' wx.request({ url: app.data.resturl + '/olist.action', data: postData, method: 'post', header: { 'content-type': 'application/x-www-form-urlencoded' }, success: (res) => { that.setData({ orderList: res.data.dlist }); that.setData({ currentType: 2 }) } }) } } }) }, //删除 toDel(e) { let orderId = e.currentTarget.dataset.id let that = this let postData = { oid: orderId } wx.request({ url: app.data.resturl + '/delOrder.action', data: postData, method: 'post', header: { 'content-type': 'application/x-www-form-urlencoded' }, success: (res) => { let code = res.data; if (code == 'yes') { let postData = { openid: app.globalData.openid } wx.request({ url: app.data.resturl + '/olist.action', data: postData, method: 'post', header: { 'content-type': 'application/x-www-form-urlencoded' }, success: (res) => { that.setData({ orderList: res.data.dlist }); that.setData({ currentType: 0 }) } }) } } }) }, orderDetail(e) { wx.navigateTo({ url: '/pages/order-details/index?id=' + e.currentTarget.dataset.id }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, onShow: function () { let that = this wx.showLoading() let postData = { openid: app.globalData.openid } if (this.data.currentType == 1){ postData.status = '待支付' } if (this.data.currentType == 2){ postData.status = '待接单' } if (this.data.currentType == 3) { postData.status = '已接单' } postData.openid = app.globalData.openid wx.request({ url: app.data.resturl + '/olist.action', data: postData, method: 'post', header: { 'content-type': 'application/x-www-form-urlencoded' }, success:(res)=>{ wx.hideLoading() that.setData({ orderList: res.data.dlist }) } }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })