微信

index.vue 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <div class="mainPage flex-v">
  3. <div class="header flex-h">
  4. <div class="flex-item flex-h">
  5. <i class="iconfont icon-sousuo"></i>
  6. <div class="flex-item">
  7. <div>
  8. <input type="text" v-model="searchKey" placeholder="请输入图书名">
  9. </div>
  10. </div>
  11. </div>
  12. <a @click="search">搜索</a>
  13. </div>
  14. <div class="searchRemark" v-if="showSearchRemark">
  15. <span>
  16. 关于“
  17. <em>{{indexSearchKey}}</em>”的搜索结果:
  18. </span>
  19. </div>
  20. <div class="flex-item">
  21. <div>
  22. <div class="noData" v-if="noData">
  23. <img src="../../../../common/icon/kong.png" alt>
  24. <span>暂无内容</span>
  25. </div>
  26. <ul>
  27. <li v-for="(item, index) in searchBooksList" :key="index">
  28. <libraryListItem :data="item" @appointmentBook="appointmentBook"></libraryListItem>
  29. </li>
  30. </ul>
  31. </div>
  32. </div>
  33. <van-dialog v-model="showAppointmentDialog" :show-confirm-button="false">
  34. <div class="dialogContent">
  35. <span class="title">确认在线预约当前图书?</span>
  36. <div>
  37. <span style="color: #666;">在线预约需在2018年12月20日前前往案场借阅图书, 否则 将取消预约资格</span>
  38. </div>
  39. <div class="btn">
  40. <a @click="sureAppointmentBook">确定</a>
  41. <a @click="showAppointmentDialog = false">取消</a>
  42. </div>
  43. </div>
  44. </van-dialog>
  45. </div>
  46. </template>
  47. <script>
  48. import libraryListItem from '../../../../components/libraryListItem/index'
  49. import { mapState, createNamespacedHelpers } from 'vuex'
  50. const { mapActions: mapAppActions } = createNamespacedHelpers('app')
  51. const { mapState: mapLibraryState, mapActions: mapLibraryAction, mapMutations: mapLibraryMutations } = createNamespacedHelpers('library')
  52. export default {
  53. data () {
  54. return {
  55. searchKey: '',
  56. showSearchRemark: false,
  57. noData: false,
  58. showAppointmentDialog: false
  59. }
  60. },
  61. created () {
  62. },
  63. computed: {
  64. ...mapState({
  65. CaseList: x => x.app.CaseList,
  66. }),
  67. ...mapLibraryState({
  68. indexSearchKey: x => x.indexSearchKey,
  69. searchBooksList: x => x.searchBooksList
  70. })
  71. },
  72. mounted () {
  73. this.$nextTick(() => {
  74. this.searchKey = this.indexSearchKey || ''
  75. })
  76. },
  77. components: {
  78. libraryListItem
  79. },
  80. methods: {
  81. ...mapAppActions([
  82. 'getCaseList',
  83. ]),
  84. ...mapLibraryAction(['']),
  85. ...mapLibraryMutations(['setIndexSearchKey']),
  86. search () { // 搜索
  87. if (this.searchKey !== '') {
  88. this.setIndexSearchKey(this.searchKey)
  89. this.showSearchRemark = true
  90. } else {
  91. this.$toast('搜索关键词不能为空')
  92. }
  93. },
  94. appointmentBook () { // 预约图书
  95. this.showAppointmentDialog = true
  96. },
  97. sureAppointmentBook () { // 确定预约图书
  98. this.showAppointmentDialog = false
  99. },
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .mainPage {
  105. .header {
  106. padding: 0.1rem 0.2rem;
  107. > div {
  108. background: #f2f2f2;
  109. position: relative;
  110. overflow: hidden;
  111. i {
  112. font-size: 0.15rem;
  113. color: #ccc;
  114. margin-left: 0.08rem;
  115. line-height: 0.3rem;
  116. }
  117. > div {
  118. margin-left: 0.1rem;
  119. > div {
  120. width: 100%;
  121. position: relative;
  122. overflow: hidden;
  123. input {
  124. width: 100%;
  125. display: block;
  126. line-height: 0.2rem;
  127. padding: 0.05rem 0;
  128. background: none;
  129. font-size: 0.13rem;
  130. }
  131. }
  132. }
  133. }
  134. > a {
  135. line-height: 0.3rem;
  136. margin-left: 0.1rem;
  137. font-size: 0.14rem;
  138. }
  139. }
  140. .searchRemark {
  141. padding: 0 0.2rem;
  142. span {
  143. width: 100%;
  144. white-space: nowrap;
  145. overflow: hidden;
  146. display: block;
  147. line-height: 0.22rem;
  148. font-size: 0.14rem;
  149. color: #616161;
  150. em {
  151. line-height: 0.22rem;
  152. font-size: 0.14rem;
  153. color: #fc5634;
  154. }
  155. }
  156. }
  157. > .flex-item {
  158. position: relative;
  159. overflow: hidden;
  160. > div {
  161. width: 100%;
  162. position: absolute;
  163. left: 0;
  164. top: 0;
  165. bottom: 0;
  166. overflow-y: scroll;
  167. -webkit-overflow-scrolling: touch;
  168. transform: translateZ(0);
  169. -webkit-transform: translateZ(0);
  170. .noData {
  171. width: 100%;
  172. margin: 0.5rem auto 0;
  173. position: relative;
  174. overflow: hidden;
  175. img {
  176. width: 0.7rem;
  177. display: block;
  178. margin: 0 auto;
  179. }
  180. span {
  181. width: 100%;
  182. display: block;
  183. text-align: center;
  184. line-height: 0.3rem;
  185. color: #b4b4b4;
  186. font-size: 0.14rem;
  187. margin: 0.05rem auto 0;
  188. }
  189. }
  190. > ul {
  191. padding: 0 0.2rem;
  192. margin: 0 auto 0.1rem;
  193. position: relative;
  194. overflow: hidden;
  195. > li {
  196. width: 100%;
  197. position: relative;
  198. overflow: hidden;
  199. margin: .1rem auto 0;
  200. }
  201. }
  202. }
  203. }
  204. }
  205. </style>