<template>
	<view class="bookshelf-content">
		<bookList></bookList>
		<readHistory></readHistory>
	</view>
	<!-- <view>
		<button @click="onBtnClick"> 去读书</button>
	</view>
	<view v-for="item in book_list " :key="item.book_id">
		<image :src="item.book_cover" @click="onClickItem(item)">
			{{item.book_name}}
		</image>
	</view> -->
</template>

<script setup lang="ts">
	import bookList from '../bookshelf/bookshelf-bookList.vue'
	import readHistory from '../bookshelf/bookshelf-readHistory.vue'
	
	import { log } from '../../framework/log';
	import { http } from '../../framework/http';
	import { config } from '../../config/config';
	import { book_item_data } from '../../data/data';
	import { UserStatus } from '../../stores/userStatusManager';
    import { ref } from 'vue';
	
	let is_show = ref(true)
		
	function onBtnClick(){	
		is_show.value = !is_show.value
		// jumpRead()
	}
	
	function onClickItem(item:book_item_data){
		// util.alert("点击了"+item.book_name)
		item.start_read_chapter_id = 1
		UserStatus().updateUserSlectBook(item)
		
		uni.reLaunch({
			url: '/pages/readbook/read'
		});
	}
	
	let book_list= ref<Array<book_item_data>>()
	function jumpRead(){
		http.StaticRequest("https://static.hainanmlwl.com/test_books/book_list.json",(err,data)=>{
			if(err){
				return
			}
			log.Debug("data.code", typeof config.url_confg.StatesCode.SUCCESS)
			if(data.code==config.url_confg.StatesCode.SUCCESS){
				log.Debug("book_list",data)
				book_list.value = data.content
			}else{
			}
		})
		// uni.reLaunch({
		// 	url: '/pages/test/index'
		// });
	}
</script>

<style lang="scss">
	.bookshelf-content{
		display: flex;
		flex-direction: column;
	}
</style>