update_patrol_point.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. import http from '../../base/httputil'
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. host: app.globalData.host,
  9. enterpriseId: null,
  10. pageCode: null,
  11. // details: {
  12. id: null,
  13. longitude: Number,
  14. latitude: Number,
  15. name: null,
  16. code: null,
  17. remark: null,
  18. // },
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad(options) {
  24. this.data.pageCode = options.code
  25. this.getDetails()
  26. },
  27. getDetails() {
  28. wx.showLoading()
  29. let obj = new Object();
  30. obj.busPatrolstationCode = this.data.pageCode
  31. http.post("/system/AppPatrolstationController/getPatrolstationDetail", obj, this.getDetailsSuccess)
  32. },
  33. getDetailsSuccess(res) {
  34. wx.hideLoading()
  35. if (res.data.length == 0) {
  36. wx.showToast({
  37. title: '暂无巡更点',
  38. icon: 'none'
  39. })
  40. } else {
  41. // this.data.details.name= res.data[0].busEnterpriseName,
  42. // this.data.enterpriseId= res.data[0].busEnterpriseId,
  43. this.data.id = res.data[0].busPatrolstationId,
  44. this.data.code = res.data[0].busPatrolstationCode,
  45. this.data.name = res.data[0].busPatrolstationName,
  46. this.data.latitude = res.data[0].latitude,
  47. this.data.longitude = res.data[0].longitude,
  48. this.data.remark = res.data[0].remarks,
  49. this.setData({
  50. remark: res.data[0].remarks,
  51. code: res.data[0].busPatrolstationCode,
  52. name: res.data[0].busPatrolstationName,
  53. latitude: res.data[0].latitude,
  54. longitude: res.data[0].longitude,
  55. })
  56. }
  57. },
  58. //-----------------------------------------
  59. bindInputName(e) {
  60. this.data.name = e.detail.value
  61. },
  62. bindInputRemark(e) {
  63. this.data.remark = e.detail.value
  64. },
  65. bindInputCode(e) {
  66. this.data.code = e.detail.value
  67. },
  68. bindViewScan() {
  69. wx.scanCode({
  70. onlyFromCamera: true,
  71. success: (res) => {
  72. this.setData({
  73. ['details.code']: res.result,
  74. })
  75. },
  76. fail: (res) => {
  77. wx.showToast({
  78. title: '扫描失败请重试',
  79. icon: 'none'
  80. })
  81. }
  82. })
  83. },
  84. //------------------------------------------
  85. updateDetails() {
  86. if (this.data.name == null) {
  87. wx.showToast({
  88. title: '请输入巡更点名称',
  89. icon: 'none'
  90. })
  91. return
  92. }
  93. // if(this.data.details.code==null){
  94. // wx.showToast({
  95. // title:'请扫描巡更点编码',
  96. // icon:'none'
  97. // })
  98. // return
  99. // }
  100. if (isNaN(this.data.latitude) || isNaN(this.data.longitude)) {
  101. wx.showToast({
  102. title: '请点击定位当前位置',
  103. icon: 'none'
  104. })
  105. return
  106. }
  107. let obj = new Object();
  108. // obj.busEnterpriseId = this.data.enterpriseId
  109. obj.busPatrolstationId = this.data.id
  110. obj.busPatrolstationName = this.data.name
  111. obj.busPatrolstationCode = this.data.code
  112. obj.longitude = this.data.longitude
  113. obj.latitude = this.data.latitude
  114. obj.remarks = this.data.remark
  115. http.post("/system/AppPatrolstationController/edittPatrolstationList", obj, this.updateDetailsSuccess)
  116. },
  117. updateDetailsSuccess(res) {
  118. wx.showToast({
  119. title: res.msg,
  120. })
  121. if (res.code == 200) {
  122. wx.navigateBack()
  123. }
  124. },
  125. /**
  126. * 生命周期函数--监听页面初次渲染完成
  127. */
  128. onReady() {
  129. },
  130. /**
  131. * 生命周期函数--监听页面显示
  132. */
  133. onShow() {
  134. },
  135. /**
  136. * 生命周期函数--监听页面隐藏
  137. */
  138. onHide() {
  139. },
  140. /**
  141. * 生命周期函数--监听页面卸载
  142. */
  143. onUnload() {
  144. },
  145. /**
  146. * 页面相关事件处理函数--监听用户下拉动作
  147. */
  148. onPullDownRefresh() {
  149. },
  150. /**
  151. * 页面上拉触底事件的处理函数
  152. */
  153. onReachBottom() {
  154. },
  155. /**
  156. * 用户点击右上角分享
  157. */
  158. onShareAppMessage() {
  159. },
  160. getLocation() {
  161. let that = this
  162. wx.getLocation({
  163. type: 'wgs84', //返回可以用于wx.openLocation的经纬度
  164. success: function (res) {
  165. that.setData({
  166. ['longitude']: res.longitude,
  167. ['latitude']: res.latitude
  168. })
  169. },
  170. })
  171. },
  172. })