|
@@ -2,8 +2,28 @@ const utils = require('../../utils/util')
|
|
|
const form = require('../../utils/formValidation')
|
|
const form = require('../../utils/formValidation')
|
|
|
const util = require('../../utils/util.js');
|
|
const util = require('../../utils/util.js');
|
|
|
const app = getApp();
|
|
const app = getApp();
|
|
|
|
|
+const chooseLocation = requirePlugin('chooseLocation');
|
|
|
Page({
|
|
Page({
|
|
|
|
|
+ // 从地图选点插件返回后,在页面的onShow生命周期函数中能够调用插件接口,取得选点结果对象
|
|
|
|
|
+ onShow () {
|
|
|
|
|
+ const location = chooseLocation.getLocation(); // 如果点击确认选点按钮,则返回选点结果对象,否则返回null
|
|
|
|
|
+ console.log(location)
|
|
|
|
|
+ if(location!=null){
|
|
|
|
|
+ console.log("")
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ ["storeInfo.storeAddress"]: location.name,
|
|
|
|
|
+ ["storeInfo.latitude"]: location.latitude,
|
|
|
|
|
+ ["storeInfo.longitude"]: location.longitude,
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ onUnload () {
|
|
|
|
|
+ // 页面卸载时设置插件选点数据为null,防止再次进入页面,geLocation返回的是上次选点结果
|
|
|
|
|
+ chooseLocation.setLocation(null);
|
|
|
|
|
+ },
|
|
|
/**
|
|
/**
|
|
|
* 页面的初始数据
|
|
* 页面的初始数据
|
|
|
*/
|
|
*/
|
|
@@ -51,12 +71,6 @@ Page({
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 生命周期函数--监听页面显示
|
|
|
|
|
- */
|
|
|
|
|
- onShow: function () {
|
|
|
|
|
-
|
|
|
|
|
- },
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
* 生命周期函数--监听页面隐藏
|
|
@@ -65,12 +79,7 @@ Page({
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 生命周期函数--监听页面卸载
|
|
|
|
|
- */
|
|
|
|
|
- onUnload: function () {
|
|
|
|
|
|
|
|
|
|
- },
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
@@ -181,4 +190,18 @@ Page({
|
|
|
[name]: _this.data[name]
|
|
[name]: _this.data[name]
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
|
|
+ //选择地图
|
|
|
|
|
+ selectMap(){
|
|
|
|
|
+ const key = '3UWBZ-YVSWX-V4245-T2G6T-QQ5US-BJFMP'; //使用在腾讯位置服务申请的key
|
|
|
|
|
+ const referer = '梦果宝盒'; //调用插件的app的名称
|
|
|
|
|
+ const location = JSON.stringify({
|
|
|
|
|
+ latitude: 39.89631551,
|
|
|
|
|
+ longitude: 116.323459711
|
|
|
|
|
+ });
|
|
|
|
|
+ const category = '生活服务,娱乐休闲';
|
|
|
|
|
+
|
|
|
|
|
+ wx.navigateTo({
|
|
|
|
|
+ url: `plugin://chooseLocation/index?key=${key}&referer=${referer}&location=${location}&category=${category}`
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|