<template>
	<view>
		<view style="background-color: #FFFFFF;">
			<view >
				<image :src="$method.splitImgHost(detail.coverUrl)" style="height: 461rpx;width: 100%;"></image>
				<view style="padding:20rpx">
					<view style="display: flex;margin-top: 13rpx;">
						<view class="yearTag">{{detail.year}}</view>
						<view class="titleTag">{{detail.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">6</text> 科 <text class="blackFont">120</text> 节  <text class="blackFont">60</text> 学时</view>
						
					</view>
				</view>
			</view>
			<u-line color="#D6D6DB" />
			<view>
				<view style="width: 160px;margin: 0 auto;"><u-tabs :list="list" item-width="150" font-size="24" bar-width="110" :current="current" @change="change" active-color="#007AFF"></u-tabs></view>
			</view>
			<u-line color="#D6D6DB" />
		</view>
		<view style="padding: 20rpx;" v-show="current==0">
			<view class="content">
				<view v-html="detail.mobileDetailHtml"></view>
			</view>
		</view>
		<view style="padding: 20rpx;" v-show="current==1">
			<view >
				<view v-for="(item,index) in courseList" class="courseItem">
					<view>{{item.courseName}}</view>
					<view><u-icon name="arrow-down" ></u-icon></view>
				</view>
			</view>
		</view>
		<view class="bottomBox">
			<view class="priceTag">¥ {{detail.standPrice}}</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 {
			id:0,
			list: [
				{
					name: '详情'
				},
				{
					name: '大纲'
				}
			],
			current:0,
			detail:{},
			courseList:[]
					
		};
	},
	onUnload() {
		
	},
	computed: { ...mapGetters(['userInfo']) },
	onLoad(option) {
		this.id = option.id;
		this.getDetail()
		this.goodsCourseList()
	},
	onShow() {
		
	},
	methods: {
		addShopCart() {
			let self = this
			this.$api.addCart({goodsId:this.id}).then(res => {
				if(res.data.code==200){
					uni.showToast({
					    title: '添加成功'
					});
				}else{
					this.$u.toast(res.data.msg);
				}
			});
		},
		goodsCourseList() {
			let self = this
			this.$api.goodsCourseList(this.id).then(res => {
				if(res.data.code==200){
					self.courseList = res.data.rows
				}
			});
		},
		getDetail() {
			let self = this
			this.$api.goodsDetail(this.id).then(res => {
				if(res.data.code==200){
					self.detail = res.data.data
					console.log(self.detail.mobileDetailHtml)
				}
			});
		},
		buy(){
			if(this.$method.isGoLogin()){
				return
			}
			this.$navTo.togo('/pages2/order/confirm_list');
		},
		addCart(){
			if(this.$method.isGoLogin()){
				return
			}
			this.addShopCart()
			
		},
		open(item){
			item.showChildren = !item.showChildren
		},
		change(index){
			this.current = index;
		}
	}
};
</script>
<style >
	page{
		background-color: #EAEEF1;
	}
</style>
<style scope>
	.courseItem{
		width: 100%;
		height: 80rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		color: #333333;
		font-size: 32rpx;
		line-height: 80rpx;
		font-weight: bold;
		padding: 0 10rpx;
		display: flex;
		justify-content: space-between;
	}
	.content{
		background-color: #FFFFFF;
	}
	.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>
