var app = getApp(); var util = require("../../utils/util.js"); let wxParse = require("../../wxParse/wxParse.js"); Page({ /** * 页面的初始数据 */ data: { obj: {}, appAssetsUrl2: app.appAssetsUrl2, content: "", covers: [ { id: 1, latitude: "", longitude: "", }, ], latitude: null, longitude: null, imglist: [], current: 0, lon: null, lat: null, calculateNew: 0, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { // this.setData({ // expertId: options.expertId, // meetId: options.meetId, // }) this.getStore(options.lon, options.lat, options.id); this.getDetail(options.id); }, ok() { wx.switchTab({ url: "/pages/home/index/index", }); }, changeSwiper(e) { let { current, source } = e.detail; if (source === "autoplay" || source === "touch") { this.setData({ current: current, }); } // this.setData({ // current: e.detail.current // }) }, getStore(lon, lat, id) { let that = this; app._get( "store/storeRecommendation", { lon: lon, lat: lat, id: id }, function (res) { if (res.code == 0 && res.data) { // let val = res.data.calculateNew / 1000; // let formatVal = parseInt(val * 10); let val = res.data.calculateNew > 1000 ? (res.data.calculateNew / 1000).toFixed(2) + "KM" : res.data.calculateNew + "M"; that.setData({ // shopObj: res.data, // calculateNew: formatVal/10, calculateNew: val, }); } } ); }, getDetail(id) { let that = this; app._get("store/info/" + id, {}, function (res) { // let val = res.store.calculateNew / 1000; let [latitude, longitude] = [ res.store.coordinate.split(",")[1], res.store.coordinate.split(",")[0], ]; let val = res.store.calculateNew > 1000 ? (res.store.calculateNew / 1000).toFixed(2) + "KM" : res.store.calculateNew + "M"; if (res.code == 0) { that.setData({ obj: res.store, "obj.calculateNew": val, // "obj.calculateNew": val.toFixed(1), imglist: res.store.storePhoto.split(","), latitude, longitude, covers: [ { id: 1, latitude: latitude, longitude: longitude, }, ], }); wxParse.wxParse("content", "html", res.store.introduce, that, 0); } }); }, // 查看地图 goLocal() { let that = this; let [latitude, longitude] = [ this.data.obj.coordinate.split(",")[0], this.data.obj.coordinate.split(",")[1], ]; // console.log(Number(latitude),Number(longitude)) wx.openLocation({ latitude: Number(longitude), longitude: Number(latitude), name: that.data.obj.name, address: that.data.obj.address, success: function () { // console.log("success"); }, }); }, callPhone() { let that = this; wx.makePhoneCall({ phoneNumber: that.data.obj.phone, }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () {}, /** * 生命周期函数--监听页面显示 */ onShow: function () {}, /** * 生命周期函数--监听页面隐藏 */ onHide: function () {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () {}, showShareMenu: function () { wx.showShareMenu(); }, hideShareMenu() { wx.hideShareMenu(); }, });