order.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. // pages/order/order.js
  2. const app = getApp()
  3. import http from "../../utils/http"
  4. import util from "../../utils/util"
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. unread:2,
  11. tabList:['接单池','待派单','待接单','进行中/待核销','已完成','售后订单'],
  12. orderState:1,
  13. list:[],
  14. finish: false,
  15. loading: false,
  16. page: 1,
  17. active: 0,
  18. token: wx.getStorageSync('token')
  19. },
  20. notice(){
  21. },
  22. orderBtnTap(e){
  23. if(e.detail.type == 1){
  24. wx.requestSubscribeMessage({
  25. tmplIds: [app.globalData.templateconfig.shop_order_template,app.globalData.templateconfig.shop_finish_template,app.globalData.templateconfig.shop_sales_template],
  26. complete :(res) =>{
  27. http.post('order/shopaccept', {
  28. id: e.detail.info.id
  29. }, true, false).then(res => {
  30. this.setData({
  31. active: 1
  32. })
  33. this.reload()
  34. util.toast('抢单成功,请派单')
  35. }).catch(e => {
  36. let data = e.data
  37. if(data.code === 2){
  38. util.toast(data.msg)
  39. setTimeout(()=>{
  40. util.skip('/service/earnestMoney/earnestMoney')
  41. },1000)
  42. }else if(data.code === 0){
  43. util.toast(data.msg)
  44. }
  45. })
  46. }
  47. })
  48. }else if(e.detail.type == 2){
  49. util.skip('/pages/allocation/allocation?id='+e.detail.info.id)
  50. }else if(e.detail.type == 3){
  51. wx.openLocation({
  52. latitude : Number(e.detail.info.address.lat),
  53. longitude : Number(e.detail.info.address.lng),
  54. name: e.detail.info.address.area,
  55. scale: 18
  56. })
  57. }
  58. },
  59. orderTap(e){
  60. util.skip('/pages/orderDetail/orderDetail?order_id='+e.detail.id)
  61. },
  62. reload(){
  63. this.setData({
  64. list: [],
  65. page: 1,
  66. finish: false
  67. })
  68. this.getList()
  69. },
  70. more(){
  71. this.setData({
  72. page: ++this.data.page
  73. })
  74. this.getList()
  75. },
  76. getList(){
  77. if(!wx.getStorageSync('token')) return
  78. if(this.data.finish){
  79. return
  80. }
  81. if(this.data.loading){
  82. return
  83. }
  84. this.setData({
  85. loading: true
  86. })
  87. let data = {
  88. page: this.data.page,
  89. }
  90. if(this.data.active === 0){
  91. data['is_pool'] = 1
  92. }else if(this.data.active === 1){
  93. data['not_allocation'] = 1
  94. }else if(this.data.active === 2){
  95. data['not_accept'] = 1
  96. }else if(this.data.active === 3){
  97. data['not_finish'] = 1
  98. }else if(this.data.active === 4){
  99. data['finish'] = 1
  100. }else if(this.data.active === 5){
  101. data['in_service'] = 1
  102. }
  103. http.post('order/shoporderlist', data).then(res => {
  104. if(res.data.length === 0){
  105. this.setData({
  106. finish: true
  107. })
  108. }
  109. let arr = this.data.list.concat(res.data)
  110. this.setData({
  111. list: arr
  112. })
  113. }).finally(res => {
  114. this.setData({
  115. loading: false
  116. })
  117. })
  118. },
  119. //派单
  120. toallocation(){
  121. wx.navigateTo({
  122. url: '/pages/allocation/allocation',
  123. })
  124. },
  125. toDetail(){
  126. wx.navigateTo({
  127. url: '../orderDetail/orderDetail',
  128. })
  129. },
  130. onChange(event) {
  131. this.setData({
  132. active: event.detail.index
  133. })
  134. this.reload()
  135. },
  136. /**
  137. * 生命周期函数--监听页面加载
  138. */
  139. onLoad(options) {
  140. },
  141. /**
  142. * 生命周期函数--监听页面显示
  143. */
  144. onShow() {
  145. this.setData({
  146. token: wx.getStorageSync('token')
  147. })
  148. this.reload()
  149. },
  150. })