<template>
	<view class="page">
		<u-checkbox-group @change="checkboxGroupChange">
			<view class="item u-flex" v-for="(item,index) in list" :key="index">
				<u-checkbox @change="checkboxChange" shape="circle" v-model="item.checked"></u-checkbox>
				<view class="box">
					<image :src="item.image" style="width: 120rpx ;height: 160rpx;" mode=""></image>
				</view>
				<view class=""
					style="justify-content: space-between;padding: 4rpx 0 ;height: 160rpx;display: flex;flex-direction: column;">
					<view class="">
						<view class="title u-line-1">{{item.title}}</view>
						<view class="writer">资源类型：付费资源</view>
					</view>
					<view class="money">¥{{item.entity_price}}</view>
				</view>
			</view>
		</u-checkbox-group>
		<view class="" style="height: 160rpx;"></view>
		<view class="bottom u-flex u-row-between">
			<view class="u-flex">
				<view class="" @click="checkedAll">
					<u-checkbox-group>
						<u-checkbox shape="circle" v-model="all"></u-checkbox>
					</u-checkbox-group>
					<text class="All">全选</text>
				</view>
				<view class="" style="margin-left: 24rpx;">
					<view class="">
						<text class="all">合计：</text>
						<text class="mi">¥</text>
						<text class="mi" style="font-size: 36rpx;">325.00</text>
					</view>
					<view class="">
						<text class="num">12</text>
						<text class="fcai">份资料</text>
					</view>
				</view>
			</view>
			<view class="btn" @click="orderinfo">
				下载资源
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				change: 0,
				all: false,
				list: [],
				series_id: ''
			};
		},
		onLoad(options) {
			this.series_id = options.id
			this.getSeriesBooks()
		},
		methods: {
			checkboxChange(e) {
				console.log(e);
			},
			// 系列列表
			getSeriesBooks() {
				this.$u.post('api/books/getSeriesBooks', {
					series_id: this.series_id
				}).then(res => {
					this.list = res.data
					this.list.map(item => {
						item.checked = false
					})
				})
			},
			//订单确认
			orderinfo() {
				this.$u.post('', {
					goods_id: '',
					type: ''
				}).then(res => {
					if (res.code == 1) {
						setTimeout(() => {
							uni.navigateTo({
								url: '/pages/index/orderinfo'
							})
						}, 800)
					}
				})
			},
			//全选
			checkedAll() {
				if (this.all == true) {
					this.list.map(val => {
						val.checked = false;
						this.all = true
						console.log(111);
					})
				} else {
					this.list.map(val => {
						val.checked = true;
						this.all = false
						console.log(222);
					})
				}
				console.log('all', this.all);
			},
			checkboxGroupChange(e) {
				console.log(e);
				if (e.length == this.list.length) {
					this.all = true
				}
				this.list.map(val => {
					if (val.checked == false) {
						this.all = false
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.num {
		font-size: 28rpx;
		font-family: JDZhengHT, JDZhengHT;
		font-weight: 400;
		color: #CF1534;
	}

	.fcai {
		font-size: 24rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		color: #131415;
	}

	.All {
		font-size: 24rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		color: #888888;
		margin-left: -16rpx
	}

	.mi {
		font-size: 28rpx;
		font-family: JDZhengHT, JDZhengHT;
		font-weight: 400;
		color: #CF1534;
	}

	.all {
		font-size: 26rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		color: #131415;
	}

	.btn {
		width: 252rpx;
		height: 88rpx;
		background: #06A971;
		border-radius: 12rpx;
		font-size: 32rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		line-height: 88rpx;
		text-align: center;
	}

	.money {
		font-size: 32rpx;
		font-family: SFPro, SFPro;
		font-weight: 400;
		color: #CF1534;
	}

	.title {
		width: 402rpx;
		font-size: 28rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 500;
		color: #222222;
	}

	.writer {
		font-size: 24rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		color: #444444;
		margin-top: 12rpx;
	}

	.box {
		width: 160rpx;
		height: 160rpx;
		border: 1rpx solid rgba(151, 151, 151, 0.1);
		padding: 0 20rpx;
	}

	.bottom {
		width: 100%;
		height: 166rpx;
		background: #FFFFFF;
		position: fixed;
		bottom: 0;
		left: 0;
		padding: 0 28rpx;
	}

	.item {
		width: 100%;
		height: 216rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin-top: 20rpx;
		padding: 28rpx 24rpx;
	}

	.page {
		background-color: #f4f4f4;
		min-height: 100vh;
		padding: 0 28rpx;
		overflow: hidden;
	}
</style>