bookdetails-chapterCatalog.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <view class="chapterCatalog_content">
  3. <view class="new-chapter" @click="clickReadChapter(book_data.chapter_count)">
  4. <view class="new-chapter__title">
  5. <view class="new-chapter__title__icon">
  6. <image class="image" src="../../static/imgs/public/img_new.png" mode=""></image>
  7. </view>
  8. <view class="new-chapter__title__name">
  9. {{book_data.chapter_new_name}}
  10. </view>
  11. </view>
  12. <view class="new-chapter__update-time">
  13. {{util.convertTimeString(book_data.chapter_time_time)}}更新
  14. </view>
  15. </view>
  16. <view class="first-chapter" v-if="first_chapter" @click="clickReadChapter(first_chapter.id)">
  17. {{first_chapter.name}}
  18. </view>
  19. <view class="two-chapter first-chapter" v-if="two_chapter" @click="clickReadChapter(two_chapter.id)">
  20. {{two_chapter.name}}
  21. </view>
  22. <view class="seeCatalog" @click="clickSeeCatalog()">
  23. <view class="seeCatalog__title">查看目录</view>
  24. <view class="seeCatalog__info">
  25. <view class="seeCatalog__info__name">
  26. {{seeCatalog_string}}
  27. </view>
  28. <uni-icons type="right"></uni-icons>
  29. </view>
  30. </view>
  31. <chapterCatalog v-if="showChapterList" :items="directoryList" :size="40" :remain="16"
  32. :scrollHeight="windowHeight*0.6" @clickChar="goToChapter" @Close="hideChapterCatalog"
  33. :unLockChapterList="unLockChapterList" :active="0">
  34. </chapterCatalog>
  35. </view>
  36. </template>
  37. <script setup lang="ts">
  38. import { ref } from 'vue';
  39. import { book_item_data, chapter_item_data } from '../../data/data';
  40. import { util } from '../../framework/util';
  41. import { tools } from '../../framework/tools';
  42. import chapterCatalog from '../../components/read/chapterCatalog.vue'
  43. import { UserStatus } from '../../stores/userStatusManager';
  44. const props = defineProps({
  45. book_data: Object,
  46. })
  47. const emits = defineEmits(['clickReadChapter'])
  48. let first_two_chapters:chapter_item_data[] = JSON.parse(props.book_data.first_two_chapters)
  49. let first_chapter = ref(null)
  50. let two_chapter = ref(null)
  51. if(first_two_chapters.length>0) {
  52. first_chapter.value = first_two_chapters[0]
  53. }
  54. if(first_two_chapters.length>1) {
  55. two_chapter.value = first_two_chapters[1]
  56. }
  57. let seeCatalog_string = ref('')
  58. if(props.book_data.book_is_action==1) {
  59. seeCatalog_string.value = `已完结 共${props.book_data.chapter_count}章`
  60. } else {
  61. seeCatalog_string.value = `连载至${props.book_data.chapter_count}章`
  62. }
  63. const {windowHeight} = uni.getSystemInfoSync()
  64. let showChapterList = ref(false)
  65. let directoryList:chapter_item_data[] = []
  66. let unLockChapterList = ref([])
  67. function clickReadChapter(id:number) {
  68. emits('clickReadChapter',id)
  69. }
  70. function clickSeeCatalog() {
  71. showChapterCatalog()
  72. }
  73. function showChapterCatalog() {
  74. let book_data = props.book_data as book_item_data
  75. UserStatus().updateUserSelectBook(book_data)
  76. if(directoryList.length>0) {
  77. showChapterList.value = true
  78. return
  79. }
  80. util.showLoading()
  81. tools.getChapterList(props.book_data.chapter_path,(chapter_ls)=>{
  82. // console.log('chapter_ls=',chapter_ls)
  83. directoryList = chapter_ls
  84. unLockChapterList.value =[]
  85. tools.get_book_un_lock_list(props.book_data.book_id,(list)=>{
  86. util.hideLoading()
  87. if(list!=null){
  88. unLockChapterList.value = list
  89. showChapterList.value = true
  90. }else{
  91. util.showErrorToast('加载错误')
  92. }
  93. })
  94. })
  95. }
  96. function hideChapterCatalog(){
  97. showChapterList.value = false
  98. }
  99. function goToChapter(chapter_list_item_data:chapter_item_data) {
  100. emits('clickReadChapter',chapter_list_item_data.id)
  101. }
  102. </script>
  103. <style lang="scss">
  104. .chapterCatalog_content{
  105. display: flex;
  106. flex-direction: column;
  107. padding: 0 40rpx;
  108. margin-top: 40rpx;
  109. // margin-bottom: 30rpx;
  110. .new-chapter{
  111. display: flex;
  112. flex-direction: row;
  113. justify-content: space-between;
  114. font-size: 16px;
  115. color: #FE4977;
  116. &__title{
  117. display: flex;
  118. flex-direction: row;
  119. &__icon{
  120. flex-shrink: 0;
  121. width: 55rpx;
  122. height: 26rpx;
  123. .image{
  124. width: 100%;
  125. height: 100%;
  126. }
  127. }
  128. &__name{
  129. margin-left: 15rpx;
  130. font-size: 17px;
  131. }
  132. }
  133. &__update-time{
  134. }
  135. }
  136. .first-chapter{
  137. margin-top: 16rpx;
  138. font-size: 16px;
  139. color: #5E5E5E;
  140. }
  141. .two-chapter{
  142. }
  143. .seeCatalog{
  144. display: flex;
  145. flex-direction: row;
  146. justify-content: space-between;
  147. align-items: center;
  148. padding: 0 25rpx;
  149. margin-top: 30rpx;
  150. height: 70rpx;
  151. border-radius: 15rpx;
  152. background-color: #F9F7F8;
  153. &__title{
  154. font-size: 16px;
  155. color: #000;
  156. }
  157. &__info{
  158. display: flex;
  159. flex-direction: row;
  160. align-items: center;
  161. &__name {
  162. font-size: 14px;
  163. color: #757575;
  164. }
  165. }
  166. }
  167. }
  168. </style>