wangfei 6 years ago
parent
commit
cdfe9c7648

+ 2
- 0
src/pages/user/library/booksList/index.vue View File

73
       'getBookList',
73
       'getBookList',
74
       "getMineBook",
74
       "getMineBook",
75
       "reserveBook",
75
       "reserveBook",
76
+      "updateBookLeftNum",
76
     ]),
77
     ]),
77
     appointmentBook (id) { // 预约图书
78
     appointmentBook (id) { // 预约图书
78
       this.reserveBookId = id
79
       this.reserveBookId = id
82
       this.reserveBook({
83
       this.reserveBook({
83
         bookid: this.reserveBookId,
84
         bookid: this.reserveBookId,
84
       }).then(() => {
85
       }).then(() => {
86
+        this.updateBookLeftNum(this.reserveBookId)
85
         this.getMineBook({
87
         this.getMineBook({
86
           page: 1,
88
           page: 1,
87
           pagesize: 1000,
89
           pagesize: 1000,

+ 2
- 0
src/pages/user/library/booksSearch/index.vue View File

90
       'getBookList',
90
       'getBookList',
91
       'getMineBook',
91
       'getMineBook',
92
       'reserveBook',
92
       'reserveBook',
93
+      "updateBookLeftNum",
93
     ]),
94
     ]),
94
     search () { // 搜索
95
     search () { // 搜索
95
       if (this.searchKey !== '') {
96
       if (this.searchKey !== '') {
107
       this.reserveBook({
108
       this.reserveBook({
108
         bookid: this.reserveBookId,
109
         bookid: this.reserveBookId,
109
       }).then(() => {
110
       }).then(() => {
111
+        this.updateBookLeftNum(this.reserveBookId)
110
         this.getMineBook({
112
         this.getMineBook({
111
           page: 1,
113
           page: 1,
112
           pagesize: 1000,
114
           pagesize: 1000,

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

25
             <img :src="item.BookTypeImg" alt>
25
             <img :src="item.BookTypeImg" alt>
26
             <span>{{item.BookTypeName}}</span>
26
             <span>{{item.BookTypeName}}</span>
27
           </a>
27
           </a>
28
-          <a v-if="(navList || []).length >8 " @click="moreNav()">
28
+          <a v-if="(navList || []).length > 8 " @click="moreNav()">
29
             <img src="https://spaceofcheng.oss-cn-beijing.aliyuncs.com/test-icon8.png" alt>
29
             <img src="https://spaceofcheng.oss-cn-beijing.aliyuncs.com/test-icon8.png" alt>
30
             <span>更多</span>
30
             <span>更多</span>
31
           </a>
31
           </a>
34
           <h1>精选推荐</h1>
34
           <h1>精选推荐</h1>
35
           <ul>
35
           <ul>
36
             <li v-for="(item, index) in books.list" :key="index">
36
             <li v-for="(item, index) in books.list" :key="index">
37
-              <libraryListItem :data="item" @appointmentBook="appointmentBook"></libraryListItem>
37
+              <libraryListItem :data="item" :status="mineBookStatus(item)" @appointmentBook="appointmentBook"></libraryListItem>
38
             </li>
38
             </li>
39
           </ul>
39
           </ul>
40
         </div>
40
         </div>
144
       'getRecommendBook',
144
       'getRecommendBook',
145
       'getMineBook',
145
       'getMineBook',
146
       'reserveBook',
146
       'reserveBook',
147
+      'updateRecommendBookLeftNum',
147
     ]),
148
     ]),
148
     selectCaseId () { // 选择案场
149
     selectCaseId () { // 选择案场
149
       if (this.currentCaseId !== this.caseId) {
150
       if (this.currentCaseId !== this.caseId) {
170
       this.onInfinite()
171
       this.onInfinite()
171
     },
172
     },
172
     onInfinite () {
173
     onInfinite () {
174
+      this.getMineBook({
175
+        page: 1,
176
+        pagesize: 1000,
177
+      })
173
       this.page++
178
       this.page++
174
       let more = this.$el.querySelector('.load-more')
179
       let more = this.$el.querySelector('.load-more')
175
       this.getRecommendBook({
180
       this.getRecommendBook({
187
           this.scrollData.noFlag = true
192
           this.scrollData.noFlag = true
188
         }
193
         }
189
       })
194
       })
190
-      this.getMineBook({
191
-        page: 1,
192
-        pagesize: 1000,
193
-      })
194
     },
195
     },
195
     appointmentBook (id) { // 预约图书
196
     appointmentBook (id) { // 预约图书
196
       this.reserveBookId = id
197
       this.reserveBookId = id
200
       this.reserveBook({
201
       this.reserveBook({
201
         bookid: this.reserveBookId,
202
         bookid: this.reserveBookId,
202
       }).then(() => {
203
       }).then(() => {
204
+        this.updateRecommendBookLeftNum(this.reserveBookId)
203
         this.getMineBook({
205
         this.getMineBook({
204
           page: 1,
206
           page: 1,
205
           pagesize: 1000,
207
           pagesize: 1000,

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

24
     updateMineBook (state, payload) {
24
     updateMineBook (state, payload) {
25
       state.minebooks = payload
25
       state.minebooks = payload
26
     },
26
     },
27
+    updateRecommendBookLeftNum(state, bookid) {
28
+      state.recommends = {...state.recommends, list: state.recommends.list.map(x => {
29
+        if(x.BookId == bookid){
30
+          x.LeftNum = x.LeftNum - 1
31
+          return x
32
+        }
33
+        return x
34
+      })}
35
+    },
36
+    updateBookLeftNum(state, bookid) {
37
+      state.books = {...state.books, list: state.books.list.map(x => {
38
+        if(x.BookId == bookid){
39
+          x.LeftNum = x.LeftNum - 1
40
+          return x
41
+        }
42
+        return x
43
+      })}
44
+    },
27
   },
45
   },
28
   actions: {
46
   actions: {
29
     getBookType ({ commit }, payload) {
47
     getBookType ({ commit }, payload) {
106
           reject(err)
124
           reject(err)
107
         })
125
         })
108
       }) 
126
       }) 
109
-    }
127
+    },
128
+    updateBookLeftNum({ commit }, bookid) {
129
+      commit('updateBookLeftNum', bookid)
130
+    },
131
+    updateRecommendBookLeftNum({ commit }, bookid) {
132
+      commit('updateRecommendBookLeftNum', bookid)
133
+    },
110
   }
134
   }
111
 }
135
 }