<template>
	<view class="com-course-address" v-if="course">
		<view class="address">
			<view class="time">
				<view class="icon"><image src="/static/images/timer.png" class="img"></image></view>
				<view class="tips">时间：{{course.openTime}}</view>
			</view>
			<view class="time">
				<view class="icon"><image src="/static/images/local.png" class="img"></image></view>
				<view class="tips" @click="onOpenMap">地址：{{course.address}}</view>
			</view>
		</view>
		<view class="service">
			<view class="icon">
				<image src="/static/images/customservice.png" class="img"></image>
			</view>
			<view class="tips">
				客服
			</view>
		</view>
		<map id="map" ref="map" style="display: none;"  v-if="course && course.id>0" :show-location="true" :latitude="course.latitude" :longitude="course.longitude"></map>
	</view>
</template>

<script>
	export default {
		name:"CourseAddress",
		props:{
			 
			course:{
				type:Object,
				default:()=>{
					return null;
				}
			}
		},
		
	
		data() {
			return {
				
			};
	
		},
		methods:{
			
			onOpenMap(e){
			  let _this=this;  
			  _this._mapContext = uni.createMapContext("map", _this); 
			  _this._mapContext.openMapApp({
				  longitude:parseFloat(_this.course.longitude),
				  latitude:parseFloat(_this.course.latitude),
				  destination:_this.course.address,
				  success:(res)=>{ 
				  },
				  fail:(res)=>{ 
					  
				  },
				  complete:(res)=>{
					  
				  }
			  }) 
			
			}
			}
	}
</script>

<style lang="scss">
@import './CourseAddress.scss'
</style>