wangfei 6 years ago
parent
commit
d837fa4661

+ 1
- 1
src/pages/bodyCheck/app.js View File

@@ -1,7 +1,7 @@
1 1
 import Vue from 'vue'
2 2
 import App from './App.vue'
3 3
 import Vant from 'vant'
4
-import 'vant/lib/vant-css/index.css'
4
+import 'vant/lib/index.css'
5 5
 import router from './router'
6 6
 import store from '../../store/index'
7 7
 import Vuex from 'vuex'

+ 1
- 1
src/pages/sales/app.js View File

@@ -1,7 +1,7 @@
1 1
 import Vue from 'vue'
2 2
 import App from './App.vue'
3 3
 import Vant from 'vant'
4
-import 'vant/lib/vant-css/index.css'
4
+import 'vant/lib/index.css'
5 5
 import router from './router'
6 6
 import store from '../../store/index'
7 7
 import Vuex from 'vuex'

+ 1
- 1
src/pages/user/app.js View File

@@ -1,7 +1,7 @@
1 1
 import Vue from 'vue'
2 2
 import App from './App.vue'
3 3
 import Vant from 'vant'
4
-import 'vant/lib/vant-css/index.css'
4
+import 'vant/lib/index.css'
5 5
 import router from './router'
6 6
 import store from '../../store/index'
7 7
 import Vuex from 'vuex'

+ 17
- 16
src/pages/user/library/booksList/index.vue View File

@@ -2,7 +2,7 @@
2 2
   <div class="mainPage">
3 3
     <div>
4 4
       <ul>
5
-        <li v-for="(item, index) in bookTypeList" :key="index">
5
+        <li v-for="(item, index) in (books.list || [])" :key="index">
6 6
           <libraryListItem :data="item" @appointmentBook="appointmentBook"></libraryListItem>
7 7
         </li>
8 8
       </ul>
@@ -24,36 +24,37 @@
24 24
 
25 25
 <script>
26 26
 import libraryListItem from '../../../../components/libraryListItem/index'
27
-import { mapState, createNamespacedHelpers } from 'vuex'
28
-const { mapActions: mapAppActions } = createNamespacedHelpers('app')
29
-const { mapState: mapLibraryState, mapActions: mapLibraryAction } = createNamespacedHelpers('library')
27
+import { createNamespacedHelpers } from 'vuex'
28
+const { mapState: mapBookState, mapActions: mapBookAction } = createNamespacedHelpers('book')
30 29
 export default {
31 30
   data () {
32 31
     return {
33
-      showAppointmentDialog: false
32
+      showAppointmentDialog: false,
33
+      query: {
34
+        caseid: '',
35
+        bookType: '',
36
+        page: 1,
37
+        pagesize: 10,
38
+      }
34 39
     }
35 40
   },
36 41
   created () {
42
+    this.query.bookType = this.$route.query.type
43
+    this.query.caseid = this.$route.query.caseid
44
+    this.getBookList(this.query)
37 45
   },
38 46
   computed: {
39
-    ...mapState({
40
-      CaseList: x => x.app.CaseList,
41
-    }),
42
-    ...mapLibraryState({
43
-      navList: x => x.navList,
44
-      bookTypeList: x => x.bookTypeList
47
+    ...mapBookState({
48
+      books: x => x.books
45 49
     })
46 50
   },
47 51
   components: {
48 52
     libraryListItem,
49 53
   },
50 54
   methods: {
51
-    ...mapAppActions([
52
-      'getCaseList',
55
+    ...mapBookAction([
56
+      'getBookList',
53 57
     ]),
54
-    ...mapLibraryAction(['getBookListByType']),
55
-    navClick (item) {
56
-    },
57 58
     appointmentBook () { // 预约图书
58 59
       this.showAppointmentDialog = true
59 60
     },

+ 30
- 25
src/pages/user/library/booksSearch/index.vue View File

@@ -11,20 +11,20 @@
11 11
       </div>
12 12
       <a @click="search">搜索</a>
13 13
     </div>
14
-    <div class="searchRemark" v-if="showSearchRemark">
14
+    <div class="searchRemark" v-if="showSearch">
15 15
       <span>
16 16
         关于“
17
-        <em>{{indexSearchKey}}</em>”的搜索结果:
17
+        <em>{{doSearchKey}}</em>”的搜索结果:
18 18
       </span>
19 19
     </div>
20
-    <div class="flex-item">
20
+    <div class="flex-item" :hidden="!showSearch">
21 21
       <div>
22
-        <div class="noData" v-if="noData">
22
+        <div class="noData" v-if="(books.list || []).length < 1">
23 23
           <img src="../../../../common/icon/kong.png" alt>
24 24
           <span>暂无内容</span>
25 25
         </div>
26
-        <ul>
27
-          <li v-for="(item, index) in searchBooksList" :key="index">
26
+        <ul v-else>
27
+          <li v-for="(item, index) in books.list" :key="index">
28 28
             <libraryListItem :data="item" @appointmentBook="appointmentBook"></libraryListItem>
29 29
           </li>
30 30
         </ul>
@@ -48,46 +48,41 @@
48 48
 <script>
49 49
 import libraryListItem from '../../../../components/libraryListItem/index'
50 50
 import { mapState, createNamespacedHelpers } from 'vuex'
51
-const { mapActions: mapAppActions } = createNamespacedHelpers('app')
52
-const { mapState: mapLibraryState, mapActions: mapLibraryAction, mapMutations: mapLibraryMutations } = createNamespacedHelpers('library')
51
+const { mapState: mapBookState, mapActions: mapBookAction } = createNamespacedHelpers('book')
53 52
 export default {
54 53
   data () {
55 54
     return {
56 55
       searchKey: '',
57
-      showSearchRemark: false,
56
+      showSearch: false,
58 57
       noData: false,
59
-      showAppointmentDialog: false
58
+      showAppointmentDialog: false,
59
+      caseid: '',
60
+      page: 1,
61
+      pagesize: 10,
62
+      doSearchKey: '',
60 63
     }
61 64
   },
62 65
   created () {
66
+    this.caseid = this.$route.query.caseid
63 67
   },
64 68
   computed: {
65
-    ...mapState({
66
-      CaseList: x => x.app.CaseList,
67
-    }),
68
-    ...mapLibraryState({
69
-      indexSearchKey: x => x.indexSearchKey,
70
-      searchBooksList: x => x.searchBooksList
69
+    ...mapBookState({
70
+      books: x => x.books,
71 71
     })
72 72
   },
73 73
   mounted () {
74
-    this.$nextTick(() => {
75
-      this.searchKey = this.indexSearchKey || ''
76
-    })
77 74
   },
78 75
   components: {
79 76
     libraryListItem
80 77
   },
81 78
   methods: {
82
-    ...mapAppActions([
83
-      'getCaseList',
79
+    ...mapBookAction([
80
+      'getBookList',
84 81
     ]),
85
-    ...mapLibraryAction(['']),
86
-    ...mapLibraryMutations(['setIndexSearchKey']),
87 82
     search () { // 搜索
88 83
       if (this.searchKey !== '') {
89
-        this.setIndexSearchKey(this.searchKey)
90
-        this.showSearchRemark = true
84
+        this.doSearchKey = this.searchKey
85
+        this.getSearchList()
91 86
       } else {
92 87
         this.$toast('搜索关键词不能为空')
93 88
       }
@@ -98,6 +93,16 @@ export default {
98 93
     sureAppointmentBook () { // 确定预约图书
99 94
       this.showAppointmentDialog = false
100 95
     },
96
+    getSearchList () {
97
+      this.getBookList({
98
+        caseid: this.caseid,
99
+        name: this.doSearchKey,
100
+        page: this.page,
101
+        pagesize: this.pagesize,
102
+      }).then(() => {
103
+        this.showSearch = true
104
+      })
105
+    },
101 106
   }
102 107
 }
103 108
 </script>

+ 1
- 1
src/pages/user/library/navList/index.vue View File

@@ -38,7 +38,7 @@ export default {
38 38
   methods: {
39 39
     ...mapBookAction(['getBookType']),
40 40
     navClick (item) {
41
-      this.$router.push({ name: 'booksList', query: { type: item.BookTypeId } })
41
+      this.$router.push({ name: 'booksList', query: { type: item.BookTypeId, caseid: this.caseid } })
42 42
     }
43 43
   }
44 44
 }

+ 3
- 3
src/pages/user/mainPage/libraryIndex/index.vue View File

@@ -15,11 +15,11 @@
15 15
         </a>
16 16
       </div>
17 17
       <nav class="nav">
18
-        <a v-for="(item, index) in navList" v-if="navList.length < 9 || index<7" :key="index" @click="navClick(item)">
18
+        <a v-for="(item, index) in navList" v-if="(navList || []).length < 9 || index<7" :key="index" @click="navClick(item)">
19 19
           <img :src="item.BookTypeImg" alt>
20 20
           <span>{{item.BookTypeName}}</span>
21 21
         </a>
22
-        <a v-if="navList.length >8 " @click="moreNav()">
22
+        <a v-if="(navList || []).length >8 " @click="moreNav()">
23 23
           <img src="https://spaceofcheng.oss-cn-beijing.aliyuncs.com/test-icon8.png" alt>
24 24
           <span>更多</span>
25 25
         </a>
@@ -152,7 +152,7 @@ export default {
152 152
       this.showAppointmentDialog = false
153 153
     },
154 154
     navClick (item) { // 点击nav
155
-      this.$router.push({ name: 'booksList', query: { type: item.BookTypeId } })
155
+      this.$router.push({ name: 'booksList', query: { type: item.BookTypeId, caseid: this.currentCaseId } })
156 156
     },
157 157
     moreNav () {
158 158
       this.$router.push({ name: 'libraryNavList', query: {caseid: this.currentCaseId} })

+ 22
- 3
src/store/book/index.js View File

@@ -4,8 +4,9 @@ import api from '../../util/api'
4 4
 export default {
5 5
   namespaced: true,
6 6
   state: {
7
-    types: [],
8
-    recommends: [],
7
+    types: {},
8
+    recommends: {},
9
+    books: {},
9 10
   },
10 11
   mutations: {
11 12
     updateTypeList (state, payload) {
@@ -14,6 +15,9 @@ export default {
14 15
     updateRecommendBooks (state, payload) {
15 16
       state.recommends = payload
16 17
     },
18
+    updateBookList (state, payload) {
19
+      state.books = payload
20
+    }
17 21
   },
18 22
   actions: {
19 23
     getBookType ({ commit }, payload) {
@@ -51,6 +55,21 @@ export default {
51 55
           reject(err)
52 56
         })
53 57
       })
54
-    }
58
+    },
59
+    getBookList ({ commit }, payload) {
60
+      return new Promise((resolve, reject) => {
61
+        Ajax({
62
+          ...api.library.getBookList,
63
+          queryData: {
64
+            ...payload
65
+          },
66
+        }).then(res => {
67
+          commit('updateBookList', res)
68
+          resolve(res)
69
+        }).catch((err) => {
70
+          reject(err)
71
+        })
72
+      })
73
+    },
55 74
   }
56 75
 }

+ 2
- 2
src/util/api.js View File

@@ -342,9 +342,9 @@ const $api = {
342 342
       method: 'get',
343 343
       url: `${baseUrl}${wechat}/book/recommend/:caseid`
344 344
     },
345
-    getBookListByType: { // 获取分类书籍列表
345
+    getBookList: { // 获取书籍列表
346 346
       method: 'get',
347
-      url: `${baseUrl}${wechat}/`
347
+      url: `${baseUrl}${wechat}/book`
348 348
     }
349 349
   }
350 350
 }