import { storeDetail } from '../../api/other'; import { MAKE_PHONE_CALL,REPORT_BEHAVIOR } from '../../utils/util.js'; // import amapFile from '../../utils/amap-wx.130.js'; Page({ data: { dataInfo:{}, latitude:0, longitude:0, id:'',//门店id }, onLoad(options) { this.setData({ id:options.id }) wx.getLocation({ type: 'wgs84', success: (res) => { this.setData({ latitude: res.latitude, longitude: res.longitude }) this.loadData(options.id) }, fail: (err) => { wx.showModal({ title: '提示', content: '获取定位失败,请检查是否开启定位权限', showCancel: false, confirmText: '我知道了' }) this.loadData(options.id) } }) }, async loadData(id){ const res = await storeDetail(id,{longitude:this.data.longitude,latitude:this.data.latitude}); if(res.code == 200){ this.setData({ dataInfo:res.data }) }else{ wx.showToast({ title: res.message || '加载失败', icon: 'none' }); } }, onAddress(){ REPORT_BEHAVIOR('门店导航', { link_id: this.data.id }) wx.openLocation({ latitude: this.data.dataInfo.latitude * 1, // 纬度 longitude: this.data.dataInfo.longitude * 1, // 经度 name:this.data.dataInfo.name, address: this.data.dataInfo.address, }) }, onPhone(){ MAKE_PHONE_CALL(this.data.dataInfo.phone); }, })