import shopApi from '../../../api/shop'; import userApi from '../../../api/user'; const app = getApp(); Page({ /** * 页面的初始数据 */ data: { isShowConfirm:false, productId:'', detail:{}, productList:[], currentProduct:{}, calculatedPrice:{}, calculating:false, scrollViewHeight:0, windowInfo:{}, markdown:null }, showConfirm(event){ const currentProduct = event.currentTarget.dataset.item; const orderConfirm = this.selectComponent("#merchantOrderConfirm"); orderConfirm.preOrder(currentProduct); }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.data.productId = options.id; // app.getLocation().then((data)=>{ // this.getDetail(data.longitude,data.latitude); // }).catch(()=>{ this.getDetail(); // }) }, getDetail(lng,lat){ shopApi.product.detail(this.data.productId,lng,lat).then((data)=>{ if(data.distance){ if(data.distance>=1000){ data.distance = parseFloat(data.distance/1000).toFixed(1)+'km'; }else{ data.distance+='m'; } } this.setData({ detail:data }); }); }, navToMap(){ wx.openLocation({ name:this.data.detail.name, address:this.data.detail.address, latitude: this.data.detail.latitude, longitude: this.data.detail.longitude, }) }, makePhoneCall(){ wx.makePhoneCall({ phoneNumber:this.data.detail.phone, }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })