<template>
	<view>
		<view style="background-color: #FFFFFF;">
			<view >
				<image :src="$method.splitImgHost(goodsData.coverUrl, true)" style="width: 100%;"></image>
				<view style="padding:20rpx">
					<view style="display: flex;margin-top: 13rpx;">
						<view class="yearTag">{{goodsData.createTime | formatDate}}</view>
						<view class="titleTag">{{goodsData.goodsName}}</view>
					</view>
					<view style="display: flex;justify-content: space-between;margin-top: 13rpx;">
						<view class="noteTag"><image src="/static/icon/wk_icon1.png" class="wk_icon"></image>
						共 <text class="blackFont">{{goodsData.updateTime}}</text> 张卷 <text class="blackFont">1200</text> 道题  </view>
						
					</view>
				</view>
			</view>
			<u-line color="#D6D6DB" />
			<view>
				<view>
					<u-tabs :list="list" item-width="50%" font-size="24" bar-width="110" :current="current" @change="change" active-color="#007AFF"></u-tabs>
				</view>
			</view>
			<u-line color="#D6D6DB" />
		</view>
		<view class="intro" v-if="current == 0">
			<view class="content">
				<view class="top">本题库为广东省建筑施工企业安全生产管理人员安全生产考试第三批参考题库（可两行）</view>
				<image class="img"  src="/static/intro.png" ></image>
			</view>
		</view>
		<view class="title-list"  v-if="current == 1">
			<view class="content">
				<view class="list" v-for="(item1,index) in outline">
					<view class="module">
						.2Z106000 施工合同管理-模块标题
					</view>
					<view class="section" :data-index="index" @click="changeItem" :class="{up:!item1.showList}">
						2Z106010 施工承发包的模式-2Z106020 施工合同...
					</view>
					<view class="article" v-if="item1.showList" :class="{active:index1 == 0}" v-for="(article,index1) in item1.list">
						施工承发包模式-施工合同与物资采购合同二
						<navigator url="/pages2/bank/questionBankTest">
							<view v-if="index1 == 0" class="btn">试做</view>
						</navigator>
						
					</view>
				</view>
				
				<view class="list">
					<view class="section" :data-index="index" @click="changeItem">
						2Z106010 施工承发包的模式-2Z106020 施工合同...
					</view>
					<view class="article" :class="{active:index1 == 0}" v-for="(article,index1) in 3">
						施工承发包模式-施工合同与物资采购合同二
						<navigator url="/pages2/bank/questionBankTest">
							<view v-if="index1 == 0" class="btn">试做</view>
						</navigator>
						
					</view>
				</view>
				
				<view class="list">
					<view class="article" :class="{active:index1 == 0}" v-for="(article,index1) in 3">
						施工承发包模式-施工合同与物资采购合同二
						<navigator url="/pages2/bank/questionBankTest">
							<view v-if="index1 == 0" class="btn">试做</view>
						</navigator>
						
					</view>
				</view>
			</view>
		</view>
		<view class="bottomBox">
			<view class="priceTag">¥ 999.00</view>
			<view style="display: flex;color: #FFFFFF;align-items: center;">
				<view class="btn1" @click="addCart">加购物车</view>
				<view class="btn2" @click="buy">立即购买</view>
			</view>
		</view>
	</view>
</template>

<script>
import { mapGetters } from 'vuex';
export default {
	data() {
		return {
			list: [
				{
					name: '详情'
				},
				{
					name: '大纲'
				}
			],
			current:0,
			outline:[{
				list:[1,2,3,4],
				showList:false,
			}],
			id:'',
			goodsData:{}
		};
	},
	filters: {
	   formatDate: function (value) {
		   
		var date = new Date(value);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
		var Y = date.getFullYear();
		return Y;
	  }
	},
	onUnload() {
		
	},
	computed: { ...mapGetters(['userInfo']) },
	onLoad(option) {
		console.log(option)
		this.id = option.id
		this.getDetail();
	},
	onShow() {
		
	},
	methods: {
		getDetail(){
			this.$api.goodsDetail(this.id).then(res => {
				console.log(res)
				this.goodsData = res.data.data;
				 
			})
		},
		getModule() {
			
		},
		buy(){
			if(this.$method.isGoLogin()){
				return
			}
			this.$navTo.togo('/pages2/order/confirm_list');
		},
		addCart(){
			if(this.$method.isGoLogin()){
				return
			}
			uni.showToast({
			    title: '添加成功',
			    duration: 1000
			});
			
		},
		open(item){
			item.showChildren = !item.showChildren
		},
		change(index){
			this.current = index;
		},
		changeItem(e) {
			let index = e.currentTarget.dataset.index
			this.outline.forEach((arrItem,i) => {
				if(i == index) {
					arrItem.showList = !arrItem.showList
				}
			})
			
		}
	}
};
</script>
<style >
	page{
		background-color: #EAEEF1;
	}
</style>
<style lang="scss" scope>
	
	.intro {
		background: #EAEEF1;
		padding:16rpx 16rpx 124rpx;
		
		.content {
			background:#fff;
			border-radius: 16rpx;;
			.top {
				border-radius: 16rpx;
				padding:32rpx 28rpx 16rpx;
				font-size: 30rpx;
				color: #333333;
			}
			
			.img {
				width:100%;
			}
		}
	}
	
	.title-list {
		background: #EAEEF1;
		padding:16rpx 16rpx 124rpx;
		.content {
			
			.list {
				background:#fff;
				margin-bottom:30rpx;
				overflow: hidden;
				border-radius: 16rpx;
				padding:10rpx 16rpx;
				
				.module {
					font-size: 30rpx;
					color: #333333;
				}
				
				.section {
					padding:30rpx 0;
					border-bottom: 1rpx solid #EEEEEE;
					font-size: 24rpx;
					color: #666666;
					
					&::before {
						content:'^';
						display: inline-block;
						margin-right:20rpx;
					}
					
					&.up {
						&::before {
							transform: rotate(180deg);
						}
						
					}
				}
				
				.article {
					height:80rpx;
					display: flex;
					align-items: center;
					margin-left:88rpx;
					font-size: 24rpx;
					color: #666666;
					border-bottom: 1rpx solid #EEEEEE;
					
					&:nth-last-of-type(1) {
						border:0;
					}
					
					&.active {
						color:#007AFF;
						
						
						.btn {
							width: 96rpx;
							height: 48rpx;
							line-height: 48rpx;
							text-align: center;
							color:#fff;
							font-size: 30rpx;
							border-radius:24rpx;
							background: #007AFF;
							margin-left:36rpx;
							border-radius: 24rpx;
						}
					}
				}
			}
		}
	}
	.btn2{
		width: 200rpx;
		height: 64rpx;
		background: linear-gradient(0deg, #FFB102, #FD644F);
		box-shadow: 0rpx 10rpx 16rpx 4rpx rgba(1, 99, 235, 0.04);
		border-radius: 32rpx;
		line-height: 64rpx;
		text-align: center;
	}
	.btn1{
		width: 200rpx;
		height: 64rpx;
		background: linear-gradient(0deg, #015EEA, #00C0FA);
		border-radius: 32rpx;
		line-height: 64rpx;
		text-align: center;
		margin-right: 20rpx;
	}
	.bottomBox{
		position: fixed;
		bottom: 0;
		width: 100%;
		left: 0;
		height:98rpx ;
		background-color: #FFFFFF;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 30rpx;
	}
	.blackFont{
		color: #333333;
		margin: 0 4rpx;
	}
	.wk_icon{
		width: 24rpx;
		height: 24rpx;
		margin-right: 12rpx;
	}
	.noteTag{
		ont-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #999999;
		align-items: center;
	}
	.priceTag{
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #FF2D55;
	}
	.titleTag{
		font-size: 32rpx;
		font-weight: bold;
		color: #333333;
		margin-left: 8rpx;
	}
	.yearTag{
		width: 80rpx;
		height: 32rpx;
		background: #EBF5FF;
		border: 2rpx solid #007AFF;
		border-radius: 16rpx;
		font-size: 24rpx;
		color: #007AFF;
		text-align: center;
		line-height: 32rpx;
	}
	.itemBox{
		background: #FFFFFF;
		box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
		border-radius: 24rpx;
		width: 100%;
		padding: 20rpx;
		margin-bottom: 20rpx;
	}
</style>
