<template>
	<div>
		<view class='group-list'>
			<view class='iconfont icon-xiangzuo' @tap='goBack' :style="'top:'+ (navH/2) +'rpx'"></view>
			<view class='header'></view>
			<view class='list'>
				<block v-for="(item,index) in combinationList" :key='index'>
					<view class='item acea-row row-between-wrapper' @tap="openSubcribe(item)"
					 data-url=''>
						<view class='pictrue'>
							<image :src='item.image'></image>
						</view>
						<view class='text'>
							<view class='line1'>{{item.title}}</view>
							<view class='acea-row'>
								<view class='team acea-row row-middle cart-color'>
									<view class='iconfont icon-pintuan'></view>
									<view class='num'>{{item.people}}人团</view>
								</view>
							</view>
							<view class='bottom acea-row row-between-wrapper'>
								<view class='money'>￥<text class='num'>{{item.price}}</text><text class='y-money'>￥{{item.product_price}}</text></view>
								<view class='groupBnt bg-color'>去拼团<text class="iconfont icon-jiantou"></text></view>
							</view>
						</view>
					</view>
				</block>
			</view>
		</view>
	</div>
</template>

<script>
	import {
		getCombinationList
	} from '@/api/activity.js';
	import {
		openPinkSubscribe
	} from '../../../utils/SubscribeMessage.js';
	let app = getApp();
	export default {
		data() {
			return {
				navH: '',
				combinationList: [],
				limit: 10,
				page: 1,
				loading: false,
				loadend: false,
			}
		},
		onLoad() {
			uni.setNavigationBarTitle({
				title:"拼团列表"
			})
			this.navH = app.globalData.navHeight;
			this.getCombinationList();
		},
		methods: {
			goBack: function() {
				uni.navigateBack();
			},
			openSubcribe: function(item) {
				let page = item;
				// #ifndef MP
				uni.navigateTo({
					url: `/pages/activity/goods_combination_details/index?id=${item.id}`
				});
				// #endif
				// #ifdef MP
				uni.showLoading({
					title: '正在加载',
				})
				openPinkSubscribe().then(res => {
					uni.hideLoading();
					uni.navigateTo({
						url: `/pages/activity/goods_combination_details/index?id=${item.id}`
					});
				}).catch(() => {
					uni.hideLoading();
				});
				// #endif
			},
			getCombinationList: function() {
				var that = this;
				if (that.loadend) return;
				if (that.loading) return;
				var data = {
					page: that.page,
					limit: that.limit
				};
				this.loading = true
				getCombinationList(data).then(function(res) {
					var combinationList = that.combinationList;
					var limit = that.limit;
					that.page++;
					that.loadend = limit > res.data.length;
					that.combinationList = combinationList.concat(res.data);
					that.page = that.data.page;
					that.loading = false;
				}).catch(() => {
					that.loading = false
				})
			},
		},
		onReachBottom: function() {
			this.getCombinationList();
		},
	}
</script>

<style>
	page {
		background-color: #fa533d !important;
	}

	.icon-xiangzuo {
		font-size: 40rpx;
		color: #fff;
		position: fixed;
		left: 30rpx;
		z-index: 99;
		transform: translateY(-20%);
	}

	.group-list .header {
		background-image: url('data:image/png;base64,[encoded data, 72636 characters]');
		background-repeat: no-repeat;
		background-size: 100% 100%;
		width: 100%;
		height: 450rpx;
	}

	.group-list .list {
		margin-top: -108rpx;
	}

	.group-list .list .item {
		width: 690rpx;
		height: 208rpx;
		background-color: #fff;
		border-radius: 6rpx;
		padding: 0 24rpx;
		box-sizing: border-box;
		margin: 0 auto 20rpx auto;
	}

	.group-list .list .item .pictrue {
		width: 160rpx;
		height: 160rpx;
	}

	.group-list .list .item .pictrue image {
		width: 100%;
		height: 100%;
		border-radius: 6rpx;
	}

	.group-list .list .item .text {
		width: 458rpx;
		font-size: 30rpx;
		color: #282828;
	}

	.group-list .list .item .text .team {
		height: 38rpx;
		border-radius: 4rpx;
		font-size: 22rpx;
		margin-top: 20rpx;
	}

	.group-list .list .item .text .team .iconfont {
		width: 54rpx;
		background-color: #ffdcd9;
		text-align: center;
		color: #dd3823;
		height: 100%;
	}

	.group-list .list .item .text .team .num {
		text-align: center;
		padding: 0 6rpx;
		height: 100%;
	}

	.group-list .list .item .text .bottom {
		margin-top: 7rpx;
	}

	.group-list .list .item .text .bottom .money {
		font-size: 24rpx;
		font-weight: bold;
		color: #282828;
	}

	.group-list .list .item .text .bottom .money .num {
		font-size: 32rpx;
	}

	.group-list .list .item .text .bottom .money .y-money {
		font-size: 24rpx;
		color: #999;
		font-weight: normal;
		text-decoration: line-through;
		margin-left: 10rpx;
	}

	.group-list .list .item .text .bottom .groupBnt {
		font-size: 26rpx;
		color: #fff;
		width: 146rpx;
		height: 54rpx;
		text-align: center;
		line-height: 54rpx;
		border-radius: 4rpx;
	}

	.group-list .list .item .text .bottom .groupBnt .iconfont {
		font-size: 25rpx;
		vertical-align: 2rpx;
		margin-left: 10rpx;
	}
</style>
