index.ux 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <import name="short-page" src="../../components/short/index.ux"></import>
  2. <import name="wechat-page" src="../../components/wechat/index.ux"></import>
  3. <template>
  4. <div id="reader-content">
  5. <div class="reader-wrap" id='list'>
  6. <div type='title' class="reader-title">
  7. <text class="title">{{bookinfo.chapter_name}}</text>
  8. <!-- <text class="add-shelf" @click="addShelf">加入书架</text> -->
  9. </div>
  10. <div type='content' class="reader-content">
  11. <text class="chapter-text" for='content'>{{$item}}</text>
  12. </div>
  13. <div type='button' class="reader-operator">
  14. <text class="operator prev" @click="getPrevChapter">上一章</text>
  15. <text class="operator catalog" @click="toCatalog">目录</text>
  16. <text class="operator next" @click="getNextChapter">下一章</text>
  17. </div>
  18. </div>
  19. <short-page if="{{showShortPop}}"></short-page>
  20. <!-- <wechat-page></wechat-page> -->
  21. </div>
  22. </template>
  23. <script>
  24. import router from "@system.router";
  25. import it from "../../helper/interface.js";
  26. import { getChapters, getIsonshelf, postUserShelfBooks, chapterOrders } from "../../api";
  27. export default {
  28. protected: {
  29. bid: '',
  30. chapter_id: ''
  31. },
  32. private: {
  33. bookinfo: {},
  34. content: [],
  35. showShortPop: false
  36. },
  37. onInit() {
  38. this.getChapters(this.bid, this.chapter_id)
  39. this.addShelf()
  40. if (this.$app.$def.data.backClickCount === 0) {
  41. this.showShortPop = true;
  42. }
  43. },
  44. onShow() {
  45. it.getShortCut((value) => {
  46. this.showShortPop = !value;
  47. })
  48. },
  49. addShelf() {
  50. console.log("add shelf");
  51. getIsonshelf({ bid: this.bid }).then(r => {
  52. r.is_on ? '' : postUserShelfBooks({ bid: this.bid })
  53. })
  54. },
  55. getChapters(bid, chapter_id) {
  56. getChapters({ bid: bid, chapter_id: chapter_id }).then(r => {
  57. this.content = r.chapter_content.trim().split(/\n/)
  58. this.bookinfo = r
  59. // this.$element('list').scrollTo({ index: 0 })
  60. }).catch(e => {
  61. console.log('e code')
  62. console.log(e.data)
  63. console.log(e.data.code == '10016' || e.data.code == '10019')
  64. if (e.data.code == '10016' || e.data.code == '10019' || e.data.code == '10017') {
  65. chapterOrders({ bid: bid, chapter_id: chapter_id }).then(r => {
  66. this.content = r.chapter_content.trim().split(/\n/)
  67. this.bookinfo = r
  68. // this.$element('list').scrollTo({ index: 0 })
  69. }).catch(f => {
  70. console.log('f code')
  71. console.log(f.data)
  72. if (f.data.code == '10014' || f.data.code == '10015') {
  73. router.push({
  74. uri: "/views/Pay",
  75. params: {
  76. code: f.data.code,
  77. fee: e.data.data.fee,
  78. bid: this.bid
  79. }
  80. })
  81. }
  82. })
  83. } else if (e.data.code == '10014' || e.data.code == '10015') {
  84. router.push({
  85. uri: "/views/Pay",
  86. params: {
  87. code: e.data.code,
  88. fee: e.data.data.fee,
  89. bid: this.bid
  90. }
  91. })
  92. }
  93. })
  94. },
  95. toCatalog() {
  96. router.push({
  97. uri: "/views/Catalog",
  98. params: {
  99. chapter_sequence: this.bookinfo.chapter_sequence,
  100. bid: this.bid
  101. }
  102. })
  103. },
  104. getPrevChapter() {
  105. console.log("get prev chapter");
  106. // this.getChapters(this.bookinfo.bid, this.bookinfo.prev_cid)
  107. router.replace({
  108. uri: "/views/Reader",
  109. params: {
  110. bid: this.bookinfo.bid,
  111. chapter_id: this.bookinfo.prev_cid
  112. }
  113. })
  114. },
  115. getNextChapter() {
  116. console.log("get next chapter");
  117. if (this.bookinfo.next_cid == 0) {
  118. router.push({
  119. uri: "/views/Raderover",
  120. params: {
  121. bid: this.bid
  122. }
  123. })
  124. return
  125. }
  126. // this.getChapters(this.bookinfo.bid, this.bookinfo.next_cid)
  127. router.replace({
  128. uri: "/views/Reader",
  129. params: {
  130. bid: this.bookinfo.bid,
  131. chapter_id: this.bookinfo.next_cid
  132. }
  133. })
  134. }
  135. }
  136. </script>
  137. <style lang="less">
  138. @import "../../assets/less/reader.less";
  139. </style>