update_patrol_point.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. bindInputName(e) {
  59. this.data.name = e.detail.value
  60. },
  61. bindInputRemark(e) {
  62. this.data.remark = e.detail.value
  63. },
  64. bindInputCode(e) {
  65. this.data.code = e.detail.value
  66. },
  67. bindViewScan(){
  68. wx.scanCode({
  69. onlyFromCamera: true,
  70. success: (res) => {
  71. this.setData({
  72. ['details.code']:res.result,
  73. })
  74. },
  75. fail: (res) => {
  76. wx.showToast({
  77. title: '扫描失败请重试',
  78. icon:'none'
  79. })
  80. }
  81. })
  82. },
  83. //------------------------------------------
  84. updateDetails() {
  85. if(this.data.name==null){
  86. wx.showToast({
  87. title:'请输入巡更点名称',
  88. icon:'none'
  89. })
  90. return
  91. }
  92. // if(this.data.details.code==null){
  93. // wx.showToast({
  94. // title:'请扫描巡更点编码',
  95. // icon:'none'
  96. // })
  97. // return
  98. // }
  99. if(this.data.longitude==0||this.data.latitude==0){
  100. wx.showToast({
  101. title:'请点击定位当前位置',
  102. icon:'none'
  103. })
  104. return
  105. }
  106. let obj = new Object();
  107. // obj.busEnterpriseId = this.data.enterpriseId
  108. obj.busPatrolstationId = this.data.id
  109. obj.busPatrolstationName = this.data.name
  110. obj.busPatrolstationCode = this.data.code
  111. obj.longitude=this.data.longitude
  112. obj.latitude=this.data.latitude
  113. obj.remarks = this.data.remark
  114. http.post("/system/AppPatrolstationController/edittPatrolstationList", obj, this.updateDetailsSuccess)
  115. },
  116. updateDetailsSuccess(res) {
  117. wx.showToast({
  118. title: res.msg,
  119. })
  120. if(res.code == 200){
  121. wx.navigateBack()
  122. }
  123. },
  124. /**
  125. * 生命周期函数--监听页面初次渲染完成
  126. */
  127. onReady() {
  128. },
  129. /**
  130. * 生命周期函数--监听页面显示
  131. */
  132. onShow() {
  133. },
  134. /**
  135. * 生命周期函数--监听页面隐藏
  136. */
  137. onHide() {
  138. },
  139. /**
  140. * 生命周期函数--监听页面卸载
  141. */
  142. onUnload() {
  143. },
  144. /**
  145. * 页面相关事件处理函数--监听用户下拉动作
  146. */
  147. onPullDownRefresh() {
  148. },
  149. /**
  150. * 页面上拉触底事件的处理函数
  151. */
  152. onReachBottom() {
  153. },
  154. /**
  155. * 用户点击右上角分享
  156. */
  157. onShareAppMessage() {
  158. },
  159. getLocation() {
  160. let that = this
  161. wx.getLocation({
  162. type: 'wgs84', //返回可以用于wx.openLocation的经纬度
  163. success: function (res) {
  164. that.setData({
  165. ['details.longitude']: res.longitude,
  166. ['details.latitude']: res.latitude
  167. })
  168. },
  169. })
  170. },
  171. })