| | |
| | | // pages/store/store.js |
| | | 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)=> { |
| | | success: (res) => { |
| | | this.setData({ |
| | | city: res.name |
| | | address: res.address, |
| | | latitude: res.latitude, |
| | | longitude: res.longitude, |
| | | }) |
| | | console.log('res', res); |
| | | } |
| | | }) |
| | | }, |
| | | 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}`, |
| | | }) |
| | | }, |
| | | makePhone(e) { |
| | | console.log('e', e); |
| | | const phoneNumber = e.currentTarget.dataset.phone |
| | | wx.makePhoneCall({ phoneNumber }) |
| | | }, |
| | | onReady() { |
| | | |
| | | }, |