new_patrol_point.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. //------------------------------------------
  47. updateDetails() {
  48. if(this.data.details.name==null){
  49. wx.showToast({
  50. title:'请输入巡更点名称',
  51. })
  52. }
  53. if(this.data.details.code==null){
  54. wx.showToast({
  55. title:'请扫描巡更点编码',
  56. })
  57. }
  58. if(this.data.details.longitude||this.data.details.latitude){
  59. wx.showToast({
  60. title:'请点击定位当前位置',
  61. })
  62. }
  63. let obj = new Object();
  64. obj.busEnterpriseId = this.data.enterpriseId
  65. obj.busPatrolstationName = this.data.details.name
  66. obj.busPatrolstationCode = this.data.details.code
  67. obj.longitude=this.data.details.longitude
  68. obj.latitude=this.data.details.latitude
  69. obj.remarks = this.data.details.remark
  70. http.post("/system/AppPatrolstationController/addPatrolstation", obj, this.updateDetailsSuccess)
  71. },
  72. updateDetailsSuccess(res) {
  73. wx.showToast({
  74. title: res.msg,
  75. })
  76. if(res.code == 200){
  77. wx.navigateBack()
  78. }
  79. },
  80. deletePatrolPoint() {
  81. // let obj = new Object();
  82. // obj.busEnterpriseId = this.data.enterpriseDetails.busEnterpriseId
  83. // http.post("/system/AppEnterpriseController/deleteEnterprise", obj, this.deleteEnterpriseSuccess)
  84. },
  85. // deleteEnterpriseSuccess(res) {
  86. // wx.showToast({
  87. // title: res.msg,
  88. // })
  89. // if(res.code == 200){
  90. // wx.navigateTo({
  91. // url: '../qiye/qiye'
  92. // })
  93. // }
  94. // },
  95. /**
  96. * 生命周期函数--监听页面初次渲染完成
  97. */
  98. onReady() {
  99. },
  100. /**
  101. * 生命周期函数--监听页面显示
  102. */
  103. onShow() {
  104. },
  105. /**
  106. * 生命周期函数--监听页面隐藏
  107. */
  108. onHide() {
  109. },
  110. /**
  111. * 生命周期函数--监听页面卸载
  112. */
  113. onUnload() {
  114. },
  115. /**
  116. * 页面相关事件处理函数--监听用户下拉动作
  117. */
  118. onPullDownRefresh() {
  119. },
  120. /**
  121. * 页面上拉触底事件的处理函数
  122. */
  123. onReachBottom() {
  124. },
  125. /**
  126. * 用户点击右上角分享
  127. */
  128. onShareAppMessage() {
  129. },
  130. getLocation() {
  131. let that = this
  132. wx.getLocation({
  133. type: 'wgs84', //返回可以用于wx.openLocation的经纬度
  134. success: function (res) {
  135. that.setData({
  136. details: {
  137. longitude: res.longitude,
  138. latitude: res.latitude
  139. }
  140. })
  141. },
  142. })
  143. },
  144. })