detail.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. // pages/detail/detail.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. cover: true,
  8. bright_points: '',
  9. message: {
  10. '0': '确认订单',
  11. '1': '订单关闭',
  12. '2': '已确认',
  13. '3': '订单中止',
  14. '4': '订单完成'
  15. },
  16. status: 0
  17. },
  18. // 报名
  19. apply() {
  20. this.setData({
  21. cover: true,
  22. })
  23. wx.kx_request({
  24. url: wx.kx_api.hwRequirement.enrollmentRequire,
  25. model: true,
  26. type: 'post',
  27. data: {
  28. requirement_id: this.data.id,
  29. bright_points: this.data.bright_points,
  30. enroll_from: 0
  31. },
  32. success: res => {
  33. wx.showToast({
  34. title: '报名成功',
  35. })
  36. },
  37. fail: res => {
  38. if (res.errcode) {
  39. wx.showModal({
  40. title: '报名失败',
  41. content: res.errmsg,
  42. showCancel: false,
  43. confirmColor: '#31364C'
  44. })
  45. }
  46. }
  47. })
  48. },
  49. // 亮点输入
  50. input(e) {
  51. this.setData({
  52. bright_points: e.detail.value
  53. })
  54. },
  55. // 打开地图
  56. openMap(e) {
  57. const name = e.currentTarget.dataset.name;
  58. const address = e.currentTarget.dataset.address;
  59. // wx.openLocation({
  60. // latitude: 31.544325,
  61. // longitude: 120.356595,
  62. // name,
  63. // address
  64. // })
  65. },
  66. // 查看合同
  67. buttonCheck() {
  68. wx.downloadFile({
  69. url: this.data.hwOrderAPI.workContract,
  70. success: (res) => {
  71. wx.openDocument({
  72. filePath: res.tempFilePath,
  73. })
  74. }
  75. })
  76. },
  77. // 确认订单
  78. buttonSubmit() {
  79. wx.kx_request({
  80. url: wx.kx_api.hwOrder.confirmOrder,
  81. type: 'post',
  82. data: {
  83. orderId: this.data.hwOrderAPI.id
  84. },
  85. success: res => {
  86. if (res.errcode === 0) {
  87. wx.showToast({
  88. title: '订单已确认',
  89. success: res => {
  90. const hwOrderAPI = this.data.hwOrderAPI;
  91. hwOrderAPI.status = 2;
  92. this.setData({
  93. hwOrderAPI
  94. })
  95. }
  96. })
  97. }
  98. }
  99. })
  100. },
  101. /* 控制cover层的显示与隐藏 */
  102. cover() {
  103. const cover = !this.data.cover;
  104. this.setData({
  105. cover
  106. })
  107. },
  108. /**
  109. * 生命周期函数--监听页面加载
  110. */
  111. onLoad: function(options) {
  112. if (options.id && options.status) {
  113. if (options.status === '3') {
  114. wx.kx_request({
  115. url: wx.kx_api.hwOrder.getOrderDetail,
  116. data: {
  117. orderId: options.id
  118. },
  119. success: res => {
  120. if (res.errcode === 0) {
  121. this.setData({
  122. ...res.data.hwRequirementAPI,
  123. hwOrderAPI: res.data.hwOrderAPI
  124. })
  125. }
  126. }
  127. })
  128. }
  129. if (options.status === '1') {
  130. wx.kx_request({
  131. url: wx.kx_api.hwRequirement.getRequirementDetail,
  132. data: {
  133. hwRequirementId: options.id
  134. },
  135. success: res => {
  136. if (res.errcode === 0) {
  137. this.setData({
  138. ...res.data.hwRequirementAPI
  139. })
  140. }
  141. }
  142. })
  143. }
  144. }
  145. if (options.status) {
  146. this.setData({
  147. status: options.status - 0
  148. })
  149. }
  150. },
  151. /**
  152. * 生命周期函数--监听页面初次渲染完成
  153. */
  154. onReady: function() {
  155. },
  156. /**
  157. * 生命周期函数--监听页面显示
  158. */
  159. onShow: function() {
  160. },
  161. /**
  162. * 生命周期函数--监听页面隐藏
  163. */
  164. onHide: function() {
  165. },
  166. /**
  167. * 生命周期函数--监听页面卸载
  168. */
  169. onUnload: function() {
  170. },
  171. /**
  172. * 页面相关事件处理函数--监听用户下拉动作
  173. */
  174. onPullDownRefresh: function() {
  175. },
  176. /**
  177. * 页面上拉触底事件的处理函数
  178. */
  179. onReachBottom: function() {
  180. },
  181. /**
  182. * 用户点击右上角分享
  183. */
  184. onShareAppMessage: function() {
  185. }
  186. })