<template>
	<view class="supp-detail-container">
		<view class="supp-detail-info">
			<view class="supplier-detail-title">
				<view class="supplier-detail-title-text">
					{{detailData.name || '-'}}
				</view>
				<view class="supplier-detail-title-contacts">
					{{detailData.contactName || '-'}}
				</view>
			</view>
			<view class="supplier-detail-tel" @click="makeOhoneHandle">
				<u-icon name="phone"></u-icon>
				{{detailData.contactPhone || '-'}}
			</view>
		</view>
		<view class="supplier-detail-basic">
			<!-- <view class="supplier-detail-telphone" @click="makeOhoneHandle">
				<u-icon name="phone"></u-icon>
				<span style="margin-left: 10rpx;">{{detailData.contactPhone || '-'}}</span>
			</view> -->
			<view class="supplier-detail-address">
				<u-icon name="map"></u-icon>
				<span style="margin-left: 10rpx;">{{detailData.address || '-'}}</span>
			</view>
			<view class="supp-detail-scope-title">
				供应范围
			</view>
			<view class="supp-detail-scope-text">
				{{detailData.radius || '-'}}
			</view>
			<view class="supp-detail-annex-title">
				附件
			</view>
			<view class="supp-detail-annex-text">
				<image :src="img" v-for="(img, i) in detailData.urls" :key="i" class="supp-detail-annex-img"
					@click="imageHandle(i)"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				detailData: {},
			}
		},
		//第一次加载
		onLoad(options) {
			let data = decodeURIComponent(options.dataInfo)
			let detailData = JSON.parse(data)
			if (detailData.attachment) {
				detailData.urls = detailData.attachment.split(',')
			}
			this.detailData = detailData
		},
		onReady() {

		},
		//页面显示
		onShow() {

		},
		methods: {
			//拨打电话
			makeOhoneHandle() {
				uni.makePhoneCall({
					phoneNumber: this.detailData.contactPhone
				})
			},
			//唤起导航
			getLocalHandle() {
				if (this.detailData.lat && this.detailData.lng && this.detailData.address && this.detailData.name) {
					uni.openLocation({
						latitude: lat,
						longitude: lng,
						name: name,
						address: address
					})
				} else {
					this.$utils.msg("位置信息丢失");
				}
			},
			//点击图片
			imageHandle(data) {
				let _that = this;
				let list = [];
				_that.detailData.urls.forEach(item => {
					list.push(item)
				})
				uni.previewImage({
					urls: list,
					current: _that.detailData.urls[data]
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.supp-detail-container {
		height: 100vh;
		position: relative;
		box-sizing: border-box;
		background: $uni-bg-color;
		padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
		padding-top: 30rpx;

		.supp-detail-info {
			height: 160rpx;
			background: #FFFFFF;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			margin: 0 30rpx 30rpx;
			padding: 30rpx;

			.supplier-detail-title {
				display: flex;

				.supplier-detail-title-text {
					flex: 1;
					font-size: 30rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #1D2129;
					line-height: 44rpx;
				}

				.supplier-detail-title-contacts {
					font-size: 30rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #1D2129;
					line-height: 44rpx;
					text-align: right;
				}
			}

			.supplier-detail-tel {
				text-align: right;
				font-size: 26rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #86909C;
				line-height: 44rpx;
				margin-top: 20rpx;
			}
		}

		.supplier-detail-basic {
			background: #FFFFFF;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			margin: 0 30rpx 30rpx;
			padding: 30rpx;

			.supplier-detail-telphone {
				font-size: 30rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #1D2129;
				line-height: 44rpx;
			}

			.supplier-detail-address {
				font-size: 30rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #1D2129;
				line-height: 44rpx;
				margin-top: 20rpx;
			}

			.supp-detail-scope-title {
				font-size: 30rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 600;
				color: #1D2129;
				line-height: 44rpx;
				margin-top: 20rpx;
			}

			.supp-detail-scope-text {
				font-size: 30rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #1D2129;
				line-height: 44rpx;
				margin-top: 10rpx;
			}

			.supp-detail-annex-title {
				font-size: 30rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 600;
				color: #1D2129;
				line-height: 44rpx;
				margin-top: 20rpx;
			}

			.supp-detail-annex-text {
				display: flex;
				margin-top: 20rpx;
				width: 100%;
				flex-wrap: wrap;

				.supp-detail-annex-img {
					width: 120rpx;
					height: 120rpx;
					margin: 0 10rpx 10rpx 0;
				}
			}
		}
	}
</style>