<template>
<view>
<!--pages/nearbyDetails/nearbyDetails.wxml-->
<map id="myMap" class="map" :latitude="lat" :longitude="lng" :markers="markers" show-location></map>
<view class="pdlr20">
	<view class="bgfff li r10">
		<view class="dflex cont">
			<view class="title flex">
				<view style="font-weight: bold;font-size:32rpx" class="mb20">{{title}}</view>
				<!-- <text style="font-size:24rpx">{{account}}</text> -->
			</view>
			<view class="yue dflex">
				<image src="/static/pages/images/nearby_icon.png" class="mr20" @tap="goNavigation"></image>
				<image src="/static/pages/images/nearby_icon1.png" @tap="makePhoneCall"></image>
			</view>
		</view>
	</view>
	<view class="bgfff li r10  ">
		<view class="dflex dizhi">
			<image src="/static/pages/images/position_icon.png"></image>
			店铺地址：
			<text>{{address}}</text>
		</view>
		<view class="phone dflex" @tap="makePhoneCall">
			<image src="/static/pages/images/phone.png"></image>
			联系电话：
			<text>{{phone}}</text>
		</view>
	</view>
	<view class="bgfff li r10  ">
		<view class="dflex time">
			<image src="/static/pages/images/nearbytime.png"></image>
			营业时间：
			<text>{{businessTime}}</text>
		</view>
		<!-- <view class="distribution dflex">
			<image src="/pages/images/distribution.png"></image>
			配送服务：
			<text>由蜂鸟提供配送服务</text>
		</view> -->
	</view>
	<!-- <view class="bgfff li r10 dflex qualifications">
		<view class="dflex foot">
			<image src="/pages/images/zizi.png"></image>
      查看运营资质
		</view>
		<view class="right">
    <image src="/pages/images/rico.png"></image>
		</view>
	</view> -->
</view>
</view>
</template>

<script>
// pages/nearbyDetails/nearbyDetails.js
const req = require("../../utils/request.js");
var QQMapWX = require("../../utils/qqmap.js");

export default {
  data() {
    return {};
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // console.log(options);
    this.id = options.id;
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getnearbyDetails();
  },
  methods: {
    getnearbyDetails() {
      // console.log(this.id);
      req.getRequest('/api/merchant/detail', {
        id: this.id
      }, data => {
        this.setData(data);
        let markers = {
          latitude: data.lat,
          longitude: data.lng,
          iconPath: "/static/pages/images/location.png"
        };
        this.setData({
          'markers[0].latitude': data.lat,
          'markers[0].longitude': data.lng,
          'markers[0].iconPath': "/static/pages/images/location.png"
        });
      });
      // console.log(this);
    },

    makePhoneCall() {
      uni.makePhoneCall({
        phoneNumber: this.phone
      });
    },

    // 导航
    goNavigation() {
      let plugin = requirePlugin('routePlan');
      let key = req.public.mapLBSKEY; //使用在腾讯位置服务申请的key

      let referer = req.getStorage('appName'); //调用插件的app的名称

      let endPoint = JSON.stringify({
        //终点
        'name': this.title,
        'latitude': this.lat,
        'longitude': this.lng
      });
      uni.navigateTo({
        url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint
      });
    }

  }
};
</script>
<style>
@import "./nearbyDetails.css";
</style>