微信

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div class="mainPage">
  3. <div>
  4. <div class="header flex-h">
  5. <div class="flex-item flex-h">
  6. <i class="iconfont icon-sousuo"></i>
  7. <router-link
  8. class="flex-item"
  9. :to="{name: 'booksSearch', query: {caseid: currentCaseId}}"
  10. >{{indexSearchKey}}</router-link>
  11. </div>
  12. <a @click="showDialog = true">
  13. <i class="iconfont icon-dingwei"></i>
  14. <span>{{currentCaseName}}</span>
  15. </a>
  16. </div>
  17. <nav class="nav">
  18. <a v-for="(item, index) in navList" v-if="(navList || []).length < 9 || index<7" :key="index" @click="navClick(item)">
  19. <img :src="item.BookTypeImg" alt>
  20. <span>{{item.BookTypeName}}</span>
  21. </a>
  22. <a v-if="(navList || []).length >8 " @click="moreNav()">
  23. <img src="https://spaceofcheng.oss-cn-beijing.aliyuncs.com/test-icon8.png" alt>
  24. <span>更多</span>
  25. </a>
  26. </nav>
  27. <div class="list">
  28. <h1>精选推荐</h1>
  29. <ul>
  30. <li v-for="(item, index) in books.list" :key="index">
  31. <libraryListItem :data="item" @appointmentBook="appointmentBook"></libraryListItem>
  32. </li>
  33. </ul>
  34. </div>
  35. <van-dialog v-model="showDialog" :show-confirm-button="false">
  36. <div class="dialogContent">
  37. <span class="title">选择案场</span>
  38. <div>
  39. <radio :data="cases" v-model="caseId"></radio>
  40. </div>
  41. <div class="btn">
  42. <a @click="selectCaseId">确定</a>
  43. </div>
  44. </div>
  45. </van-dialog>
  46. <van-dialog v-model="showAppointmentDialog" :show-confirm-button="false">
  47. <div class="dialogContent">
  48. <span class="title">确认在线预约当前图书?</span>
  49. <div>
  50. <span style="color: #666;">在线预约需在2018年12月20日前前往案场借阅图书, 否则 将取消预约资格</span>
  51. </div>
  52. <div class="btn">
  53. <a @click="sureAppointmentBook">确定</a>
  54. <a @click="showAppointmentDialog = false">取消</a>
  55. </div>
  56. </div>
  57. </van-dialog>
  58. </div>
  59. </div>
  60. </template>
  61. <script>
  62. import libraryListItem from '../../../../components/libraryListItem/index'
  63. import radio from '../../../../components/radio/index'
  64. import { mapState, createNamespacedHelpers } from 'vuex'
  65. const { mapActions: mapAppActions } = createNamespacedHelpers('app')
  66. const { mapState: mapBookState, mapActions: mapBookActions } = createNamespacedHelpers('book')
  67. export default {
  68. name: '',
  69. data () {
  70. return {
  71. showDialog: false,
  72. showAppointmentDialog: false,
  73. caseId: '',
  74. currentCaseId: '',
  75. currentCaseName: '',
  76. cases: [],
  77. indexSearchKey: '',
  78. page: 1,
  79. pagesize: 10,
  80. }
  81. },
  82. computed: {
  83. ...mapState({
  84. userInfo: x => x.userCenter.userInfo,
  85. CaseList: x => x.app.CaseList
  86. }),
  87. ...mapBookState({
  88. navList: x => x.types.list,
  89. books: x => x.recommends
  90. }),
  91. },
  92. components: {
  93. libraryListItem,
  94. radio
  95. },
  96. created () {
  97. if (!this.CaseList.length || this.CaseList === null) {
  98. this.getCaseList().then((res) => {
  99. (res.cases || []).map((item) => {
  100. this.cases.push({
  101. value: item.CaseName,
  102. id: item.CaseId
  103. })
  104. })
  105. this.currentCaseId = ((res.cases || [])[0] || {}).CaseId
  106. this.currentCaseName = ((res.cases || [])[0] || {}).CaseName
  107. this.init()
  108. })
  109. } else {
  110. (this.CaseList || []).map((item) => {
  111. this.cases.push({
  112. value: item.CaseName,
  113. id: item.CaseId
  114. })
  115. })
  116. this.currentCaseId = ((this.CaseList || [])[0] || {}).CaseId
  117. this.currentCaseName = ((this.CaseList || [])[0] || {}).CaseName
  118. this.init()
  119. }
  120. },
  121. methods: {
  122. ...mapAppActions(['getCaseList']),
  123. ...mapBookActions([
  124. 'getBookType',
  125. 'getRecommendBook',
  126. 'getMineBook',
  127. ]),
  128. selectCaseId () { // 选择案场
  129. if (this.currentCaseId !== this.caseId) {
  130. this.currentCaseId = this.caseId
  131. this.CaseList.map((item) => {
  132. if (item.CaseId === this.currentCaseId) this.currentCaseName = item.CaseName
  133. })
  134. this.page = 1
  135. this.init()
  136. }
  137. this.showDialog = false
  138. },
  139. init () { // 初始化
  140. this.getBookType({
  141. caseid: this.currentCaseId,
  142. page: 1,
  143. pagesize: 10,
  144. })
  145. this.getRecommendBook({
  146. caseid: this.currentCaseId,
  147. page: this.page,
  148. pagesize: this.pagesize,
  149. })
  150. },
  151. appointmentBook () { // 预约图书
  152. this.showAppointmentDialog = true
  153. },
  154. sureAppointmentBook () { // 确定预约图书
  155. this.showAppointmentDialog = false
  156. },
  157. navClick (item) { // 点击nav
  158. this.$router.push({ name: 'booksList', query: { type: item.BookTypeId, caseid: this.currentCaseId } })
  159. },
  160. moreNav () {
  161. this.$router.push({ name: 'libraryNavList', query: {caseid: this.currentCaseId} })
  162. }
  163. }
  164. }
  165. </script>
  166. <!-- Add "scoped" attribute to limit CSS to this component only -->
  167. <style lang="scss" scoped>
  168. @import 'page.scss';
  169. </style>