Browse Source

Merge branch 'dev' of http://git.ycjcjy.com/SpaceOfCheng/wechat into dev

yuantianjiao 6 years ago
parent
commit
bec5d6e51e

+ 44
- 11
src/components/libraryListItem/index.vue View File

4
       <a>
4
       <a>
5
         <img :src="data.BookImg" class="centerLabel cover" alt>
5
         <img :src="data.BookImg" class="centerLabel cover" alt>
6
       </a>
6
       </a>
7
-      <span v-if="type === 1" class="active">状态值</span>
7
+      <span v-if="type === 1" :class="data.BorrowStatus=='0'?'active':''">{{myBookStatus}}</span>
8
     </div>
8
     </div>
9
     <div class="flex-item">
9
     <div class="flex-item">
10
       <div>
10
       <div>
22
           </span>
22
           </span>
23
         </div>
23
         </div>
24
         <div v-if="type === 1" class="flex-h" style="margin-top: .06rem;">
24
         <div v-if="type === 1" class="flex-h" style="margin-top: .06rem;">
25
-          <span class="flex-item">应还时间:{{data.ReturnDate}}</span>
25
+          <span class="flex-item">应还时间:{{toolClass.dateFormat(data.EndDate, 'yyyy-MM-dd')}}</span>
26
         </div>
26
         </div>
27
         <div v-if="type === 1" class="flex-h">
27
         <div v-if="type === 1" class="flex-h">
28
           <span class="flex-item">{{data.CaseName}}</span>
28
           <span class="flex-item">{{data.CaseName}}</span>
29
-          <span>已归还</span>
30
-          <span>已逾期
31
-            <em>4</em>天
29
+          <span v-if="data.BorrowStatus=='3' || data.BorrowStatus=='2'">已归还</span>
30
+          <span v-if="data.BorrowStatus == '1'">已借阅
31
+            <em>{{borrowDay}}</em>天
32
+          </span>
33
+          <span v-if="data.BorrowStatus == '0'">已逾期
34
+            <em>{{lateDay}}</em>天
32
           </span>
35
           </span>
33
         </div>
36
         </div>
34
         <div v-if="type === 2" class="flex-h" style="margin-top: .06rem;">
37
         <div v-if="type === 2" class="flex-h" style="margin-top: .06rem;">
35
-          <span class="flex-item">预约时间:{{data.appointmentDate}}</span>
38
+          <span class="flex-item">预约时间:{{toolClass.dateFormat(data.ReserveDate)}}</span>
36
         </div>
39
         </div>
37
         <div v-if="type === 2" class="flex-h" style="margin-top: 0;">
40
         <div v-if="type === 2" class="flex-h" style="margin-top: 0;">
38
-          <span class="flex-item">预约资格将保留至:2018-12-08</span>
41
+          <span class="flex-item">预约资格将保留至:{{toolClass.dateFormat(data.ReserveEndDate, 'yyyy-MM-dd')}}</span>
39
         </div>
42
         </div>
40
         <div v-if="type === 2" class="flex-h" style="margin-top: 0;">
43
         <div v-if="type === 2" class="flex-h" style="margin-top: 0;">
41
           <span class="flex-item">{{data.CaseName}}</span>
44
           <span class="flex-item">{{data.CaseName}}</span>
46
 </template>
49
 </template>
47
 
50
 
48
 <script>
51
 <script>
52
+import toolClass from '../../util/util'
49
 
53
 
50
 export default {
54
 export default {
51
   name: '',
55
   name: '',
58
     bookStatus() {
62
     bookStatus() {
59
       let status = '在线预约'
63
       let status = '在线预约'
60
       switch(this.status) {
64
       switch(this.status) {
61
-        case 'reserve':
65
+        case '4':
62
           status = '已预约'
66
           status = '已预约'
63
           break
67
           break
64
-        case 'borrowed':
68
+        case '1':
65
           status = '借阅中'
69
           status = '借阅中'
66
           break
70
           break
67
-        case 'late':
71
+        case '0':
68
           status = '借阅中'
72
           status = '借阅中'
69
           break
73
           break
70
       }
74
       }
71
       return status
75
       return status
76
+    },
77
+    myBookStatus() {
78
+      let status = ''
79
+      switch(this.data.BorrowStatus) {
80
+        case '4':
81
+          status = '已预约'
82
+          break
83
+        case '1':
84
+          status = '借阅中'
85
+          break
86
+        case '0':
87
+          status = '逾期未还'
88
+          break
89
+        case '3':
90
+          status = '逾期归还'
91
+          break
92
+        case '2':
93
+          status = '已归还'
94
+          break
95
+      }
96
+      return status
97
+    },
98
+    lateDay() {
99
+      const nowdata = new Date()
100
+      return toolClass.diffDate(new Date(this.data.EndDate), nowdata)
101
+    },
102
+    borrowDay() {
103
+      const nowdata = new Date()
104
+      return toolClass.diffDate(new Date(this.data.BorrowDate), nowdata)
72
     }
105
     }
73
   },
106
   },
74
   components: {
107
   components: {
77
   },
110
   },
78
   methods: {
111
   methods: {
79
     appointmentBook (id) {
112
     appointmentBook (id) {
80
-      if(this.status == 'reserve' || this.status == 'borrowed' || this.status == 'late'){
113
+      if(this.status == '4' || this.status == '1' || this.status == '0'){
81
         return
114
         return
82
       }
115
       }
83
       this.$emit('appointmentBook', id)
116
       this.$emit('appointmentBook', id)

+ 51
- 20
src/pages/user/library/borrowedRecord/index.vue View File

7
       normalColor="#666"
7
       normalColor="#666"
8
       @slideChange="slideChange"
8
       @slideChange="slideChange"
9
     >
9
     >
10
-      <div class="subMain" slot="slideTabH-borrowed">
10
+      <div class="subMain" slot="slideTabH-1">
11
         <div>
11
         <div>
12
           <ul>
12
           <ul>
13
-            <li v-for="(item, index) in books.list" :key="index">
13
+            <li v-for="(item, index) in borrowBooks.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-reserve">
19
+      <div class="subMain" slot="slideTabH-2">
20
         <div>
20
         <div>
21
           <span>请在资格保留时间内至案场借阅图书,超出预约时间将取消预约资格</span>
21
           <span>请在资格保留时间内至案场借阅图书,超出预约时间将取消预约资格</span>
22
           <ul>
22
           <ul>
23
-            <li v-for="(item, index) in books.list" :key="index">
23
+            <li v-for="(item, index) in reserveBooks.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>
31
       <div class="borrowedRecordContent flex-h" @click="showDialog = false">
31
       <div class="borrowedRecordContent flex-h" @click="showDialog = false">
32
         <div class="img">
32
         <div class="img">
33
           <a>
33
           <a>
34
-            <img src class="centerLabel" alt>
34
+            <img :src="currentItem.BookImg" class="centerLabel" alt>
35
           </a>
35
           </a>
36
         </div>
36
         </div>
37
         <div class="flex-item">
37
         <div class="flex-item">
38
           <div>
38
           <div>
39
             <div>
39
             <div>
40
-              <span>状态值</span>
40
+              <span>{{myBookStatus}}</span>
41
             </div>
41
             </div>
42
-            <span class="title">书名</span>
43
-            <span>借阅时间:</span>
44
-            <span>应还时间:</span>
45
-            <span>归还时间:</span>
42
+            <span class="title">{{currentItem.BookName}}</span>
43
+            <span>借阅时间:{{toolClass.dateFormat(currentItem.BorrowDate)}}</span>
44
+            <span>应还时间:{{toolClass.dateFormat(currentItem.EndDate, 'yyyy-MM-dd')}}</span>
45
+            <span>归还时间:{{currentItem.BorrowStatus == '2' || currentItem.BorrowStatus == '3' ? '暂未归还' : toolClass.dateFormat(currentItem.ReturnDate)}}</span>
46
           </div>
46
           </div>
47
         </div>
47
         </div>
48
       </div>
48
       </div>
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 toolClass from '../../../../util/util'
56
 import { createNamespacedHelpers } from 'vuex'
57
 import { createNamespacedHelpers } from 'vuex'
57
 const { mapState: mapBookState, mapActions: mapBookAction } = createNamespacedHelpers('book')
58
 const { mapState: mapBookState, mapActions: mapBookAction } = createNamespacedHelpers('book')
58
 export default {
59
 export default {
59
   data () {
60
   data () {
60
     return {
61
     return {
61
-      tabList: [{ value: '借阅记录', id: 'borrowed' }, { value: '线上预约记录', id: 'reserve' }],
62
+      tabList: [{ value: '借阅记录', id: '1' }, { value: '线上预约记录', id: '2' }],
62
       showDialog: false,
63
       showDialog: false,
63
-      status: 'borrowed',
64
+      status: '1',
64
       page: 1,
65
       page: 1,
65
       pagesize: 10,
66
       pagesize: 10,
67
+      reserveBooks: {},
68
+      borrowBooks: {},
69
+      currentItem: {},
66
     }
70
     }
67
   },
71
   },
68
   created () {
72
   created () {
69
-    this.getList()
73
+    this.getList('1')
74
+    this.getList('2')
70
   },
75
   },
71
   computed: {
76
   computed: {
72
-    ...mapBookState({
73
-      books: x => x.minebooks,
74
-    })
77
+    myBookStatus() {
78
+      let status = ''
79
+      switch(this.currentItem.BorrowStatus) {
80
+        case '4':
81
+          status = '已预约'
82
+          break
83
+        case '1':
84
+          status = '借阅中'
85
+          break
86
+        case '0':
87
+          status = '逾期未还'
88
+          break
89
+        case '3':
90
+          status = '逾期归还'
91
+          break
92
+        case '2':
93
+          status = '已归还'
94
+          break
95
+      }
96
+      return status
97
+    },
75
   },
98
   },
76
   components: {
99
   components: {
77
     libraryListItem,
100
     libraryListItem,
84
     slideChange (e) {
107
     slideChange (e) {
85
       if (this.status !== this.tabList[e].id) {
108
       if (this.status !== this.tabList[e].id) {
86
         this.status = this.tabList[e].id
109
         this.status = this.tabList[e].id
87
-        this.page = 1
88
-        this.getList()
110
+        // this.page = 1
111
+        // this.getList()
89
       }
112
       }
90
     },
113
     },
91
     borrowedRecordClick (e) { // 借阅记录点击事件
114
     borrowedRecordClick (e) { // 借阅记录点击事件
115
+      this.currentItem = e
92
       this.showDialog = true
116
       this.showDialog = true
93
     },
117
     },
94
-    getList () {
118
+    getList (status) {
119
+      const _that = this
95
       this.getMineBook({
120
       this.getMineBook({
96
         page: this.page,
121
         page: this.page,
97
         pagesize: this.pagesize,
122
         pagesize: this.pagesize,
98
-        status: this.status,
123
+        status: status == '1'?'1,3,2,0':'4',
124
+      }).then((res) => {
125
+        if(status == '1') {
126
+          _that.borrowBooks = res
127
+        } else {
128
+          _that.reserveBooks = res
129
+        }
99
       })
130
       })
100
     }
131
     }
101
   }
132
   }

+ 2
- 1
src/store/book/index.js View File

67
         Ajax({
67
         Ajax({
68
           ...api.library.getBookList,
68
           ...api.library.getBookList,
69
           queryData: {
69
           queryData: {
70
-            ...payload
70
+            ...payload,
71
+            showzero: '0',
71
           },
72
           },
72
         }).then(res => {
73
         }).then(res => {
73
           commit('updateBookList', res)
74
           commit('updateBookList', res)

+ 7
- 0
src/util/util.js View File

116
     var time2 = date2.getFullYear()+"年"+ (date2.getMonth()+1) +"月"+date2.getDate()+"日";
116
     var time2 = date2.getFullYear()+"年"+ (date2.getMonth()+1) +"月"+date2.getDate()+"日";
117
     return time2;
117
     return time2;
118
   },
118
   },
119
+  diffDate (begintime, endtime) {
120
+    var begintime_ms = Date.parse(begintime);
121
+    var endtime_ms = Date.parse(endtime); 
122
+    var date3=endtime_ms-begintime_ms
123
+    var days=Math.floor(date3/(24*3600*1000))
124
+    return days
125
+  },
119
 }
126
 }
120
 
127
 
121
 export default toolClass
128
 export default toolClass