123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- // 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 () {
-
- }
- })
|