orderDetail.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // pages/orderDetail/orderDetail.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. info: '',
  11. settle: '',
  12. safeBottom: `30px`,
  13. },
  14. allocation(){
  15. util.skip('/pages/allocation/allocation?id='+this.data.info.id)
  16. },
  17. accept(){
  18. wx.requestSubscribeMessage({
  19. tmplIds: [app.globalData.templateconfig.shop_order_template,app.globalData.templateconfig.shop_finish_template,app.globalData.templateconfig.shop_sales_template],
  20. complete :(res) =>{
  21. http.post('order/shopaccept', {
  22. id: this.data.info.id
  23. }, true, false).then(res => {
  24. util.toast('抢单成功,请派单')
  25. this.getInfo()
  26. }).catch(e => {
  27. let data = e.data
  28. if(data.code === 2){
  29. util.toast(data.msg)
  30. setTimeout(()=>{
  31. util.skip('/service/earnestMoney/earnestMoney')
  32. },1000)
  33. }else if(data.code === 0){
  34. util.toast(data.data)
  35. }
  36. })
  37. }
  38. })
  39. },
  40. copy(event){
  41. wx.setClipboardData({
  42. data: event.currentTarget.dataset.content,
  43. success (res) {
  44. util.toast('已复制')
  45. }
  46. })
  47. },
  48. navigation(){
  49. wx.openLocation({
  50. latitude : Number(this.data.info.orderAddress.lat),
  51. longitude : Number(this.data.info.orderAddress.lng),
  52. name: this.data.info.orderAddress.area,
  53. scale: 18
  54. })
  55. },
  56. call(event){
  57. wx.makePhoneCall({
  58. phoneNumber: event.currentTarget.dataset.content
  59. })
  60. },
  61. getInfo(){
  62. http.post('order/orderInfo', {
  63. id: this.data.order_id
  64. }).then(res => {
  65. this.setData({
  66. info: res.data
  67. })
  68. if(res.data.is_settle > 0 ){
  69. this.getSettle()
  70. }
  71. })
  72. },
  73. getSettle(){
  74. http.post('order/priceInfo', {
  75. id: this.data.order_id
  76. }).then(res => {
  77. this.setData({
  78. settle: res.data
  79. })
  80. })
  81. },
  82. /**
  83. * 生命周期函数--监听页面加载
  84. */
  85. onLoad(options) {
  86. const high = app.globalData.safeBottom
  87. this.setData({
  88. safeBottom: `${high}px`,
  89. order_id: options.order_id
  90. })
  91. },
  92. /**
  93. * 生命周期函数--监听页面显示
  94. */
  95. onShow() {
  96. this.getInfo()
  97. },
  98. /**
  99. * 生命周期函数--监听页面隐藏
  100. */
  101. onHide() {
  102. },
  103. /**
  104. * 生命周期函数--监听页面卸载
  105. */
  106. onUnload() {
  107. },
  108. /**
  109. * 页面相关事件处理函数--监听用户下拉动作
  110. */
  111. onPullDownRefresh() {
  112. },
  113. /**
  114. * 页面上拉触底事件的处理函数
  115. */
  116. onReachBottom() {
  117. },
  118. /**
  119. * 用户点击右上角分享
  120. */
  121. onShareAppMessage() {
  122. }
  123. })