read.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <readPage ref="readPages" @touchend="onClickView" @touchmove="hideSetting" v-for="(text,index) in book_text_list" :key="index" :text_content="text" >
  3. </readPage>
  4. </template>
  5. <script setup lang="ts">
  6. import { ref,getCurrentInstance} from 'vue';
  7. import { book_item_data, chapter_item_data } from '../../data/data';
  8. import { tools } from '../../framework/tools';
  9. import { UserStatus } from '../../stores/userStatusManager';
  10. import { log } from '../../framework/log';
  11. import readPage from '../../components/read/readPage.vue'
  12. import {onPullDownRefresh,onReachBottom} from '@dcloudio/uni-app'
  13. const readPages = ref(null)
  14. let book_data:book_item_data = UserStatus().getUserSlectBook()
  15. let book_list:chapter_item_data[] = []
  16. let cur_read_chapter_id =ref(0)
  17. //设置属性
  18. let fontSize = ref(18)
  19. let lineHeight = ref(1.8)
  20. let colorList = ref(['#000', '#666'])
  21. //设置属性end
  22. if(book_data!=null){
  23. initView()
  24. }
  25. let book_text_list = ref<Array<string>>([])
  26. function initView(){
  27. cur_read_chapter_id.value = tools.getChapterReadChapterIdByData(book_data)
  28. tools.getChapterList(book_data.chapter_path,(chapter_ls)=>{
  29. // log.Debug("chapter_ls",chapter_ls)
  30. book_list = chapter_ls
  31. draw()
  32. })
  33. }
  34. function draw(){
  35. if(cur_read_chapter_id.value!=0){
  36. tools.getCurChapterTxt(book_data.base_path,cur_read_chapter_id.value,fontSize.value*2,(text:string)=>{
  37. book_text_list.value.push(text)
  38. })
  39. }
  40. }
  41. function lower(){
  42. cur_read_chapter_id.value+=1;
  43. draw()
  44. }
  45. function onClickView(){
  46. }
  47. function hideAllTop(){
  48. }
  49. function showSetting(){
  50. }
  51. function hideSetting(){
  52. }
  53. onPullDownRefresh( async () => {
  54. showTopLoadingStatus()
  55. })
  56. onReachBottom(async ()=>{
  57. showBottomLoadingStatus()
  58. })
  59. function showBottomLoadingStatus(){
  60. readPages.value.find((child,index)=>{
  61. if( index == (book_text_list.value.length-1) ){
  62. child.showBottomLoading()
  63. lower()
  64. }
  65. })
  66. }
  67. function showTopLoadingStatus(){
  68. readPages.value.find((child,index)=>{
  69. if( index == 0 ){
  70. child.showTopLoading()
  71. }
  72. })
  73. }
  74. </script>
  75. <style scoped>
  76. </style>