|
@@ -0,0 +1,195 @@
|
|
|
|
+import http from '../../base/httputil'
|
|
|
|
+const app = getApp()
|
|
|
|
+Page({
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 页面的初始数据
|
|
|
|
+ */
|
|
|
|
+ data: {
|
|
|
|
+ host: app.globalData.host,
|
|
|
|
+ enterpriseId: null,
|
|
|
|
+ pageCode:null,
|
|
|
|
+ // details: {
|
|
|
|
+ id: null,
|
|
|
|
+ longitude: Number,
|
|
|
|
+ latitude: Number,
|
|
|
|
+ name: null,
|
|
|
|
+ code: null,
|
|
|
|
+ remark: null,
|
|
|
|
+ // },
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
|
+ */
|
|
|
|
+ onLoad(options) {
|
|
|
|
+ this.data.pageCode = options.code
|
|
|
|
+ this.getDetails()
|
|
|
|
+ },
|
|
|
|
+ getDetails() {
|
|
|
|
+ wx.showLoading()
|
|
|
|
+ let obj = new Object();
|
|
|
|
+ obj.busPatrolstationCode = this.data.pageCode
|
|
|
|
+ http.post("/system/AppPatrolstationController/getPatrolstationDetail", obj, this.getDetailsSuccess)
|
|
|
|
+ },
|
|
|
|
+ getDetailsSuccess(res) {
|
|
|
|
+ console.log("!!!", res)
|
|
|
|
+ wx.hideLoading()
|
|
|
|
+ if (res.data.length == 0) {
|
|
|
|
+
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '暂无巡更点',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ // this.data.details.name= res.data[0].busEnterpriseName,
|
|
|
|
+ // this.data.enterpriseId= res.data[0].busEnterpriseId,
|
|
|
|
+ this.data.id= res.data[0].busPatrolstationId,
|
|
|
|
+ this.data.code= res.data[0].busPatrolstationCode,
|
|
|
|
+ this.data.name= res.data[0].busPatrolstationName,
|
|
|
|
+ this.data.latitude= res.data[0].latitude,
|
|
|
|
+ this.data.longitude= res.data[0].longitude,
|
|
|
|
+ this.data.remark=res.data[0].remarks,
|
|
|
|
+ this.setData({
|
|
|
|
+ remark: res.data[0].remarks,
|
|
|
|
+ code:res.data[0].busPatrolstationCode,
|
|
|
|
+ name:res.data[0].busPatrolstationName,
|
|
|
|
+ latitude: res.data[0].latitude,
|
|
|
|
+ longitude: res.data[0].longitude,})
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ //-----------------------------------------
|
|
|
|
+ bindInputName(e) {
|
|
|
|
+ this.data.name = e.detail.value
|
|
|
|
+ },
|
|
|
|
+ bindInputRemark(e) {
|
|
|
|
+ this.data.remark = e.detail.value
|
|
|
|
+ },
|
|
|
|
+ bindInputCode(e) {
|
|
|
|
+ this.data.code = e.detail.value
|
|
|
|
+ },
|
|
|
|
+ bindViewScan(){
|
|
|
|
+ wx.scanCode({
|
|
|
|
+ onlyFromCamera: true,
|
|
|
|
+ success: (res) => {
|
|
|
|
+ this.setData({
|
|
|
|
+ ['details.code']:res.result,
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ fail: (res) => {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '扫描失败请重试',
|
|
|
|
+ icon:'none'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ //------------------------------------------
|
|
|
|
+
|
|
|
|
+ updateDetails() {
|
|
|
|
+ if(this.data.name==null){
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title:'请输入巡更点名称',
|
|
|
|
+ icon:'none'
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // if(this.data.details.code==null){
|
|
|
|
+ // wx.showToast({
|
|
|
|
+ // title:'请扫描巡更点编码',
|
|
|
|
+ // icon:'none'
|
|
|
|
+ // })
|
|
|
|
+ // return
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ if(this.data.longitude==0||this.data.latitude==0){
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title:'请点击定位当前位置',
|
|
|
|
+ icon:'none'
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let obj = new Object();
|
|
|
|
+ // obj.busEnterpriseId = this.data.enterpriseId
|
|
|
|
+ obj.busPatrolstationId = this.data.id
|
|
|
|
+ obj.busPatrolstationName = this.data.name
|
|
|
|
+ obj.busPatrolstationCode = this.data.code
|
|
|
|
+ obj.longitude=this.data.longitude
|
|
|
|
+ obj.latitude=this.data.latitude
|
|
|
|
+ obj.remarks = this.data.remark
|
|
|
|
+
|
|
|
|
+ http.post("/system/AppPatrolstationController/edittPatrolstationList", obj, this.updateDetailsSuccess)
|
|
|
|
+ },
|
|
|
|
+ updateDetailsSuccess(res) {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: res.msg,
|
|
|
|
+ })
|
|
|
|
+ if(res.code == 200){
|
|
|
|
+ wx.navigateBack()
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
|
+ */
|
|
|
|
+ onReady() {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
|
+ */
|
|
|
|
+ onShow() {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 生命周期函数--监听页面隐藏
|
|
|
|
+ */
|
|
|
|
+ onHide() {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 生命周期函数--监听页面卸载
|
|
|
|
+ */
|
|
|
|
+ onUnload() {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
+ */
|
|
|
|
+ onPullDownRefresh() {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
|
+ */
|
|
|
|
+ onReachBottom() {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 用户点击右上角分享
|
|
|
|
+ */
|
|
|
|
+ onShareAppMessage() {
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ getLocation() {
|
|
|
|
+ let that = this
|
|
|
|
+ wx.getLocation({
|
|
|
|
+ type: 'wgs84', //返回可以用于wx.openLocation的经纬度
|
|
|
|
+ success: function (res) {
|
|
|
|
+ that.setData({
|
|
|
|
+ ['details.longitude']: res.longitude,
|
|
|
|
+ ['details.latitude']: res.latitude
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+})
|