yuantianjiao 6 år sedan
förälder
incheckning
21cf81ece8

+ 20
- 2
src/components/libraryListItem/index.vue Visa fil

12
         <h5 v-if="!type">{{data.BookDescription}}</h5>
12
         <h5 v-if="!type">{{data.BookDescription}}</h5>
13
         <div v-if="!type" class="flex-h" style="margin-top: .06rem;">
13
         <div v-if="!type" class="flex-h" style="margin-top: .06rem;">
14
           <span class="flex-item">{{data.Author}} 著</span>
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
         </div>
16
         </div>
17
         <div v-if="!type" class="flex-h">
17
         <div v-if="!type" class="flex-h">
18
           <span class="flex-item">{{data.Publisher}}</span>
18
           <span class="flex-item">{{data.Publisher}}</span>
49
 
49
 
50
 export default {
50
 export default {
51
   name: '',
51
   name: '',
52
-  props: ['data', 'type'],
52
+  props: ['data', 'type', 'status'],
53
   data () {
53
   data () {
54
     return {
54
     return {
55
     }
55
     }
56
   },
56
   },
57
   computed: {
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
   components: {
74
   components: {
60
   },
75
   },
62
   },
77
   },
63
   methods: {
78
   methods: {
64
     appointmentBook (id) {
79
     appointmentBook (id) {
80
+      if(this.status == 'reserve' || this.status == 'borrowed' || this.status == 'late'){
81
+        return
82
+      }
65
       this.$emit('appointmentBook', id)
83
       this.$emit('appointmentBook', id)
66
     },
84
     },
67
     itemClick (target) {
85
     itemClick (target) {

+ 27
- 23
src/pages/user/library/borrowedRecord/index.vue Visa fil

7
       normalColor="#666"
7
       normalColor="#666"
8
       @slideChange="slideChange"
8
       @slideChange="slideChange"
9
     >
9
     >
10
-      <div class="subMain" slot="slideTabH-1">
10
+      <div class="subMain" slot="slideTabH-borrowed">
11
         <div>
11
         <div>
12
           <ul>
12
           <ul>
13
-            <li v-for="(item, index) in borrowedRecordList" :key="index">
13
+            <li v-for="(item, index) in books.list" :key="index">
14
               <libraryListItem :data="item" :type="1" @itemClick="borrowedRecordClick"></libraryListItem>
14
               <libraryListItem :data="item" :type="1" @itemClick="borrowedRecordClick"></libraryListItem>
15
             </li>
15
             </li>
16
           </ul>
16
           </ul>
17
         </div>
17
         </div>
18
       </div>
18
       </div>
19
-      <div class="subMain" slot="slideTabH-2">
19
+      <div class="subMain" slot="slideTabH-reserve">
20
         <div>
20
         <div>
21
           <span>请在资格保留时间内至案场借阅图书,超出预约时间将取消预约资格</span>
21
           <span>请在资格保留时间内至案场借阅图书,超出预约时间将取消预约资格</span>
22
           <ul>
22
           <ul>
23
-            <li v-for="(item, index) in appointmentList" :key="index">
23
+            <li v-for="(item, index) in books.list" :key="index">
24
               <libraryListItem :data="item" :type="2"></libraryListItem>
24
               <libraryListItem :data="item" :type="2"></libraryListItem>
25
             </li>
25
             </li>
26
           </ul>
26
           </ul>
53
 <script>
53
 <script>
54
 import slideTabH from '../../../../components/slideTabH/index'
54
 import slideTabH from '../../../../components/slideTabH/index'
55
 import libraryListItem from '../../../../components/libraryListItem/index'
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
 export default {
58
 export default {
60
   data () {
59
   data () {
61
     return {
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
   created () {
68
   created () {
69
+    this.getList()
67
   },
70
   },
68
   computed: {
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
   components: {
76
   components: {
81
     slideTabH
78
     slideTabH
82
   },
79
   },
83
   methods: {
80
   methods: {
84
-    ...mapAppActions([
85
-      'getCaseList',
81
+    ...mapBookAction([
82
+      'getMineBook',
86
     ]),
83
     ]),
87
-    ...mapLibraryAction(['getBookListByType']),
88
-    navClick (item) {
89
-    },
90
     slideChange (e) {
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
     borrowedRecordClick (e) { // 借阅记录点击事件
91
     borrowedRecordClick (e) { // 借阅记录点击事件
95
       this.showDialog = true
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
 </script>
103
 </script>

+ 34
- 10
src/pages/user/mainPage/libraryIndex/index.vue Visa fil

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

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

+ 14
- 0
src/store/book/index.js Visa fil

91
           reject(err)
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 Visa fil

350
       method: 'get',
350
       method: 'get',
351
       url: `${baseUrl}${wechat}/customer/book`
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
 export default $api
359
 export default $api

+ 9
- 1
src/util/util.js Visa fil

107
         resolve(result)
107
         resolve(result)
108
       }).catch(reject)
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
 export default toolClass
121
 export default toolClass