<template>
	<view class="page flex-col align-center">
		<view class="group_1"></view>
		<view class="group_5 ">
			<view class="group_6 flex-row justify-between">
				<text class="text_17">{{ partnerInfo.partnerName }}</text>
			</view>
			<view class="group_7">
				<u-scroll-list :indicator="false">
					<view v-for="(item, index) in partnerInfo.shopImages" :key="index" class="group_8">
						<image :src="item" class="goodItemImg"></image>
					</view>
				</u-scroll-list>
			</view>
			<view class=" padding-left-sm padding-right-sm padding-top padding-bottom flex-row justify-between">
				<view><text class="text_18">营业时间</text>
					<text class="text_19">{{ partnerInfo.workTime }}</text>
				</view>

				<image class="label_5" mode="widthFix" :src="imagesUrl+'telIcon.png'" @click="call()" />
			</view>
			<view class="padding-left-sm padding-right-sm padding-bottom  flex-row justify-between"
				@click="$map.openMap(partnerInfo.partnerName, partnerInfo.latitude, partnerInfo.longitude)">
				<text>
					{{ partnerInfo.address }}
				</text>

				<image class="label_5" mode="widthFix" :src="imagesUrl+'location11.png'" />
			</view>

		</view>

		<view class="tabs self-start">
			<u-tabs :list="tabs" lineColor="transparent" :activeStyle="{
			            color: '#ff7019',
						fontSize: '34rpx'
			        }" :inactiveStyle="{
			            color: '#606266',
						fontSize: '34rpx'
			        }" itemStyle="padding-right: 20px; height: 34px;">
			</u-tabs>
		</view>

		<view class="goodList radius">
			<view class="goods radius" style="position: relative;" v-for="item,index in mallGoodsList" :key="index"
				@click="this.$tab.navigateTo('/subMallPages/goodInfo/goodInfo?id='+item.id)">
				<u--image class="goodImg" radius="10rpx" width="300rpx" height="220rpx" :showLoading="true"
					:src="item.image"
					@click="this.$tab.navigateTo('/subMallPages/goodInfo/goodInfo?id='+item.id)"></u--image>
				<view style="position: absolute; top: 20rpx; right: 20rpx;">
					<u-tag text="不参与会员折扣" type="warning" plain plainFill size="mini"
						v-if="item.isAttend !== '1'"></u-tag>
					<u-tag text="此商品参与会员折扣" type="warning" plain plainFill size="mini" v-else></u-tag>
				</view>
				<view class="carTitle">
					<text class="u-line-2">
						{{ item.title }}
					</text>
				</view>
				<view class="flex-row justify-between">
					<view class="">
						<text class="priceIcon">￥</text>
						<text class="priceNum">{{ item.lowPrice }}</text>
					</view>
					<view class="butBtn" @click="this.$tab.navigateTo('/subMallPages/goodInfo/goodInfo?id='+item.id)">查看
					</view>
				</view>
			</view>
			<view class="flex-col align-center justify-center margin" style="margin: 0 auto; min-height: 300rpx;"
				v-if="mallGoodsList.length == 0">
				<u-empty mode="list" textSize="32rpx" iconSize="160rpx">
				</u-empty>
			</view>
		</view>
		<!-- 分页 -->
		<view class="margin-top">
			<page-pagination :total="total" :currentPage="queryParams.pageNum" :showBorder="false" mode="simple"
				layout="prev,page,next" @change="changePageNum"></page-pagination>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				imagesUrl: getApp().globalData.config.imagesUrl,
				baseUrl: getApp().globalData.config.baseUrl,
				partnerInfo: {
					shopImages: []
				},
				tabs: [{
					name: '团购'
				}, {
					name: '评价',
				}],
				total: '', //总页数
				mallGoodsList: [],
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					partnerId: ''
				},
				mallPlatinum: 0, // 铂金会员级别
			};
		},
		onLoad(option) {
			this.queryParams.partnerId = option.partnerId
			this.getPartnerInfo()
			this.getConfig()
			this.getGoodsList()
		},
		methods: {
			async getPartnerInfo() {
				// /system/mallPartners
				const res = await this.$request({
					url: '/system/mallPartners/partnerInfo/' + this.queryParams.partnerId,
				})
				this.partnerInfo = res.data
				// 处理图片
				if (res.data.shopImages) {
					let shopImages = res.data.shopImages.split(',')
					for (let i = 0; i < shopImages.length; i++) {
						shopImages[i] = this.baseUrl + shopImages[i]
					}
					this.partnerInfo.shopImages = shopImages
				}
				uni.setNavigationBarTitle({
					title: res.data.partnerName
				})
				console.log(res);
			},
			// 获取商品列表
			async getGoodsList() {
				const res = await this.$request({
					url: '/system/mallGoods/listWx',
					data: this.queryParams
				})
				for (let i = 0; i < res.rows.length; i++) {
					res.rows[i].image = getApp().globalData.config.baseUrl + res.rows[i].image; // 处理图片拼接
				}
				this.total = res.total
				this.mallGoodsList = res.rows
				// console.log(this.mallGoodsList);
			},
			// 获取配置:铂金会员折扣
			async getConfig() {
				const res = await this.$request({
					url: '/system/shopconfig/listWx'
				})
				this.mallPlatinum = res.rows[0].mallPlatinum
				console.log('this.mallPlatinum', this.mallPlatinum);
			},
			// 分页切换
			changePageNum(pageNum, type) {
				this.queryParams.pageNum = pageNum;
				// console.log("点击了" + type + "，当前页：" + pageNum);
				this.getGoodsList()

			},
			call() {
				uni.makePhoneCall({
					phoneNumber: this.partnerInfo.contactNumber.toString(), //电话号码
					success: function(e) {
						console.log(e);
					},
					fail: function(e) {
						console.log(e);

					}
				})
			}
		},
	};
</script>
<style lang="scss" scoped>
	@import './index.rpx.css';

	.goodItemImg {
		border-radius: 10px;
		width: 327rpx;
		height: 216rpx;
	}

	.tabs {
		width: 700rpx;
		margin-left: 10rpx;
	}

	.goodList {
		margin: 0 auto;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		width: 700rpx;

		border-radius: 10rpx;

		.goods {
			width: 340rpx;
			padding: 20rpx;
			box-sizing: border-box;
			margin-top: 20rpx;
			background-color: #ffffff;


			.carTitle {
				width: 320rpx;
				margin: 20rpx 0;
			}

			.carAge {
				font-size: 12px;
				color: #b5b5b5;
				margin: 10rpx 0;
			}

			.goodImg {
				border-radius: 25rpx;
			}

			.butBtn {
				background: #FF7019;
				color: #fff;
				font-size: 24rpx;
				padding: 10rpx 20rpx;
				border-radius: 10rpx;
			}

			.priceIcon {
				font-size: 28rpx;
				color: #FF7019;
			}

			.priceNum {
				font-size: 40rpx;
				color: #FF7019;
			}

			.delPrice {
				margin-left: 10rpx;
				color: #B5B5B5;
				text-decoration: line-through;
			}
		}
	}
</style>