bookshelf.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view class="bookshelf-content">
  3. <bookList></bookList>
  4. <readHistory></readHistory>
  5. </view>
  6. <!-- <view>
  7. <button @click="onBtnClick"> 去读书</button>
  8. </view>
  9. <view v-for="item in book_list " :key="item.book_id">
  10. <image :src="item.book_cover" @click="onClickItem(item)">
  11. {{item.book_name}}
  12. </image>
  13. </view> -->
  14. </template>
  15. <script setup lang="ts">
  16. import bookList from '../bookshelf/bookshelf-bookList.vue'
  17. import readHistory from '../bookshelf/bookshelf-readHistory.vue'
  18. import { log } from '../../framework/log';
  19. import { http } from '../../framework/http';
  20. import { config } from '../../config/config';
  21. import { book_item_data } from '../../data/data';
  22. import { UserStatus } from '../../stores/userStatusManager';
  23. import { ref } from 'vue';
  24. let is_show = ref(true)
  25. function onBtnClick(){
  26. is_show.value = !is_show.value
  27. // jumpRead()
  28. }
  29. function onClickItem(item:book_item_data){
  30. // util.alert("点击了"+item.book_name)
  31. item.start_read_chapter_id = 1
  32. UserStatus().updateUserSlectBook(item)
  33. uni.reLaunch({
  34. url: '/pages/readbook/read'
  35. });
  36. }
  37. let book_list= ref<Array<book_item_data>>()
  38. function jumpRead(){
  39. http.StaticRequest("https://static.hainanmlwl.com/test_books/book_list.json",(err,data)=>{
  40. if(err){
  41. return
  42. }
  43. log.Debug("data.code", typeof config.url_confg.StatesCode.SUCCESS)
  44. if(data.code==config.url_confg.StatesCode.SUCCESS){
  45. log.Debug("book_list",data)
  46. book_list.value = data.content
  47. }else{
  48. }
  49. })
  50. // uni.reLaunch({
  51. // url: '/pages/test/index'
  52. // });
  53. }
  54. </script>
  55. <style lang="scss">
  56. .bookshelf-content{
  57. display: flex;
  58. flex-direction: column;
  59. }
  60. </style>