You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
172 lines
3.1 KiB
JavaScript
172 lines
3.1 KiB
JavaScript
|
2 years ago
|
// pages/jobDetail/addAddressNew/index.js
|
||
|
|
var QQMapWX = require("../../../utils/qqmap-wx-jssdk.min.js");
|
||
|
|
var qqmapsdk;
|
||
|
|
const app = getApp();
|
||
|
|
Page({
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面的初始数据
|
||
|
|
*/
|
||
|
|
data: {
|
||
|
|
mapTitle:"无标题",
|
||
|
|
mapAddress:"请添加位置信息",
|
||
|
|
pos: {
|
||
|
|
posName: '',
|
||
|
|
posTitle: '',
|
||
|
|
posContent: '',
|
||
|
|
latitude: '',
|
||
|
|
longitude: '',
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面加载
|
||
|
|
*/
|
||
|
|
onLoad(options) {
|
||
|
|
var that = this;
|
||
|
|
qqmapsdk = new QQMapWX({
|
||
|
|
key: "5PTBZ-YI7C6-MZGS3-ES7QN-4T5O2-EJFVR",
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
chooseMap(e) {
|
||
|
|
var that = this;
|
||
|
|
console.log(e);
|
||
|
|
// let name = e.currentTarget.dataset.name;
|
||
|
|
// let lat = e.currentTarget.dataset.lat;
|
||
|
|
// let lng = e.currentTarget.dataset.lng;
|
||
|
|
console.log("123");
|
||
|
|
|
||
|
|
wx.chooseLocation({
|
||
|
|
// latitude:lat,
|
||
|
|
// longitude:lng,
|
||
|
|
|
||
|
|
success(res) {
|
||
|
|
console.log(res);
|
||
|
|
let tmp = that.data.pos;
|
||
|
|
tmp.posTitle = res.name;
|
||
|
|
tmp.posContent = res.address
|
||
|
|
tmp.latitude = res.latitude
|
||
|
|
tmp.longitude = res.longitude
|
||
|
|
that.setData({
|
||
|
|
pos: tmp
|
||
|
|
})
|
||
|
|
|
||
|
|
// qqmapsdk.reverseGeocoder({
|
||
|
|
// location: {
|
||
|
|
// latitude: res.latitude,
|
||
|
|
// longitude: res.longitude
|
||
|
|
// },
|
||
|
|
// success: function (res1) {
|
||
|
|
// console.log(res1);
|
||
|
|
// that.setData({
|
||
|
|
// mapTitle: res1.result.formatted_addresses.recommend.district,
|
||
|
|
// mapAddress:res1.result.address
|
||
|
|
// })
|
||
|
|
// },
|
||
|
|
// fail: function (res) {
|
||
|
|
// console.log(res);
|
||
|
|
// },
|
||
|
|
// });
|
||
|
|
|
||
|
|
console.log(res);
|
||
|
|
}
|
||
|
|
})
|
||
|
|
// }
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// console.log(lat);
|
||
|
|
|
||
|
|
that.setData({
|
||
|
|
mapLoad: false
|
||
|
|
})
|
||
|
|
},
|
||
|
|
|
||
|
|
formSubmit(e) {
|
||
|
|
var that = this;
|
||
|
|
wx.showLoading({
|
||
|
|
title: '提交中...',
|
||
|
|
})
|
||
|
|
console.log(e.detail.value.addName);
|
||
|
|
if(app.isEmptyCheck(e.detail.value.addName)){
|
||
|
|
wx.hideLoading({
|
||
|
|
success: (res) => {
|
||
|
|
wx.showToast({
|
||
|
|
title: '名称不能为空',
|
||
|
|
icon:'error'
|
||
|
|
})
|
||
|
|
},
|
||
|
|
})
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if(that.data.pos.posName == "请添加位置信息"){
|
||
|
|
wx.hideLoading({
|
||
|
|
success: (res) => {
|
||
|
|
wx.showToast({
|
||
|
|
title: '位置不能为空',
|
||
|
|
icon:'error'
|
||
|
|
})
|
||
|
|
},
|
||
|
|
})
|
||
|
|
return
|
||
|
|
}
|
||
|
|
that.data.pos.posName = e.detail.value.addName;
|
||
|
|
wx.setStorageSync('otherPos', JSON.stringify(that.data.pos));
|
||
|
|
wx.navigateBack({
|
||
|
|
delta:-1,
|
||
|
|
})
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
|
*/
|
||
|
|
onReady() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面显示
|
||
|
|
*/
|
||
|
|
onShow() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面隐藏
|
||
|
|
*/
|
||
|
|
onHide() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面卸载
|
||
|
|
*/
|
||
|
|
onUnload() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
|
*/
|
||
|
|
onPullDownRefresh() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面上拉触底事件的处理函数
|
||
|
|
*/
|
||
|
|
onReachBottom() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 用户点击右上角分享
|
||
|
|
*/
|
||
|
|
onShareAppMessage() {
|
||
|
|
|
||
|
|
}
|
||
|
|
})
|