diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index 3b6e71b..d5bef6e 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -1,5 +1,6 @@ // miniprogram/pages/addDevice/addDevice.js - +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp(); Page({ @@ -215,7 +216,7 @@ ['form.installperson']: app.globalData.userName, ['form.installtimeFmt']: "", ['form.workmsg']: "", - ['form.description']: "" + // ['form.description']: "" }) const { @@ -467,14 +468,14 @@ //自动生成修改内容 this.changeMsg(); //提交权限限制(只有施工人员能修改) - if(app.globalData.role!='repair'){ - wx.showToast({ - icon: 'none', - title: '无权限修改', - duration:2000 - }) - return false - } + // if(app.globalData.role!='repair'){ + // wx.showToast({ + // icon: 'none', + // title: '无权限修改', + // duration:2000 + // }) + // return false + // } var that = this; var fileList = that.data.fileList; for (var i = 0; i < fileList.length; i++) { @@ -538,6 +539,30 @@ } }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, //粘贴经纬度 paste() { var _this = this; @@ -557,6 +582,7 @@ }); } }) + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) }, selectValue(value) { var that = this; @@ -657,7 +683,11 @@ header: { 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - success(res) {} + success(res) { + that.setData({ + [`form.photopath${image_index + 1}`] : '' + }) + } }) } else { //这里是点击了取消以后 console.log('用户点击取消') diff --git a/miniprogram/pages/addDevicelog/addDeviceLog.js b/miniprogram/pages/addDevicelog/addDeviceLog.js index 3b6e71b..d5bef6e 100644 --- a/miniprogram/pages/addDevicelog/addDeviceLog.js +++ b/miniprogram/pages/addDevicelog/addDeviceLog.js @@ -1,5 +1,6 @@ // miniprogram/pages/addDevice/addDevice.js - +var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); +var qqmapsdk; var app = getApp(); Page({ @@ -215,7 +216,7 @@ ['form.installperson']: app.globalData.userName, ['form.installtimeFmt']: "", ['form.workmsg']: "", - ['form.description']: "" + // ['form.description']: "" }) const { @@ -467,14 +468,14 @@ //自动生成修改内容 this.changeMsg(); //提交权限限制(只有施工人员能修改) - if(app.globalData.role!='repair'){ - wx.showToast({ - icon: 'none', - title: '无权限修改', - duration:2000 - }) - return false - } + // if(app.globalData.role!='repair'){ + // wx.showToast({ + // icon: 'none', + // title: '无权限修改', + // duration:2000 + // }) + // return false + // } var that = this; var fileList = that.data.fileList; for (var i = 0; i < fileList.length; i++) { @@ -538,6 +539,30 @@ } }) }, + showAddress :function(longitude, latitude, self) { + // 实例化腾讯地图API核心类 + qqmapsdk = new QQMapWX({ + key: 'BGPBZ-C5O3P-ROUDR-LWC4J-63EKH-V5FRX'//此处使用你自己申请的key + }) + // 腾讯地图调用接口 + qqmapsdk.reverseGeocoder({ + location: { + latitude: latitude, + longitude: longitude + }, + success: function (res) { + self.setData({ + 'form.area':res.result.address.slice(0,res.result.address.indexOf('区')+1), + 'form.street':res.result.address.slice(res.result.address.indexOf('区')+1) + }) + }, + fail: function (res) { + console.log(res); + }, + complete: function (res) { + } + }); + }, //粘贴经纬度 paste() { var _this = this; @@ -557,6 +582,7 @@ }); } }) + _this.showAddress(_this.data.form.longitude,_this.data.form.latitude,_this) }, selectValue(value) { var that = this; @@ -657,7 +683,11 @@ header: { 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }, - success(res) {} + success(res) { + that.setData({ + [`form.photopath${image_index + 1}`] : '' + }) + } }) } else { //这里是点击了取消以后 console.log('用户点击取消') diff --git a/miniprogram/pages/earth/earth.js b/miniprogram/pages/earth/earth.js index 376a6e2..8bc3b3b 100644 --- a/miniprogram/pages/earth/earth.js +++ b/miniprogram/pages/earth/earth.js @@ -388,6 +388,9 @@ var that = this; if (that.data.devcodes == "") { + that.setData({ + markers:[] + }) return false; } wx.request({ @@ -405,9 +408,9 @@ that.setData({ listData: listResultData }) - var markersArr = that.data.markers; + var markersArr = [] for (var i = 0; i < listResultData.length; i++) { - markersArr = markersArr.concat({ + let arr = { iconPath: "../../images/locat.png", id: listResultData[i].id, callout: { @@ -426,7 +429,8 @@ longitude: listResultData[i].longitude, width: 40, height: 40 - }); + }; + markersArr.push(arr) } that.setData({ markers: markersArr,