<!DOCTYPE html>
<html>
	<?php echo $this->fetch('head.html'); ?>
	<style>
		.p-price {
			padding: 20px 6px;
			color: #666;
			font-size: 16px;
			line-height: 2;
		}

		.p-price .price {
			color: #f60;
			font-size: 18px;
		}

		.p-price .buy-btn {

			margin-left: 10px;
			background-color: #5f98d2;
			color: #fff;
			display: inline-block;
			text-align: center;
			line-height: 30px;
			font-size: 14px;
			padding: 0px 10px;
			border-radius: 5px;
			cursor: pointer;
		}
	</style>
	<body>
		<?php echo $this->fetch('header.html'); ?>
		<div class="main-body">

			<div class="row-box mgb-5">
				<div class="flex">
					<a   href="/">首页</a>
					<i class="iconfont icon-right"></i>
					<a  href="/module.php?m=book">图书</a>
					<i class="iconfont icon-right"></i>
					<a  href=""><?php echo $this->_var['data']['title']; ?></a>
					<i class="iconfont icon-right"></i>
					<a><cite>正文</cite></a>
				</div>
				

			</div>
			<div class="flex">
				<div class="flex-1">
					<div class="row-box">
						<div class="d-title"><?php echo $this->_var['data']['title']; ?></div>
						<div class="d-desc">
							描述：<?php echo $this->_var['data']['description']; ?>
						</div>

						<div class="p-price">
							<?php if ($this->_var['data']['ispay']): ?>
							课程价格：<span class="price">￥ <?php echo $this->_var['data']['money']; ?></span>元
							<?php endif; ?>
							<?php if (! $this->_var['isbuy']): ?>
							<a href="JavaScript:;" class="js-buy buy-btn" gold="<?php echo $this->_var['data']['gold']; ?>" bookid="<?php echo $this->_var['data']['bookid']; ?>">立即购买</a>
							<?php else: ?>
							<a class="buy-btn" target="_blank" href="/module.php?m=book&a=view&bookid=<?php echo $this->_var['data']['bookid']; ?>">去阅读</a>
							<?php endif; ?>
						</div>

						<div class="d-content">


							<?php echo $this->_var['data']['content']; ?>


						</div>
					</div>
				</div>
				<div class="page-side">
					<div class="row-box">
						<h3 class="fly-panel-title">热门课程</h3>
						<div class="">
							<?php $_from = $this->_var['reclist']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
							<a class="row-item" href="/module.php?m=book&a=show&bookid=<?php echo $this->_var['c']['bookid']; ?>">
								<div class="row-item-title"><?php echo $this->_var['c']['title']; ?></div>
							</a>
							<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
						</div>
					</div>

				</div>
			</div>


		</div>
		<?php echo $this->fetch('footer.html'); ?>
		<?php echo $this->fetch('foot-all.html'); ?>



		<script>
			$(document).on("click", ".js-buy", function() {
				var bookid = $(this).attr("bookid");
				var gold = $(this).attr("gold");
				$.post("/module.php?m=book_order&a=order&ajax=1", {
					bookid: bookid
				}, function(data) {
					skyToast(data.message);
					if (data.error) {
						if (data.error == 1000) {
							window.location = '/index.php?m=login'
						}else if(data.error==1){
							window.location = data.url;
						} else if (data.data.action == "buygold") {
							window.location = "/index.php?m=gold&a=buy&gold=" + gold
						}
						return false;
					}
					if (data.error == 0) {
						if (data.data.action == 'success') {
							window.location = "/module.php?m=book&a=view&bookid=" + bookid
						} else if (data.data.action == "pay") {
							window.location = data.data.payurl
						}
					}
				}, "json")
			})
		</script>
	</body>
</html>
