import { getShopPage } from '../../api/index' var QQMapWX = require('../../utils/qqmap-wx-jssdk.min'); var qqmapsdk; Page({ /** * 页面的初始数据 */ data: { shopList: [], address: '', latitude: '', longitude: '', }, selAddress() { console.log('点击了'); wx.chooseLocation({ type: 'wgs84', success: (res) => { this.setData({ address: res.address, latitude: res.latitude, longitude: res.longitude, }) } }) }, onLoad(options) { let that = this qqmapsdk = new QQMapWX({ key: 'HIDBZ-2QXL4-TAWUD-XET6Q-EKTJE-CCBSQ' }); qqmapsdk.reverseGeocoder({ success: (res) => { console.log('res', res); this.setData({ address: res.result.address, latitude: res.result.latitude, longitude: res.result.longitude, }) } }) wx.getLocation({ type: 'wgs84', success(res) { const latitude = res.latitude const longitude = res.longitude that.getShops(latitude, longitude) } }) }, getShops(latitude, longitude) { getShopPage({ model: { longitude, latitude } }).then(res => { this.setData({ shopList: res.data.records }) }) }, handleDetail(e) { const id = e.currentTarget.dataset.id wx.navigateTo({ url: `/pages/store/info?id=${id}`, }) }, userDetail(e) { const iamId = e.currentTarget.dataset.id wx.navigateTo({ url: `/pages/store/staff?id=${iamId}`, }) }, makePhone(e) { console.log('e', e); const phoneNumber = e.currentTarget.dataset.phone wx.makePhoneCall({ phoneNumber }) }, onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })