new_patrol_point.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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: null,
  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(this.data.details.longitude==0||this.data.details.latitude==0){
  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. })
  98. if(res.code == 200){
  99. wx.navigateBack()
  100. }
  101. },
  102. deletePatrolPoint() {
  103. // let obj = new Object();
  104. // obj.busEnterpriseId = this.data.enterpriseDetails.busEnterpriseId
  105. // http.post("/system/AppEnterpriseController/deleteEnterprise", obj, this.deleteEnterpriseSuccess)
  106. },
  107. // deleteEnterpriseSuccess(res) {
  108. // wx.showToast({
  109. // title: res.msg,
  110. // })
  111. // if(res.code == 200){
  112. // wx.navigateTo({
  113. // url: '../qiye/qiye'
  114. // })
  115. // }
  116. // },
  117. /**
  118. * 生命周期函数--监听页面初次渲染完成
  119. */
  120. onReady() {
  121. },
  122. /**
  123. * 生命周期函数--监听页面显示
  124. */
  125. onShow() {
  126. },
  127. /**
  128. * 生命周期函数--监听页面隐藏
  129. */
  130. onHide() {
  131. },
  132. /**
  133. * 生命周期函数--监听页面卸载
  134. */
  135. onUnload() {
  136. },
  137. /**
  138. * 页面相关事件处理函数--监听用户下拉动作
  139. */
  140. onPullDownRefresh() {
  141. },
  142. /**
  143. * 页面上拉触底事件的处理函数
  144. */
  145. onReachBottom() {
  146. },
  147. /**
  148. * 用户点击右上角分享
  149. */
  150. onShareAppMessage() {
  151. },
  152. getLocation() {
  153. let that = this
  154. wx.getLocation({
  155. type: 'wgs84', //返回可以用于wx.openLocation的经纬度
  156. success: function (res) {
  157. that.setData({
  158. ['details.longitude']: res.longitude,
  159. ['details.latitude']: res.latitude
  160. })
  161. },
  162. })
  163. },
  164. })