wangfei 6 年之前
父節點
當前提交
cdfe9c7648

+ 2
- 0
src/pages/user/library/booksList/index.vue 查看文件

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

+ 2
- 0
src/pages/user/library/booksSearch/index.vue 查看文件

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

+ 8
- 6
src/pages/user/mainPage/libraryIndex/index.vue 查看文件

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

+ 25
- 1
src/store/book/index.js 查看文件

@@ -24,6 +24,24 @@ export default {
24 24
     updateMineBook (state, payload) {
25 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 46
   actions: {
29 47
     getBookType ({ commit }, payload) {
@@ -106,6 +124,12 @@ export default {
106 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
 }