<template>
	<view>
		
		<swiper class="screen-swiper square-dot" :indicator-dots="true" :circular="true"
		 :autoplay="true" interval="5000" duration="500">
			<swiper-item v-for="(item,index) in agent.picall" :key="index">
				<image :src="item" mode="aspectFill"></image>
			</swiper-item>
		</swiper>
		
		<view class="bg-white padding text-xl text-black text-bold margin-bottom-sm">
			{{agent.title}}
		</view>
		
		<view class="cu-list menu margin-bottom-sm sm-border">
			<view class="cu-item arrow">
				<view class="content">
					<text class="cuIcon-phone text-grey"></text>
					<text class="text-grey">门店电话</text>
				</view>
				<view class="action" @tap="makePhone()">
					<text class="text-grey">{{agent.telephone}}</text>
				</view>
			</view>
			<view class="cu-item">
				<view class="content">
					<text class="cuIcon-similar text-grey"></text>
					<text class="text-grey">所在市区</text>
				</view>
				<view class="action">
					<text class="text-grey">{{agent.province}} {{agent.city}} {{agent.district}}</text>
				</view>
			</view>
			<view class="cu-item arrow">
				<view class="content">
					<text class="cuIcon-location text-grey"></text>
					<text class="text-grey">详细地址</text>
				</view>
				<view class="action basis-lg text-right text-cut" @tap="setAddress()">
					<text class="text-grey">{{agent.address}}</text>
				</view>
			</view>
		</view>
		
		<view class="cu-bar bg-white solids-bottom">
			<view class="action">
				<text class="cuIcon-titles text-blue"></text> 门店介绍
			</view>
		</view>
		<view class="echo-article-details bg-white margin-bottom-sm">
			<u-parse :content="agent.details" noData="详情内容..." @navigate="navigate"></u-parse>
		</view>
	
	</view>
</template>

<script>
	import uParse from '@/components/gaoyia-parse/parse.vue';
	var _this;
	export default {
		components: {
			uParse
		},
		data() {
			return {
				userinfo: {},
				agent: {}
			}
		},
		onLoad: function(option) {
			_this = this;
			var agentid = option.agentid || 0;
			_this.userinfo = uni.getStorageSync('userinfo');
			_this.$req.ajax({
				path: "agent/getagent",
				data: {
					agentid: agentid
				}
			}).then((data) => {
				_this.agent = data.agent;
			}).catch((err) => {
				uni.showModal({
					title: '信息提示',
					content: err,
					showCancel: false
				});
			});
		},
		onShareAppMessage: function(res) {
			return {
				title: _this.agent.title,
				path: "/pages/agent/detail?agentid="+_this.agent.id
		    }
		},
		methods: {
			setAddress: function() {
				uni.openLocation({
					latitude: parseFloat(_this.agent.latitude),
					longitude: parseFloat(_this.agent.longitude),
					name: _this.agent.agentname,
					address: _this.agent.city + " " + _this.agent.district + " " + _this.agent.address,
					success: function () {
						console.log('success');
					}
				});
			},
			makePhone: function() {
				uni.makePhoneCall({
					phoneNumber: _this.agent.telephone
				});
			},
			goPage: function(pageurl) {
				uni.navigateTo({
					url: pageurl,
					fail: function(){
						uni.switchTab({
						    url: pageurl
						});
					}
				});
			},
			goDetail: function(partjobid) {
				uni.navigateTo({
					url: '/pages/partjob/detail?partjobid=' + partjobid
				});
			},
			navigate: function(href, e) {
				// #ifdef H5
				location.href = href;
				// #endif
				// #ifndef H5
				uni.navigateTo({
					url: '/pages/tool/webview?pagesrc=' + encodeURIComponent(href)
				});
				// #endif
			}
		}
	}
</script>

<style lang="scss">
</style>
