<template>
	<view class="center">
		<view class="store-info flex">
			<view class="store-top flex">
				<image class="simage" :src="info.logo" mode=""></image>
				<view class="stop-main">
					<view class="stop-title">{{ info.name }}</view>
				</view>
			</view>
			<view class="">

			</view>
		</view>
		<view class="store-item" v-if="info.mobile">
			<view class="store-font">预约电话：{{ info.mobile }}</view>
		</view>
		<view class="store-main" v-if="images != null">
			<view class="smain-title">店内照片</view>
			<scroll-view class="scroll-box flex" @scroll="scroll" scroll-x="true" :scroll-with-animation="true"
				scroll-left="10px">
				<view class="scroll-item" v-for="(item, index) in images" :key="index">
					<image class="scroll-image" :src="'https://shop.xianghuaqi.net.cn/'+item" mode="heightFix">
					</image>
				</view>
			</scroll-view>
		</view>
		<!-- <jyf-parser class="main" :html="art.content"></jyf-parser> -->
		<view class="" style="height: 100rpx;"></view>
		<view class="btn-box" v-if="info.mobile">
			<view class="btn-left" @click="tocall()">拨打电话</view>

			<!-- #ifdef H5 -->
			<view class="btn-right" @click="toGaodeMap()">导航到店</view>
			<!-- #endif -->
			<!-- #ifdef MP -->
			<view class="btn-right" @click="dh()">导航到店</view>
			<!-- #endif -->
			<!-- #ifdef APP-PLUS -->
			<view class="btn-right" @click="gomapApp(info.latitude, info.longitude, info.name)">导航到店</view>
			<!-- #endif -->
		</view>
		<view class="btn-box dhdd flex" v-if="!info.mobile">
			<!-- #ifdef H5 -->
			<view class="btn-right" @click="toGaodeMap()">导航到店</view>
			<!-- #endif -->
			<!-- #ifdef MP -->
			<view class="btn-right" @click="dh()">导航到店</view>
			<!-- #endif -->
			<!-- #ifdef APP-PLUS -->
			<view class="btn-right" @click="gomapApp(info.latitude, info.longitude, info.name)">导航到店</view>
			<!-- #endif -->
		</view>
	</view>
</template>

<script>
	import {
		getShopInfo
	} from '@/api/shop.js'
	export default {
		data() {
			return {
				id: '',
				info: {},
				images: [],
			};
		},

		onLoad(option) {
			let obj = this;
			this.id = option.id;
			this.getStoreDetail();
		},
		onShow() {},
		methods: {
			// 获取门店详情
			getStoreDetail() {
				let obj = this;
				console.log('进入');
				getShopInfo({
					shop_id: obj.id
				}).then(res => {
					obj.info = res.data
					obj.images = res.data.images.split(',')
					console.log(obj.images, '123456');
				});
			},
			scroll(e) {
				console.log(e, '123456');
			},
			tocall() {
				let num = this.info.mobile;
				console.log(num);
				uni.makePhoneCall({
					phoneNumber: num //仅为示例
				});
			},
			// 调用高德
			toGaodeMap() {
				let obj = this;
				window.location.href =
					`https://uri.amap.com/marker?position=${obj.info.longitude},${obj.info.latitude}&name=${obj.info.name}`;
			},
			// 导航
			dh() {
				let obj = this;
				wx.openLocation({
					latitude: obj.info.latitude * 1,
					longitude: obj.info.longitude * 1,
					name: obj.info.name,
					address: obj.info.detailed_address
				});
			},
			gomapApp(latitude, longitude, name) {
				let url = '';
				if (plus.os.name == 'Android') {
					//判断是安卓端
					plus.nativeUI.actionSheet({
							//选择菜单
							title: '选择地图应用',
							cancel: '取消',
							buttons: [{
								title: '腾讯地图'
							}, {
								title: '百度地图'
							}, {
								title: '高德地图'
							}]
						},
						function(e) {
							switch (e.index) {
								//下面是拼接url,不同系统以及不同地图都有不同的拼接字段
								case 1:
									//注意referer=xxx的xxx替换成你在腾讯地图开发平台申请的key
									url = `qqmap://map/geocoder?coord=${latitude},${longitude}&referer=xxx`;
									break;
								case 2:
									url =
										`baidumap://map/marker?location=${latitude},${longitude}&title=${name}&coord_type=gcj02&src=andr.baidu.openAPIdemo`;
									break;
								case 3:
									url =
										`androidamap://viewMap?sourceApplication=appname&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`;
									break;
								default:
									break;
							}
							if (url != '') {
								url = encodeURI(url);
								//plus.runtime.openURL(url,function(e){})调起手机APP应用
								plus.runtime.openURL(url, function(e) {
									plus.nativeUI.alert('本机未安装指定的地图应用');
								});
							}
						}
					);
				} else {
					// iOS上获取本机是否安装了百度高德地图，需要在manifest里配置
					// 在manifest.json文件app-plus->distribute->apple->urlschemewhitelist节点下添加
					//（如urlschemewhitelist:["iosamap","baidumap"]）
					plus.nativeUI.actionSheet({
							title: '选择地图应用',
							cancel: '取消',
							buttons: [{
								title: '腾讯地图'
							}, {
								title: '百度地图'
							}, {
								title: '高德地图'
							}]
						},
						function(e) {
							switch (e.index) {
								case 1:
									url = `qqmap://map/geocoder?coord=${latitude},${longitude}&referer=xxx`;
									break;
								case 2:
									url =
										`baidumap://map/marker?location=${latitude},${longitude}&title=${name}&content=${name}&src=ios.baidu.openAPIdemo&coord_type=gcj02`;
									break;
								case 3:
									url =
										`iosamap://viewMap?sourceApplication=applicationName&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`;
									break;
								default:
									break;
							}
							if (url != '') {
								url = encodeURI(url);
								plus.runtime.openURL(url, function(e) {
									plus.nativeUI.alert('本机未安装指定的地图应用');
								});
							}
						}
					);
				}
			}
		}
	};
</script>

<style lang="less">
	.center,
	page {
		background: #f8f8f8;
		height: 100%;
	}

	.dhdd {
		view {
			margin: 0 auto;
		}
	}

	.store-info {
		background: #ffffff;

		.store-top {
			padding: 40rpx 20rpx;
			justify-content: flex-start;

			.simage {
				width: 130rpx;
				height: 130rpx;
				background: #f44939;
			}

			.stop-main {
				height: 130rpx;
				padding: 6rpx 0;
				margin-left: 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: flex-start;

				.stop-title {
					font-size: 36rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #000000;
				}

				.stop-address {
					display: flex;
					justify-content: flex-end;
					align-items: center;

					.mrt-image {
						width: 20rpx;
						height: 28rpx;
					}

					.mrt-font {
						margin-left: 8rpx;
						font-size: 22rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #666666;
					}
				}
			}
		}
	}

	.store-item {
		background: #ffffff;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		padding: 30rpx 30rpx 30rpx 44rpx;

		.store-image1 {
			width: 36rpx;
			height: 36rpx;
		}

		.store-image2 {
			margin: 0 1rpx;
			width: 34rpx;
			height: 34rpx;
		}

		.store-image3 {
			margin: 0 7rpx;
			width: 22rpx;
			height: 28rpx;
		}

		.store-font {
			margin-left: 22rpx;
			font-size: 26rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #2d2d2d;
		}
	}

	.store-main {
		margin-top: 16rpx;
		background: #ffffff;
		padding: 30rpx 42rpx 40rpx;

		.smain-title {
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #464646;
		}
	}

	.scroll-box {
		white-space: nowrap;
		margin-top: 30rpx;
		height: 240rpx;

		.scroll-item:first-child {
			margin-left: 0;
		}

		.scroll-item {
			margin-left: 20rpx;
			display: inline-block;
			height: 240rpx;
			// width: 240rpx;
		}

		.scroll-image {
			height: 240rpx;
			// width: 240rpx;
		}
	}

	.btn-box {
		display: flex;
		justify-content: space-between;
		position: fixed;
		bottom: 0rpx;
		left: 0;
		right: 0;
		width: 750rpx;
		background: rgba(255, 255, 255, 0.6);
		box-shadow: 0rpx 0rpx 20rpx 0px rgba(50, 50, 52, 0.06);
		padding: 22rpx 68rpx;

		.btn-left {
			width: 280rpx;
			height: 80rpx;
			background: linear-gradient(180deg, #ffa30b, #ffd158);
			box-shadow: 0px 3rpx 13rpx 3rpx rgba(255, 164, 13, 0.48);
			border-radius: 40rpx;
			text-align: center;
			line-height: 80rpx;
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #ffffff;
		}

		.btn-right {
			width: 280rpx;
			height: 80rpx;
			background: linear-gradient(180deg, #ff6223, #ffab60);
			box-shadow: 0px 3rpx 13rpx 3rpx rgba(255, 164, 13, 0.48);
			border-radius: 40rpx;
			text-align: center;
			line-height: 80rpx;
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #ffffff;
		}
	}

	.popup_row {
		width: 100%;
		height: 500rpx;
		background-color: #ffffff;
		border-radius: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;

		.rows {
			width: 100%;
			padding: 0 24rpx;

			.rows-item {
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				width: 100%;
				font-size: 32rpx;
				color: #303133;
				// border-bottom: 1rpx solid #f0f0f0;
			}

			// .row-1 {
			// 	margin: auto;
			// 	.first_aid {
			// 		width: 300rpx;
			// 		height: 300rpx;
			// 	}
			// }
			// .row-2 {
			// 	font-size: 38rpx;
			// 	margin-top: 20rpx;
			// }
		}
	}

	.shop-dhq {
		width: 702rpx;
		height: 171rpx;
		box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.15);
		margin: auto;
		border-radius: 20rpx;
		background-color: #fff;
		padding: 0 48rpx 0 26rpx;
		margin-bottom: 20rpx;

		.dhq-left {
			.dhq-name {
				overflow: hidden;
				width: 28%;
				font-size: 28rpx;
				font-weight: bold;
				color: #333333;
			}

			.dhq-price {
				padding-top: 20rpx;

				.j-price {
					font-size: 38rpx;
					font-weight: bold;
					color: #ff4c4c;

					&::before {
						content: '￥';
						font-size: 24rpx;
						color: #ff4c4c;
					}
				}

				.j-zk {
					margin: 10rpx;
					display: inline-block;
					margin-left: 10rpx;
					line-height: 32rpx;
					height: 32rpx;
					border: 1px solid #ff4c4c;
					border-radius: 5rpx;
					font-size: 22rpx;
					font-weight: 500;
					color: #ff4c4c;
					padding: 0 8rpx;
				}
			}
		}

		.dhq-right {
			.right-btn {
				width: 105rpx;
				line-height: 56rpx;
				background: linear-gradient(143.2747deg, #ff6a00, #ee0979);
				border: 1rpx solid #ff4c4c;
				border-radius: 27rpx;
				text-align: center;
				color: #fff;
				font-size: 28rpx;
				font-weight: bold;
			}
		}
	}

	.jx-box-content {
		display: flex;

		.content-left {
			margin: 20rpx 15rpx;
			width: 236rpx;
			height: 236rpx;
			background: #e2e2e2;
			border-radius: 10rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.content-right {
			display: flex;
			flex-direction: column;
			justify-content: space-around;

			.shop-name {
				width: 382rpx;
				font-size: 32rpx;
				font-weight: bold;
				color: #333333;

				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
			}

			.shop-content {
				width: 455rpx;
				display: flex;
				justify-content: space-between;

				.shop-content-left {
					display: flex;
					flex-direction: column;

					.price-box {
						display: flex;
						align-items: center;

						.yuan-price {
							font-size: 26rpx;
							font-weight: 500;
							text-decoration: line-through;
							color: #999999;
						}

						image {
							margin: 0 10rpx;
							width: 16rpx;
							height: 18rpx;
						}

						.j-price {
							font-size: 24rpx;
							font-weight: bold;
							color: #b59467;
						}
					}

					.price-x {
						font-size: 36rpx;
						font-weight: bold;
						color: #ff4c4c;
					}
				}

				.shop-content-right {
					margin-top: 20rpx;
					align-items: center;
					text-align: center;
					width: 137rpx;
					height: 52rpx;
					font-size: 26rpx;
					font-weight: 500;
					color: #fff;
					background: #f75022;
					border-radius: 26rpx;
					line-height: 52rpx;
				}
			}
		}
	}

	.popup-box {
		width: 500rpx;
		background: #ffffff;
		border-radius: 20rpx;
		padding: 50rpx 0 20rpx;

		.title {
			text-align: center;
			font-size: 32rpx;
			font-weight: 500;
		}

		.input {
			background: #e8e8e8;
			width: 300rpx;
			margin: 50rpx auto 0;
			padding: 10rpx;
		}

		.nocancel {
			margin-top: 20rpx;
			text-align: center;
			font-size: 28rpx;
			font-weight: 500;
		}

		.comfirm-box {
			margin-top: 80rpx;
			display: flex;
			width: 100%;
			align-items: center;

			.cancel {
				width: 50%;
				text-align: center;
				font-size: 28rpx;
				font-weight: 500;
			}

			.comfirm {
				width: 50%;
				text-align: center;
				font-size: 28rpx;
				font-weight: 500;
				color: #fe4a4a;
			}
		}
	}

	.main {
		padding: 10rpx;
		display: flex;
		flex-direction: column;
	}

	/deep/ .main {
		.rich-img {
			width: 100% !important;
			height: auto;
		}
	}
</style>