123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- 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();
- },
- });
|