readPage.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view :style="{height:'100vh'}">
  3. <view v-html="book_title" :style="{
  4. fontSize:`${config.read_config.fontSizeList[read_setting_data.fontSizeIndex]*1.5}px`,
  5. lineHeight:`${config.read_config.lineHeight * config.read_config.fontSizeList[read_setting_data.fontSizeIndex]}px`,
  6. color:`${font_color}`
  7. }"></view>
  8. <view class="inner-box">
  9. <view class="book-inner"
  10. v-html="getText()"
  11. :style="{
  12. fontSize: `${config.read_config.fontSizeList[read_setting_data.fontSizeIndex]}px`,
  13. lineHeight: `${config.read_config.lineHeight * config.read_config.fontSizeList[read_setting_data.fontSizeIndex]}px`,
  14. color:`${font_color}`
  15. }" @touchstart="(event)=>{emits('onTouchstart',event)}"
  16. @touchend="(event)=>{emits('onTouchend',event)}"
  17. @touchmove="(event)=>{emits('onTouchmove',event)}">
  18. </view>
  19. <view v-if="isLock==false" style="display: flex;justify-content: space-around;justify-items: center;margin-bottom: 5%;margin-top: 3%;">
  20. <image :src="getLogoIconRes()" style="width: 1013rpx;height: 40rpx;"></image>
  21. </view>
  22. <view v-if="isLock==false" style="display: flex;justify-content: space-around;justify-items: center;margin-bottom: 3%;margin-top: 3%;">
  23. <view @tap="emits('clickPreChapter')" :style="{color:ReadSetting().getReadSetting().readMode==config.read_config.readMode.Dark?'#868686':'#000000'}">上一章</view>
  24. <!-- <view @tap="emits('clickCatalog')">目录</view> -->
  25. <image :src="getMlIconRes()" style="width: 142rpx;height: 56rpx;" @tap="emits('clickCatalog')"></image>
  26. <view @tap="emits('clickNextChapter')" :style="{color:ReadSetting().getReadSetting().readMode==config.read_config.readMode.Dark?'#868686':'#000000'}">下一章</view>
  27. </view>
  28. </view>
  29. <view v-if="isLock" style="position: absolute;bottom: -1%;">
  30. <view @touchend="(event)=>{emits('onTouchend',event)}" @touchstart="(event)=>{emits('onTouchstart',event)}" style="width: 100vw;height: 100vh;position: absolute;bottom: 0;top: 0;"></view>
  31. <image :src="ReadSetting().getReadSetting().readMode==config.read_config.readMode.Dark?bgDarkModeRes:bgModeRes" style="width: 100vw;height: 100vh;"></image>
  32. <view style="position: absolute;bottom: 20%;">
  33. <view style="display: flex;
  34. flex-wrap: wrap;
  35. justify-content: space-between;">
  36. <recharge-item ref="Items" class="product-item" v-for="(item,index) in rechargeList" :key="item.goods_id" :recharge_item_data="item" @itemClick="onItemSelect"></recharge-item>
  37. </view>
  38. </view>
  39. <view style="position: absolute;bottom: 12%;left: -20%;">
  40. <image :src="ReadSetting().getReadSetting().readMode==config.read_config.readMode.Dark?shuBiDarkModeRes:shuBiModeRes" mode="aspectFit" style="height: 50rpx;"></image>
  41. </view>
  42. <view style="position: absolute;bottom: 13%;left: 30%;">
  43. <view style="height: 50rpx;" :style="{color:ReadSetting().getReadSetting().readMode==config.read_config.readMode.Dark?'#868686':'#000000'}">{{user_coin}}</view>
  44. </view>
  45. <view style="position: absolute;bottom: 12%;right: -25%;">
  46. <image @click="onAutoClick()" :src="getAutoImgStyle()" mode="aspectFit" style="height: 50rpx;"></image>
  47. </view>
  48. <view style="position: absolute;bottom: 12.5%;right: 22%;">
  49. <view style="height: 55rpx;font-size: 33rpx;" :style="{color:ReadSetting().getReadSetting().readMode==config.read_config.readMode.Dark?'#868686':'#000000'}">自动购买下一章</view>
  50. </view>
  51. <view style="position: absolute;bottom: 2%;">
  52. <image src="../../static/imgs/read/btn_buy_chapter.png" style="width: 90vw;height: 8vh;margin-left: 5%;"></image>
  53. </view>
  54. <view @tap="emits('BuyChapter')" style="position: absolute;bottom: 3%;width: 100%;height: 6vh;display: flex;justify-content: space-around;justify-items: center;">
  55. 解锁本章需要{{coin}}书币
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script setup lang="ts">
  61. import {defineProps, onMounted, ref, watch} from 'vue'
  62. import { ReadSetting } from '../../stores/readSetting';
  63. import { config } from '../../config/config';
  64. import { log } from '../../framework/log';
  65. import { tools } from '../../framework/tools';
  66. import rechargeItem from './rechargeItem.vue';
  67. import { recharge_list_data } from '../../data/data';
  68. import { UserData } from '../../stores/userDataManager';
  69. const {windowHeight,windowWidth} = uni.getSystemInfoSync()
  70. let rechargeList= ref<Array<recharge_list_data>>(null)
  71. let lock_content = ref('')
  72. let ml_icon_res = ref('')
  73. function getMlIconRes(){
  74. return ReadSetting().getReadSetting().readMode==config.read_config.readMode.Dark?'../../static/imgs/read/img_read_dark_ml.png':'../../static/imgs/read/img_read_ml.png'
  75. }
  76. let logo_icon_res = ref('')
  77. function getLogoIconRes(){
  78. return ReadSetting().getReadSetting().readMode==config.read_config.readMode.Dark?'../../static/imgs/read/img_read_dark_logo.png':'../../static/imgs/read/img_read_logo.png'
  79. }
  80. let {text_content,book_title,coin} = defineProps(['text_content','book_title','coin'])
  81. function test(){
  82. console.log("fuck")
  83. }
  84. // setLockContent()
  85. let bgModeRes = '../../static/imgs/read/img_unlock_bg.png'
  86. let bgDarkModeRes = '../../static/imgs/read/img_dark_unlock_bg.png'
  87. let shuBiModeRes = '../../static/imgs/read/img_shu_bi.png'
  88. let shuBiDarkModeRes = '../../static/imgs/read/img_drak_shu_bi.png'
  89. onMounted(()=>{
  90. ReadSetting().getRechargeList(config.recharge_stype.CHAPTER_PAGE,(d)=>{
  91. rechargeList.value = d
  92. })
  93. })
  94. let emits = defineEmits(['onTouchstart','onTouchend','onTouchmove','clickCatalog','clickPreChapter','clickNextChapter','BuyChapter','onClickBuy'])
  95. let read_setting_data = ReadSetting().getReadSetting()
  96. let font_color = ref(tools.getFontColorByMode(read_setting_data.readMode))
  97. function showTopLoading(){
  98. }
  99. function showBottomLoading(){
  100. }
  101. watch(async () => ReadSetting().getReadSetting().readMode, // 监听的数据源
  102. (newVal, oldVal) => {
  103. font_color.value = tools.getFontColorByMode(ReadSetting().getReadSetting().readMode)
  104. }
  105. );
  106. function setLockContent(){
  107. let len = text_content.length
  108. let temp_list = text_content.split('<br><br>')
  109. if(temp_list.length>=7){
  110. for(let i=0;i<7;i++){
  111. lock_content.value += (temp_list[i]+"<br><br>"+"<br><br>")
  112. }
  113. }else{
  114. lock_content.value = '请使用书币解锁内容,或者成为vip!'
  115. }
  116. }
  117. function getText(){
  118. // return isLock.value?lock_content:text_content
  119. return text_content
  120. }
  121. let isLock = ref(false)
  122. function LockChapter(){
  123. isLock.value = true
  124. }
  125. function UnLockChapter(){
  126. isLock.value = false
  127. }
  128. let Items = ref(null)
  129. let curSelectGoodsId = ref(0)
  130. let curSelectGoodsIsVip = ref(true)
  131. function onItemSelect(goods_id:number,isVip:boolean,is_default:boolean){
  132. curSelectGoodsIsVip.value = isVip
  133. curSelectGoodsId.value = goods_id
  134. Items.value.find((child,index)=>{
  135. child.updateSelectStatus(goods_id)
  136. })
  137. if(!is_default){
  138. emits('onClickBuy',curSelectGoodsId.value,curSelectGoodsId.value)
  139. }
  140. }
  141. let user_coin = ref(UserData().getData().coin)
  142. watch(()=>UserData().getData().coin,()=>{
  143. user_coin.value = UserData().getData().coin
  144. })
  145. function getAutoImgStyle(){
  146. return read_setting_data.autoBuyNextChpater?'../../static/imgs/read/setting/img_auto_on.png':'../../static/imgs/read/setting/img_auto_off.png'
  147. }
  148. function onAutoClick(){
  149. ReadSetting().changeAutoBuyNextChapter(!read_setting_data.autoBuyNextChpater)
  150. }
  151. defineExpose({ showBottomLoading,showTopLoading ,LockChapter,UnLockChapter });
  152. </script>
  153. <style lang="scss" scoped>
  154. .inner-box {
  155. flex: 1 1 auto;
  156. overflow: hidden;
  157. .book-inner {
  158. text-indent: 2em;
  159. text-align: justify;
  160. }
  161. padding: 5%;
  162. }
  163. .product-item {
  164. box-sizing: border-box;
  165. width: calc(50%); /* 减去一些空间作为间隔 */
  166. margin-bottom: 0px; /* 商品之间的垂直间距 */
  167. padding-left: 0px;
  168. padding-right: 0px;
  169. // border: 1px solid #ddd; /* 可选:给商品添加边框 */
  170. }
  171. </style>