许成详 6 년 전
부모
커밋
d2d789b665

+ 34
- 22
src/pages/user/library/booksList/index.vue 파일 보기

@@ -1,18 +1,36 @@
1 1
 <template>
2 2
   <div class="mainPage">
3 3
     <div>
4
-      1
4
+      <ul>
5
+        <li v-for="(item, index) in bookTypeList" :key="index">
6
+          <libraryListItem :data="item" @appointmentBook="appointmentBook"></libraryListItem>
7
+        </li>
8
+      </ul>
9
+      <van-dialog v-model="showAppointmentDialog" :show-confirm-button="false">
10
+        <div class="dialogContent">
11
+          <span class="title">确认在线预约当前图书?</span>
12
+          <div>
13
+            <span style="color: #666;">在线预约需在2018年12月20日前前往案场借阅图书, 否则 将取消预约资格</span>
14
+          </div>
15
+          <div class="btn">
16
+            <a @click="sureAppointmentBook">确定</a>
17
+            <a @click="showAppointmentDialog = false">取消</a>
18
+          </div>
19
+        </div>
20
+      </van-dialog>
5 21
     </div>
6 22
   </div>
7 23
 </template>
8 24
 
9 25
 <script>
26
+import libraryListItem from '../../../../components/libraryListItem/index'
10 27
 import { mapState, createNamespacedHelpers } from 'vuex'
11 28
 const { mapActions: mapAppActions } = createNamespacedHelpers('app')
12 29
 const { mapState: mapLibraryState, mapActions: mapLibraryAction } = createNamespacedHelpers('library')
13 30
 export default {
14 31
   data () {
15 32
     return {
33
+      showAppointmentDialog: false
16 34
     }
17 35
   },
18 36
   created () {
@@ -22,17 +40,25 @@ export default {
22 40
       CaseList: x => x.app.CaseList,
23 41
     }),
24 42
     ...mapLibraryState({
25
-      navList: x => x.navList
43
+      navList: x => x.navList,
44
+      bookTypeList: x => x.bookTypeList
26 45
     })
27 46
   },
28 47
   components: {
48
+    libraryListItem,
29 49
   },
30 50
   methods: {
31 51
     ...mapAppActions([
32 52
       'getCaseList',
33 53
     ]),
34
-    ...mapLibraryAction(['getNavList']),
54
+    ...mapLibraryAction(['getBookListByType']),
35 55
     navClick (item) {
56
+    },
57
+    appointmentBook () { // 预约图书
58
+      this.showAppointmentDialog = true
59
+    },
60
+    sureAppointmentBook () { // 确定预约图书
61
+      this.showAppointmentDialog = false
36 62
     }
37 63
   }
38 64
 }
@@ -50,27 +76,13 @@ export default {
50 76
     -webkit-overflow-scrolling: touch;
51 77
     transform: translateZ(0);
52 78
     -webkit-transform: translateZ(0);
53
-    .nav {
54
-      width: 100%;
79
+    >ul{
80
+      padding: 0 .16rem;
81
+      margin-bottom: .1rem;
55 82
       position: relative;
56 83
       overflow: hidden;
57
-      font-size: 0;
58
-      > a {
59
-        display: inline-block;
60
-        width: 25%;
61
-        text-align: center;
62
-        margin-top: 0.15rem;
63
-        img {
64
-          height: 0.48rem;
65
-        }
66
-        span {
67
-          width: 100%;
68
-          display: inline-block;
69
-          text-align: center;
70
-          font-size: 0.12rem;
71
-          line-height: 0.22rem;
72
-          margin: 0.08rem auto 0;
73
-        }
84
+      li{
85
+        margin: .1rem auto 0;
74 86
       }
75 87
     }
76 88
   }

+ 60
- 0
src/pages/user/library/booksSearch/index.vue 파일 보기

@@ -0,0 +1,60 @@
1
+<template>
2
+  <div class="mainPage">
3
+    1
4
+  </div>
5
+</template>
6
+
7
+<script>
8
+import { mapState, createNamespacedHelpers } from 'vuex'
9
+const { mapActions: mapAppActions } = createNamespacedHelpers('app')
10
+const { mapState: mapLibraryState, mapActions: mapLibraryAction, mapMutations: mapLibraryMutations } = createNamespacedHelpers('library')
11
+export default {
12
+  data () {
13
+    return {
14
+    }
15
+  },
16
+  created () {
17
+  },
18
+  computed: {
19
+    ...mapState({
20
+      CaseList: x => x.app.CaseList,
21
+    }),
22
+    ...mapLibraryState({
23
+    })
24
+  },
25
+  components: {
26
+  },
27
+  methods: {
28
+    ...mapAppActions([
29
+      'getCaseList',
30
+    ]),
31
+    ...mapLibraryAction(['']),
32
+    ...mapLibraryMutations(['setIndexSearchKey']),
33
+  }
34
+}
35
+</script>
36
+
37
+<style lang="scss" scoped>
38
+.mainPage {
39
+  > div {
40
+    width: 100%;
41
+    position: absolute;
42
+    left: 0;
43
+    top: 0;
44
+    bottom: 0;
45
+    overflow-y: scroll;
46
+    -webkit-overflow-scrolling: touch;
47
+    transform: translateZ(0);
48
+    -webkit-transform: translateZ(0);
49
+    >ul{
50
+      padding: 0 .16rem;
51
+      margin-bottom: .1rem;
52
+      position: relative;
53
+      overflow: hidden;
54
+      li{
55
+        margin: .1rem auto 0;
56
+      }
57
+    }
58
+  }
59
+}
60
+</style>

+ 3
- 6
src/pages/user/mainPage/libraryIndex/index.vue 파일 보기

@@ -4,11 +4,7 @@
4 4
       <div class="header flex-h">
5 5
         <div class="flex-item flex-h">
6 6
           <i class="iconfont icon-sousuo"></i>
7
-          <div class="flex-item">
8
-            <div>
9
-              <input type="text">
10
-            </div>
11
-          </div>
7
+          <router-link class="flex-item" :to="{name: 'booksSearch'}">{{indexSearchKey}}</router-link>
12 8
         </div>
13 9
         <a @click="showDialog = true">
14 10
           <i class="iconfont icon-dingwei"></i>
@@ -81,7 +77,8 @@ export default {
81 77
     }),
82 78
     ...mapLibraryState({
83 79
       navList: x => x.navList,
84
-      bookList: x => x.bookList
80
+      bookList: x => x.bookList,
81
+      indexSearchKey: x => x.indexSearchKey
85 82
     }),
86 83
   },
87 84
   components: {

+ 2
- 19
src/pages/user/mainPage/libraryIndex/page.scss 파일 보기

@@ -16,31 +16,14 @@
16 16
       >div{
17 17
         margin: 0 .1rem 0 .2rem;
18 18
         background: #f2f2f2;
19
-        align-items: center;
20 19
         i{
21 20
           font-size: .15rem;
22 21
           color: #ccc;
23 22
           margin-left: .08rem;
23
+          line-height: .3rem;
24 24
         }
25
-        >div{
25
+        >a{
26 26
           margin-left: .05rem;
27
-          >*{
28
-            display: inline-block;
29
-            vertical-align: middle;
30
-            line-height: .2rem;
31
-          }
32
-          >div{
33
-            width: 100%;
34
-            position: relative;
35
-            overflow: hidden;
36
-            input{
37
-              width: 100%;
38
-              font-size: .13rem;
39
-              color: #ccc;
40
-              background: none;
41
-              padding: .05rem 0;
42
-            }
43
-          }
44 27
         }
45 28
       }
46 29
       >a{

+ 6
- 0
src/pages/user/router.js 파일 보기

@@ -15,6 +15,7 @@ import orderList from './orderList/index' // 城咖啡-点单列表
15 15
 import libraryIndex from './mainPage/libraryIndex/index' // 图书馆首页
16 16
 import userCenter from './mainPage/userCenter/index' // 个人中心
17 17
 import libraryNavList from './library/navList/index' // 图书馆nav
18
+import booksSearch from './library/booksSearch/index' // 搜索图书
18 19
 import booksList from './library/booksList/index' // 图书列表
19 20
 import bindMobile from './bindMobile/bindMobile' // 绑定手机号
20 21
 import lessonOrder from './lessonOrder/index' // 我的订单
@@ -72,6 +73,11 @@ const router = new Router({
72 73
     name: 'libraryNavList',
73 74
     component: libraryNavList,
74 75
     children: []
76
+  }, { // 图书搜索
77
+    path: '/booksSearch',
78
+    name: 'booksSearch',
79
+    component: booksSearch,
80
+    children: []
75 81
   }, { // 图书列表
76 82
     path: '/booksList',
77 83
     name: 'booksList',

+ 105
- 3
src/store/library/index.js 파일 보기

@@ -4,7 +4,8 @@ import api from '../../util/api'
4 4
 export default {
5 5
   namespaced: true,
6 6
   state: {
7
-    navList: [{
7
+    indexSearchKey: '', // 图书首页搜索关键词
8
+    navList: [{ // 图书馆首页nav
8 9
       icon: '',
9 10
       name: '名著',
10 11
       id: ''
@@ -37,7 +38,80 @@ export default {
37 38
       name: '更多',
38 39
       id: 'more'
39 40
     }],
40
-    bookList: [{
41
+    bookList: [{ // 图书馆首页推荐书籍
42
+      img: '',
43
+      name: '书名',
44
+      id: '',
45
+      status: '状态',
46
+      author: '作者',
47
+      publishingHouses: '出版社',
48
+      stock: '10'
49
+    }, {
50
+      img: '',
51
+      name: '书名',
52
+      id: '',
53
+      status: '状态',
54
+      author: '作者',
55
+      publishingHouses: '出版社',
56
+      stock: '10'
57
+    }, {
58
+      img: '',
59
+      name: '书名',
60
+      id: '',
61
+      status: '状态',
62
+      author: '作者',
63
+      publishingHouses: '出版社',
64
+      stock: '10'
65
+    }, {
66
+      img: '',
67
+      name: '书名',
68
+      id: '',
69
+      status: '状态',
70
+      author: '作者',
71
+      publishingHouses: '出版社',
72
+      stock: '10'
73
+    }, {
74
+      img: '',
75
+      name: '书名',
76
+      id: '',
77
+      status: '状态',
78
+      author: '作者',
79
+      publishingHouses: '出版社',
80
+      stock: '10'
81
+    }],
82
+    bookTypeList: [{ // 分类书籍列表
83
+      img: '',
84
+      name: '书名',
85
+      id: '',
86
+      status: '状态',
87
+      author: '作者',
88
+      publishingHouses: '出版社',
89
+      stock: '10'
90
+    }, {
91
+      img: '',
92
+      name: '书名',
93
+      id: '',
94
+      status: '状态',
95
+      author: '作者',
96
+      publishingHouses: '出版社',
97
+      stock: '10'
98
+    }, {
99
+      img: '',
100
+      name: '书名',
101
+      id: '',
102
+      status: '状态',
103
+      author: '作者',
104
+      publishingHouses: '出版社',
105
+      stock: '10'
106
+    }, {
107
+      img: '',
108
+      name: '书名',
109
+      id: '',
110
+      status: '状态',
111
+      author: '作者',
112
+      publishingHouses: '出版社',
113
+      stock: '10'
114
+    }, {
41 115
       img: '',
42 116
       name: '书名',
43 117
       id: '',
@@ -80,6 +154,9 @@ export default {
80 154
     }]
81 155
   },
82 156
   mutations: {
157
+    setIndexSearchKey (state, data) { // 赋值图书首页搜索关键词
158
+      state.indexSearchKey = data || ''
159
+    },
83 160
     setNavInfo (state, data) { // 赋值nav
84 161
       (data || []).map((item) => {
85 162
         state.navList.push({
@@ -107,9 +184,34 @@ export default {
107 184
     },
108 185
     emptyRecommendBookList (state, data) { // 清空精选推荐书籍列表
109 186
       state.bookList = []
110
-    }
187
+    },
188
+    setBookTypeList (state, data) { // 赋值分类书籍列表
189
+      (data || []).map((item) => {
190
+        state.bookList.push({
191
+          img: '',
192
+          name: '书名',
193
+          id: '',
194
+          status: '状态',
195
+          author: '作者',
196
+          publishingHouses: '出版社',
197
+          stock: '10'
198
+        })
199
+      })
200
+    },
111 201
   },
112 202
   actions: {
203
+    getBookListByType (context, data) { // 获取分类书籍列表
204
+      return new Promise((resolve, reject) => {
205
+        Ajax(api.library.getBookListByType.url, {
206
+          method: api.library.getBookListByType.method
207
+        }).then(res => {
208
+          context.commit('setBookTypeList', res)
209
+          resolve(res)
210
+        }).catch((err) => {
211
+          reject(err)
212
+        })
213
+      })
214
+    },
113 215
     getNavList (context, data) { // 获取nav数据
114 216
       return new Promise((resolve, reject) => {
115 217
         Ajax(api.library.getNavList.url, {

+ 4
- 0
src/util/api.js 파일 보기

@@ -341,6 +341,10 @@ const $api = {
341 341
     getRecommendBookList: { // 获取精选推荐书籍列表
342 342
       method: 'get',
343 343
       url: `${baseUrl}${wechat}/`
344
+    },
345
+    getBookListByType: { // 获取分类书籍列表
346
+      method: 'get',
347
+      url: `${baseUrl}${wechat}/`
344 348
     }
345 349
   }
346 350
 }