yuantianjiao 6 年之前
父節點
當前提交
21cf81ece8

+ 20
- 2
src/components/libraryListItem/index.vue 查看文件

@@ -12,7 +12,7 @@
12 12
         <h5 v-if="!type">{{data.BookDescription}}</h5>
13 13
         <div v-if="!type" class="flex-h" style="margin-top: .06rem;">
14 14
           <span class="flex-item">{{data.Author}} 著</span>
15
-          <span class="status active" @click="appointmentBook(data.BookId)">{{data.Status}}</span>
15
+          <span class="status active" @click="appointmentBook(data.BookId)">{{bookStatus}}</span>
16 16
         </div>
17 17
         <div v-if="!type" class="flex-h">
18 18
           <span class="flex-item">{{data.Publisher}}</span>
@@ -49,12 +49,27 @@
49 49
 
50 50
 export default {
51 51
   name: '',
52
-  props: ['data', 'type'],
52
+  props: ['data', 'type', 'status'],
53 53
   data () {
54 54
     return {
55 55
     }
56 56
   },
57 57
   computed: {
58
+    bookStatus() {
59
+      let status = '在线预约'
60
+      switch(this.status) {
61
+        case 'reserve':
62
+          status = '已预约'
63
+          break
64
+        case 'borrowed':
65
+          status = '借阅中'
66
+          break
67
+        case 'late':
68
+          status = '借阅中'
69
+          break
70
+      }
71
+      return status
72
+    }
58 73
   },
59 74
   components: {
60 75
   },
@@ -62,6 +77,9 @@ export default {
62 77
   },
63 78
   methods: {
64 79
     appointmentBook (id) {
80
+      if(this.status == 'reserve' || this.status == 'borrowed' || this.status == 'late'){
81
+        return
82
+      }
65 83
       this.$emit('appointmentBook', id)
66 84
     },
67 85
     itemClick (target) {

+ 27
- 23
src/pages/user/library/borrowedRecord/index.vue 查看文件

@@ -7,20 +7,20 @@
7 7
       normalColor="#666"
8 8
       @slideChange="slideChange"
9 9
     >
10
-      <div class="subMain" slot="slideTabH-1">
10
+      <div class="subMain" slot="slideTabH-borrowed">
11 11
         <div>
12 12
           <ul>
13
-            <li v-for="(item, index) in borrowedRecordList" :key="index">
13
+            <li v-for="(item, index) in books.list" :key="index">
14 14
               <libraryListItem :data="item" :type="1" @itemClick="borrowedRecordClick"></libraryListItem>
15 15
             </li>
16 16
           </ul>
17 17
         </div>
18 18
       </div>
19
-      <div class="subMain" slot="slideTabH-2">
19
+      <div class="subMain" slot="slideTabH-reserve">
20 20
         <div>
21 21
           <span>请在资格保留时间内至案场借阅图书,超出预约时间将取消预约资格</span>
22 22
           <ul>
23
-            <li v-for="(item, index) in appointmentList" :key="index">
23
+            <li v-for="(item, index) in books.list" :key="index">
24 24
               <libraryListItem :data="item" :type="2"></libraryListItem>
25 25
             </li>
26 26
           </ul>
@@ -53,27 +53,24 @@
53 53
 <script>
54 54
 import slideTabH from '../../../../components/slideTabH/index'
55 55
 import libraryListItem from '../../../../components/libraryListItem/index'
56
-import { mapState, createNamespacedHelpers } from 'vuex'
57
-const { mapActions: mapAppActions } = createNamespacedHelpers('app')
58
-const { mapState: mapLibraryState, mapActions: mapLibraryAction } = createNamespacedHelpers('library')
56
+import { createNamespacedHelpers } from 'vuex'
57
+const { mapState: mapBookState, mapActions: mapBookAction } = createNamespacedHelpers('book')
59 58
 export default {
60 59
   data () {
61 60
     return {
62
-      tabList: [{ value: '借阅记录', id: '1' }, { value: '线上预约记录', id: '2' }],
63
-      showDialog: false
61
+      tabList: [{ value: '借阅记录', id: 'borrowed' }, { value: '线上预约记录', id: 'reserve' }],
62
+      showDialog: false,
63
+      status: 'borrowed',
64
+      page: 1,
65
+      pagesize: 10,
64 66
     }
65 67
   },
66 68
   created () {
69
+    this.getList()
67 70
   },
68 71
   computed: {
69
-    ...mapState({
70
-      CaseList: x => x.app.CaseList,
71
-    }),
72
-    ...mapLibraryState({
73
-      navList: x => x.navList,
74
-      bookTypeList: x => x.bookTypeList,
75
-      borrowedRecordList: x => x.borrowedRecordList,
76
-      appointmentList: x => x.appointmentList
72
+    ...mapBookState({
73
+      books: x => x.minebooks,
77 74
     })
78 75
   },
79 76
   components: {
@@ -81,19 +78,26 @@ export default {
81 78
     slideTabH
82 79
   },
83 80
   methods: {
84
-    ...mapAppActions([
85
-      'getCaseList',
81
+    ...mapBookAction([
82
+      'getMineBook',
86 83
     ]),
87
-    ...mapLibraryAction(['getBookListByType']),
88
-    navClick (item) {
89
-    },
90 84
     slideChange (e) {
91
-      if (e === 1 && !this.appointmentList.length) {
85
+      if (this.status !== this.tabList[e].id) {
86
+        this.status = this.tabList[e].id
87
+        this.page = 1
88
+        this.getList()
92 89
       }
93 90
     },
94 91
     borrowedRecordClick (e) { // 借阅记录点击事件
95 92
       this.showDialog = true
96 93
     },
94
+    getList () {
95
+      this.getMineBook({
96
+        page: this.page,
97
+        pagesize: this.pagesize,
98
+        status: this.status,
99
+      })
100
+    }
97 101
   }
98 102
 }
99 103
 </script>

+ 34
- 10
src/pages/user/mainPage/libraryIndex/index.vue 查看文件

@@ -1,7 +1,7 @@
1 1
 <template>
2 2
   <div class="mainPage">
3 3
     <div>
4
-      <loadMore :on-infinite="onInfinite" :dataList="books.list">
4
+      <loadMore :on-infinite="onInfinite" :dataList="scrollData">
5 5
         <div class="header flex-h">
6 6
           <div class="flex-item flex-h">
7 7
             <i class="iconfont icon-sousuo"></i>
@@ -54,7 +54,7 @@
54 54
         <div class="dialogContent">
55 55
           <span class="title">确认在线预约当前图书?</span>
56 56
           <div>
57
-            <span style="color: #666;">在线预约需在2018年12月20日前前往案场借阅图书, 否则 将取消预约资格</span>
57
+            <span style="color: #666;">在线预约需在{{reserveEndDate}}前前往案场借阅图书, 否则 将取消预约资格</span>
58 58
           </div>
59 59
           <div class="btn">
60 60
             <a @click="sureAppointmentBook">确定</a>
@@ -70,6 +70,7 @@
70 70
 import loadMore from '@/components/vue-load-more/index'
71 71
 import libraryListItem from '../../../../components/libraryListItem/index'
72 72
 import radio from '../../../../components/radio/index'
73
+import toolClass from '../../../../util/util'
73 74
 import { mapState, createNamespacedHelpers } from 'vuex'
74 75
 const { mapActions: mapAppActions } = createNamespacedHelpers('app')
75 76
 const { mapState: mapBookState, mapActions: mapBookActions } = createNamespacedHelpers('book')
@@ -85,10 +86,11 @@ export default {
85 86
       cases: [],
86 87
       indexSearchKey: '',
87 88
       page: 0,
88
-      pagesize: 2,
89
+      pagesize: 4,
89 90
       scrollData: {
90 91
         noFlag: false // 暂无更多数据显示
91
-      }
92
+      },
93
+      reserveBookId: '',
92 94
     }
93 95
   },
94 96
   computed: {
@@ -98,8 +100,12 @@ export default {
98 100
     }),
99 101
     ...mapBookState({
100 102
       navList: x => x.types.list,
101
-      books: x => x.recommends
103
+      books: x => x.recommends,
104
+      mineBooks: x => x.minebooks,
102 105
     }),
106
+    reserveEndDate() {
107
+      return toolClass.calDate(7)
108
+    }
103 109
   },
104 110
   components: {
105 111
     libraryListItem,
@@ -137,6 +143,7 @@ export default {
137 143
       'getBookType',
138 144
       'getRecommendBook',
139 145
       'getMineBook',
146
+      'reserveBook',
140 147
     ]),
141 148
     selectCaseId () { // 选择案场
142 149
       if (this.currentCaseId !== this.caseId) {
@@ -172,25 +179,42 @@ export default {
172 179
       }).then((res) => {
173 180
         console.log(res)
174 181
         if (res.list.length < res.pageSize) {
175
-          console.log(res.list.length)
176
-          more.style.display = 'none' // 隐藏加载条
182
+          console.log(more.style.display)
183
+          more.style.display='none'// 隐藏加载条
177 184
         } else {
178
-          console.log(res.list.length)
185
+          console.log(more.style.display)
186
+          more.style.display='none'// 隐藏加载条
179 187
           this.scrollData.noFlag = true
180 188
         }
181 189
       })
190
+      this.getMineBook({
191
+        page: 1,
192
+        pagesize: 1000,
193
+      })
182 194
     },
183
-    appointmentBook () { // 预约图书
195
+    appointmentBook (id) { // 预约图书
196
+      this.reserveBookId = id
184 197
       this.showAppointmentDialog = true
185 198
     },
186 199
     sureAppointmentBook () { // 确定预约图书
200
+      this.reserveBook({
201
+        bookid: this.reserveBookId,
202
+      }).then(() => {
203
+        this.getMineBook({
204
+          page: 1,
205
+          pagesize: 1000,
206
+        })
207
+      })
187 208
       this.showAppointmentDialog = false
188 209
     },
189 210
     navClick (item) { // 点击nav
190 211
       this.$router.push({ name: 'booksList', query: { type: item.BookTypeId, caseid: this.currentCaseId } })
191 212
     },
192 213
     moreNav () {
193
-      this.$router.push({ name: 'libraryNavList', query: { caseid: this.currentCaseId } })
214
+      this.$router.push({ name: 'libraryNavList', query: {caseid: this.currentCaseId} })
215
+    },
216
+    mineBookStatus (item) {
217
+      return ((this.mineBooks.list || []).filter(x => x.BookId === item.BookId)[0] || {}).BorrowStatus
194 218
     }
195 219
   }
196 220
 }

+ 2
- 1
src/pages/user/mainPage/userCenter/index.vue 查看文件

@@ -103,7 +103,8 @@ export default {
103 103
   name: '',
104 104
   data () {
105 105
     return {
106
-      user: {}
106
+      user: {},
107
+      headimgurl: '',
107 108
     }
108 109
   },
109 110
   computed: {

+ 14
- 0
src/store/book/index.js 查看文件

@@ -91,6 +91,20 @@ export default {
91 91
           reject(err)
92 92
         })
93 93
       })
94
+    },
95
+    reserveBook (c, { bookid }) {
96
+      return new Promise((resolve, reject) => {
97
+        Ajax({
98
+          ...api.library.reserve,
99
+          urlData: {
100
+            bookid,
101
+          },
102
+        }).then(res => {
103
+          resolve(res)
104
+        }).catch((err) => {
105
+          reject(err)
106
+        })
107
+      }) 
94 108
     }
95 109
   }
96 110
 }

+ 4
- 0
src/util/api.js 查看文件

@@ -350,6 +350,10 @@ const $api = {
350 350
       method: 'get',
351 351
       url: `${baseUrl}${wechat}/customer/book`
352 352
     },
353
+    reserve: {
354
+      method: 'post',
355
+      url: `${baseUrl}${wechat}/book/reserve/:bookid`
356
+    },
353 357
   }
354 358
 }
355 359
 export default $api

+ 9
- 1
src/util/util.js 查看文件

@@ -107,7 +107,15 @@ const toolClass = {
107 107
         resolve(result)
108 108
       }).catch(reject)
109 109
     })
110
-  }
110
+  },
111
+  calDate (aa) {
112
+    var date1 = new Date(),
113
+    time1=date1.getFullYear()+"-"+(date1.getMonth()+1)+"-"+date1.getDate();//time1表示当前时间
114
+    var date2 = new Date(date1);
115
+    date2.setDate(date1.getDate()+aa);       
116
+    var time2 = date2.getFullYear()+"年"+ (date2.getMonth()+1) +"月"+date2.getDate()+"日";
117
+    return time2;
118
+  },
111 119
 }
112 120
 
113 121
 export default toolClass