<template>
	<view>
		<view class="banner">
			<view class="banner-item info">
				<view class="info-title">
					{{tableData.advertisingName}}
				</view>
				<view class="info-text">{{tableData.shopDescription}}</view>
				<view class="info-racord" v-if="moban.length !=0">
					<view class="info-price"><span>{{moban[0].rentalPrice || ''}}</span>元/{{moban[0].leaseTerm || ''}}
					</view>
					<!-- <view class="info-intention">{{tableData.id}}人有意向</view> -->
				</view>
				<view class="" v-if="moban.length !=0" @click="moreZu">
					查看更多租金优惠
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="banner-item field">
				<view class="banner-item-title">基础信息</view>
				<view class="banner-item-form">
					<u-row gutter="16">
						<u-col span="7">
							<view class="form-item">
								<view class="label">广告位类型：</view>
								<text>{{tableData.advertisingType}}</text>
							</view>
						</u-col>
						<u-col span="5">
							<view class="form-item">
								<view class="label">所属端：</view>
								<text>{{tableData.affiliation || '--'}}</text>
							</view>
						</u-col>
						<u-col span="7">
							<view class="form-item">
								<view class="label">轮播顺序：</view>
								<text>{{tableData.rotationOrder || '--'}}</text>
							</view>
						</u-col>
					</u-row>
				</view>
			</view>
			<view class="banner-item">
				<view class="banner-item-title">广告信息</view>
				<view class="banner-item-form">
					<u-row gutter="16">
						<u-col span="7">
							<view class="form-item">
								<view class="label">广告尺寸：</view>
								<text>{{tableData.dimensions || '--'}}</text>
							</view>
						</u-col>
						<u-col span="5">
							<view class="form-item">
								<view class="label">可上传大小：</view>
								<text>{{tableData.size || '--'}}</text>
							</view>
						</u-col>
						<u-col span="7">
							<view class="form-item">
								<view class="label">位置示意图：</view>
							</view>
						</u-col>
						<u-col span="12">
							<view style="display: flex;flex-wrap: wrap;">
								<u-image @click="openimg(tableData.locationDiagram,index)" :showLoading="true" v-for="(item,index) in list(tableData.locationDiagram)"
									v-if="tableData.locationDiagram" :src="imgUrl+item" width="90px" height="90px"
									border-radius="20" style="margin-bottom:25rpx;margin-left: 25rpx;"></u-image>
								<text v-else>暂无</text>
							</view>
							<!-- <image :src="imgurl+tableData.locationDiagram" width="100%"></image> -->
						</u-col>
					</u-row>
				</view>
			</view>
		</view>
		<view style="height: 100rpx;"></view>
		<!-- 底部 -->
		<view class="page-footer">
			<!-- <view class="footer-service">
			<u-image :showLoading="true" :src="$imgUrl('/sevice-icon.png')"  width="30rpx" height="30rpx"></u-image>
			<text>客服</text>
		</view> -->
			<view class="footer-btn">
				<!-- <u-button type="primary" @click="leaseAdd('/pages/intentionApply/intentionApply')"  style="margin-right:10px;height: 35px;">意向申请</u-button> -->
				<u-button type="success" style="width: 100%;border-radius: 10px;"
					@click="leaseAdd('/pages/advertisementAdd/advertisementAdd')">租赁申请</u-button>
				<!-- <u-button type="success" style="margin-left: unset;" @click="leaseAdd">广告申请</u-button> -->
			</view>
			<!-- <view class="footer-service">
			<u-image :showLoading="true"  :src="$imgUrl('/share-icon.png')"  width="30rpx" height="30rpx"></u-image>
			<text>分享</text>
		</view> -->

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tableData: {},
				swiperList: [{
					id: 0,
					type: 'image',
					url: this.$imgUrl('/img/1.jpg')
				}],
				latitude: 39.909,
				longitude: 116.39742,
				moban: [],
				resourcesId: '',
				imgurl: '',
				imgUrl: this.$img,
			};
		},
		onLoad(option) {
			this.imgurl = this.$img
			let data = JSON.parse(option.item)
			console.log(data)
			this.tableData = data;
			this.resourcesId = `gg${data.id}`
			let paesize = {
				pageNumber: 0,
				pageSize: 10,
				resourcesId: `gg${data.id}`
			}
			this.$http.sendRequest('/cereResourceStrategy/queryByResources', 'POST', paesize, 1).then(res => {

				this.moban = res.data.data
			}).catch(err => {
				console.log(err)
				//请求失败
			})
		},
		methods: {
			openimg(urls,index) {
				urls =urls.split(',')
				let list = urls.map(item=>{
					return this.imgUrl + item
				})
				uni.previewImage({
					current:index,
					urls: list,
					longPressActions: {
						itemList: ['发送给朋友', '保存图片', '收藏'],
						success: function(data) {
							console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			},
			list(list) {
				const imgs = list.split(',')
				return imgs
			},
			leaseAdd(url) {

				this.$http.sendRequest('/cerePlatformMerchant/queryByPage', 'POST', {
					"pageSize": 10,
					pageNumber: 0,
					phone: uni.getStorageSync('user').phone
				}).then(res => {
					if (res.data.code == '20004' || res.data.code == '20003') {
						uni.navigateTo({
							url: '/pages/login/login'
						})

					}
					if (res.data.data.content.length > 0) {
						let c1 = res.data.data.content[0]

						if (c1.checkState == '1') {
							uni.showToast({
								icon: 'none',
								title: '商家申请正在审核中',
								duration: 3000
							});
						} else if (c1.checkState == '3') {
							uni.showToast({
								icon: 'none',
								title: '商家申请审核已被拒绝 请重新提交',
								duration: 3000
							});
							setTimeout(() => {
								uni.navigateTo({
									url: '/pagesA/leaseAdd/leaseAdd'
								})
							}, 3000)
						} else if (c1.checkState == '2') {
							uni.navigateTo({
								url: `${url}?ids=${this.tableData.id}&type=${this.tableData.advertisingType}`
							})
						}
					} else {
						uni.showToast({
							icon: 'none',
							title: '请先申请成为商家',
							duration: 3000
						});
						setTimeout(() => {
							uni.navigateTo({
								url: '/pagesA/leaseAdd/leaseAdd'
							})
						}, 3000)
					}
				})
			},
			moreZu() {
				uni.navigateTo({
					url: `/pagesA/moreZu/moreZu?resourcesId=${this.resourcesId}`
				})
			},
		}
	};
</script>

<style scoped lang="scss">
	@import 'advertisementDetail.scss';
</style>