// pages/jobDetail/editAddress/index.js var QQMapWX = require("../../../utils/qqmap-wx-jssdk.min.js"); var qqmapsdk; const app = getApp(); Page({ /** * 页面的初始数据 */ data: { array: ['河南', '日薪', '补贴', '返费', '计件', '保底', '面议', '月薪'], index: 0, jobDetail: {}, cqDz: '', cqLat: '', cpLng: '', msDz: '', msLat: '', msLng: '', ssDz: '', ssLat: '', ssLng: '', district: '' }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { var that = this; qqmapsdk = new QQMapWX({ key: "5PTBZ-YI7C6-MZGS3-ES7QN-4T5O2-EJFVR", }); new Promise(function (resolve, reject) { that.setData({ jobDetail: wx.getStorageSync('jobDetail') }) resolve(); }).then(function () { that.setData({ cqDz: that.data.jobDetail.store.detailPosition, cqLat: that.data.jobDetail.store.lat, cqLng: that.data.jobDetail.store.lng, msDz: that.data.jobDetail.storeJob.interviewAddr, msLat: that.data.jobDetail.storeJob.interviewLat, msLng: that.data.jobDetail.storeJob.interviewLng, ssDz: that.data.jobDetail.storeJob.meettingAddr, ssLat: that.data.jobDetail.storeJob.meettingLat, ssLng: that.data.jobDetail.storeJob.meettingLng, }) }) // that.setData({ // cqDz:that.data.jobDetail.store.detailPosition, // cqLat:that.data.jobDetail.store.lat, // cqLng:that.data.jobDetail.store.lng, // msDz:that.data.jobDetail.storeJob.interviewAddr, // ssDz:that.data.jobDetail.storeJob.meettingAddr, // }) }, chooseMap(e) { var that = this; console.log(e); let name = e.currentTarget.dataset.name; var lat = e.currentTarget.dataset.lat; var lng = e.currentTarget.dataset.lng; let address = e.currentTarget.dataset.address; console.log("123"); wx.chooseLocation({ latitude: Number(lat), longitude: Number(lng), success(res) { console.log(res); qqmapsdk.reverseGeocoder({ location: { latitude: res.latitude, longitude: res.longitude }, success: function (res1) { console.log(res1); that.setData({ district: res1.result.address_component.province + "," + res1.result.address_component.city + "," + res1.result.address_component.district }) if (name == "cqDz") { that.setData({ cqDz: res.address, cqLat: res.latitude, cqLng: res.longitude, }) } if (name == "msDz") { that.setData({ msDz: res.address, msLat: res.latitude, msLng: res.longitude, }) } if (name == "ssDz") { // console.log("111111"); // console.log(res.address); that.setData({ ssDz: res.address, ssLat: res.latitude, ssLng: res.longitude, }) } }, fail: function (res) { console.log(res); }, }); console.log(res); } }) // } // console.log(lat); that.setData({ mapLoad: false }) }, formSubmit(e) { var that = this; wx.showLoading({ title: '提交中...', }) // debugger; if (that.data.cqLat != '') { let currData = {}; let that = this; currData["storeId"] = that.data.jobDetail.store.id; currData["detailPosition"] = that.data.cqDz; currData["lat"] = that.data.cqLat; currData["lng"] = that.data.cqLng; currData["district"] = that.data.district wx.request({ url: app.globalData.ip + "/store/updateLngLatDetailPosition", header: app.globalData.header, data: currData, method: "POST", success: function (res) { // debugger; }, fail: function (res) { console.log(res); }, }); } let arr = []; if (that.data.msLat != "") { arr.push(that.push('interviewAddr', that.data.msDz)); arr.push(that.push('interviewLng', that.data.msLng)); arr.push(that.push('interviewLat', that.data.msLat)); } if (that.data.ssLat != "") { arr.push(that.push('meettingAddr', that.data.ssDz)); arr.push(that.push('meettingLng', that.data.ssLng)); arr.push(that.push('meettingLat', that.data.ssLat)); } Promise.all(arr).then((res) => { wx.setStorageSync('isLoad', true); wx.showToast({ title: '修改成功', icon: 'success', duration: 1000 }) setTimeout(function () { wx.navigateBack({ delta: 1, }) }, 1000) }).catch((err) => { console.log(err) wx.showToast({ title: '修改失败', icon: 'success', duration: 1000 }) }) wx.hideLoading({ success: (res) => {}, }) }, push(filedName, filedValue) { let currData = {}; let that = this; currData["id"] = that.data.jobDetail.storeJob.id; currData["fieldName"] = filedName; currData["value"] = filedValue; return new Promise(function (resolve, reject) { wx.request({ url: app.globalData.ip + "/store/job/updateJobField", header: app.globalData.header, data: currData, method: "POST", success: function (res) { resolve(res); // debugger; }, fail: function (res) { reject(res); console.log(res); }, }); }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { var that = this; // that.setData({ // cqDz: that.data.jobDetail.store.detailPosition, // cqLat: that.data.jobDetail.store.lat, // cqLng: that.data.jobDetail.store.lng, // msDz: that.data.jobDetail.storeJob.interviewAddr, // ssDz: that.data.jobDetail.storeJob.meettingAddr, // }) }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })