orderDetail.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. order_id: '',
  11. info: '',
  12. show: false,
  13. images: [],
  14. safeBottom: `30px`,
  15. settle: ''
  16. },
  17. copy(event){
  18. wx.setClipboardData({
  19. data: event.currentTarget.dataset.content,
  20. success (res) {
  21. util.toast('已复制')
  22. }
  23. })
  24. },
  25. navigation(){
  26. wx.openLocation({
  27. latitude : Number(this.data.info.orderAddress.lat),
  28. longitude : Number(this.data.info.orderAddress.lng),
  29. name: this.data.info.orderAddress.area,
  30. scale: 18
  31. })
  32. },
  33. call(){
  34. wx.makePhoneCall({
  35. phoneNumber: this.data.info.orderAddress.mobile
  36. })
  37. },
  38. onClose(){
  39. this.setData({
  40. show: false
  41. })
  42. },
  43. showUpload(){
  44. this.setData({
  45. show: true
  46. })
  47. },
  48. delImages(e){
  49. let index = e.currentTarget.dataset.index
  50. this.data.images.splice(index,1)
  51. this.setData({
  52. images: this.data.images
  53. })
  54. },
  55. chooseImages(e) {
  56. let index = e.currentTarget.dataset.index
  57. http.chooseImg(['camera'], true).then(res => {
  58. let arr = this.data.images;
  59. if(index !== undefined){
  60. arr.splice(index,1,res.data.url)
  61. }else {
  62. arr.push(res.data.url)
  63. }
  64. this.setData({
  65. images: arr
  66. })
  67. })
  68. },
  69. getInfo(){
  70. http.post('order/orderInfo', {
  71. id: this.data.order_id
  72. }).then(res => {
  73. this.setData({
  74. info: res.data
  75. })
  76. if(res.data.is_settle > 0 ){
  77. this.getSettle()
  78. }
  79. })
  80. },
  81. getSettle(){
  82. http.post('order/priceInfo', {
  83. id: this.data.order_id
  84. }).then(res => {
  85. this.setData({
  86. settle: res.data
  87. })
  88. })
  89. },
  90. accept(){
  91. http.post('order/skillaccept',{
  92. id: this.data.order_id
  93. }, true, false).then(res => {
  94. util.toast('抢单成功')
  95. this.getInfo()
  96. }).catch(e => {
  97. let data = e.data
  98. if(data.code === 2){
  99. util.toast(data.msg)
  100. }else if(data.code === 0){
  101. util.toast(data.data)
  102. }
  103. })
  104. },
  105. go(){
  106. http.post('order/skillgo', {
  107. id: this.data.order_id
  108. }).then(res => {
  109. this.getInfo()
  110. })
  111. },
  112. arrive(){
  113. if(this.data.images.length === 0) return util.toast('请上传图片')
  114. http.post('order/skillreach', {
  115. id: this.data.order_id,
  116. reach_images: this.data.images.join(',')
  117. }).then(res => {
  118. this.setData({
  119. images: [],
  120. show: false
  121. })
  122. this.getInfo()
  123. })
  124. },
  125. finish(){
  126. if(this.data.images.length === 0) return util.toast('请上传图片')
  127. http.post('order/skillfinish', {
  128. id: this.data.order_id,
  129. finish_images: this.data.images.join(',')
  130. }).then(res => {
  131. this.setData({
  132. images: [],
  133. show: false
  134. })
  135. this.getInfo()
  136. })
  137. },
  138. start(){
  139. http.post('order/skillstart', {
  140. id: this.data.order_id
  141. }).then(res => {
  142. this.getInfo()
  143. })
  144. },
  145. /**
  146. * 生命周期函数--监听页面加载
  147. */
  148. onLoad(options) {
  149. const high = app.globalData.safeBottom
  150. this.setData({
  151. order_id: options.id,
  152. safeBottom: `${high}px`
  153. })
  154. },
  155. /**
  156. * 生命周期函数--监听页面初次渲染完成
  157. */
  158. onReady() {
  159. },
  160. /**
  161. * 生命周期函数--监听页面显示
  162. */
  163. onShow() {
  164. this.getInfo()
  165. },
  166. /**
  167. * 生命周期函数--监听页面隐藏
  168. */
  169. onHide() {
  170. },
  171. /**
  172. * 生命周期函数--监听页面卸载
  173. */
  174. onUnload() {
  175. },
  176. /**
  177. * 页面相关事件处理函数--监听用户下拉动作
  178. */
  179. onPullDownRefresh() {
  180. },
  181. /**
  182. * 页面上拉触底事件的处理函数
  183. */
  184. onReachBottom() {
  185. },
  186. /**
  187. * 用户点击右上角分享
  188. */
  189. onShareAppMessage() {
  190. }
  191. })