import { storeDetail } from '../../api/other'; import { MAKE_PHONE_CALL } from '../../utils/util.js'; Page({ data: { dataInfo:{}, latitude:0, longitude:0 }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { 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' }); } }, onPhone(){ MAKE_PHONE_CALL(this.data.dataInfo.phone); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })