new_patrol_point.js 3.8 KB

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