瀏覽代碼

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

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

+ 11
- 7
src/components/vue-load-more/index.vue 查看文件

@@ -8,20 +8,20 @@
8 8
   >
9 9
     <section class="inner" :style="{ transform: 'translate3d(0, 0px, 0)' }">
10 10
       <header class="pull-refresh">
11
-        <slot name="pull-refresh">
11
+        <!-- <slot name="pull-refresh">
12 12
           <span class="down-tip">下拉更新</span>
13 13
           <span class="up-tip">松开刷新数据</span>
14 14
           <span class="refresh-tip">加载中……</span>
15
-        </slot>
15
+        </slot> -->
16 16
       </header>
17 17
       <slot></slot>
18
-      <footer class="load-more">
18
+      <footer class="load-more" v-show="!dataList.noFlag">
19 19
         <slot name="load-more">
20 20
           <span v-show="downFlag === false">上拉加载更多</span>
21 21
           <span v-show="downFlag === true">加载中……</span>
22 22
         </slot>
23 23
       </footer>
24
-      <div class="nullData" v-show="dataList.noFlag">暂无更多数据</div>
24
+      <!-- <div class="nullData" v-show="dataList.noFlag">暂无更多数据</div> -->
25 25
     </section>
26 26
   </div>
27 27
 </template>
@@ -77,8 +77,8 @@ export default {
77 77
       this.startScroll = this.$el.scrollTop || 0
78 78
       this.touching = true // 留着有用,不能删除
79 79
 
80
-      this.dataList.noFlag = false
81
-      this.$el.querySelector('.load-more').style.display = 'block'
80
+      // this.dataList.noFlag = false
81
+      // this.$el.querySelector('.load-more').style.display = 'block'
82 82
     },
83 83
     touchMove (e) {
84 84
       if (this.dataList.noFlag || !this.touching) {
@@ -137,6 +137,10 @@ export default {
137 137
       //   return
138 138
       // }
139 139
 
140
+      if (this.dataList.noFlag) {
141
+        return
142
+      }
143
+
140 144
       let outerHeight = this.$el.clientHeight
141 145
       let innerHeight = this.$el.querySelector('.inner').clientHeight
142 146
       let scrollTop = this.$el.scrollTop
@@ -184,7 +188,7 @@ export default {
184 188
 <style lang="scss" scoped>
185 189
 .yo-scroll {
186 190
   font-size: 0.24rem;
187
-  position: absolute;
191
+  position: fixed;
188 192
   top: 0;
189 193
   right: 0;
190 194
   bottom: 0;

+ 66
- 38
src/pages/user/library/booksList/index.vue 查看文件

@@ -1,33 +1,40 @@
1 1
 <template>
2 2
   <div class="mainPage">
3
-    <div>
4
-      <div class="noData" v-if="show && (books.list || []).length < 1">
5
-        <img src="../../../../common/icon/kong.png" alt>
6
-        <span>暂无内容</span>
3
+    <loadMore :on-infinite="onInfinite" :dataList="scrollData">
4
+      <div class="box">
5
+        <div class="noData" v-if="show && (books.list || []).length < 1">
6
+          <img src="../../../../common/icon/kong.png" alt>
7
+          <span>暂无内容</span>
8
+        </div>
9
+        <ul>
10
+          <li v-for="(item, index) in (books.list || [])" :key="index" v-if="show">
11
+            <libraryListItem
12
+              :data="item"
13
+              :status="mineBookStatus(item)"
14
+              @appointmentBook="appointmentBook"
15
+            ></libraryListItem>
16
+          </li>
17
+        </ul>
7 18
       </div>
8
-      <ul>
9
-        <li v-for="(item, index) in (books.list || [])" :key="index" v-if="show">
10
-          <libraryListItem :data="item" :status="mineBookStatus(item)" @appointmentBook="appointmentBook"></libraryListItem>
11
-        </li>
12
-      </ul>
13
-      <van-dialog v-model="showAppointmentDialog" :show-confirm-button="false">
14
-        <div class="dialogContent">
15
-          <span class="title">确认在线预约当前图书?</span>
16
-          <div>
17
-            <span style="color: #666;">在线预约需在{{reserveEndDate}}前前往案场借阅图书, 否则 将取消预约资格</span>
18
-          </div>
19
-          <div class="btn">
20
-            <a @click="sureAppointmentBook">确定</a>
21
-            <a @click="showAppointmentDialog = false">取消</a>
22
-          </div>
19
+    </loadMore>
20
+    <van-dialog v-model="showAppointmentDialog" :show-confirm-button="false">
21
+      <div class="dialogContent">
22
+        <span class="title">确认在线预约当前图书?</span>
23
+        <div>
24
+          <span style="color: #666;">在线预约需在{{reserveEndDate}}前前往案场借阅图书, 否则 将取消预约资格</span>
25
+        </div>
26
+        <div class="btn">
27
+          <a @click="sureAppointmentBook">确定</a>
28
+          <a @click="showAppointmentDialog = false">取消</a>
23 29
         </div>
24
-      </van-dialog>
25
-    </div>
30
+      </div>
31
+    </van-dialog>
26 32
   </div>
27 33
 </template>
28 34
 
29 35
 <script>
30 36
 import libraryListItem from '../../../../components/libraryListItem/index'
37
+import loadMore from '@/components/vue-load-more/index'
31 38
 import { createNamespacedHelpers } from 'vuex'
32 39
 import toolClass from '../../../../util/util'
33 40
 const { mapState: mapBookState, mapActions: mapBookAction } = createNamespacedHelpers('book')
@@ -43,14 +50,20 @@ export default {
43 50
       },
44 51
       reserveBookId: '',
45 52
       show: false,
53
+      scrollData: {
54
+        noFlag: false // 暂无更多数据显示
55
+      },
46 56
     }
47 57
   },
48 58
   created () {
49 59
     this.query.bookType = this.$route.query.type
50 60
     this.query.caseid = this.$route.query.caseid
51
-    this.getBookList(this.query).then(() => {
52
-      this.show = true
61
+    this.$nextTick(() => {
62
+      this.onInfinite()
53 63
     })
64
+    // this.getBookList(this.query).then(() => {
65
+    //   this.show = true
66
+    // })
54 67
     this.getMineBook({
55 68
       page: 1,
56 69
       pagesize: 1000,
@@ -61,12 +74,13 @@ export default {
61 74
       books: x => x.books,
62 75
       mineBooks: x => x.minebooks,
63 76
     }),
64
-    reserveEndDate() {
77
+    reserveEndDate () {
65 78
       return toolClass.calDate(7)
66 79
     }
67 80
   },
68 81
   components: {
69 82
     libraryListItem,
83
+    loadMore
70 84
   },
71 85
   methods: {
72 86
     ...mapBookAction([
@@ -93,6 +107,20 @@ export default {
93 107
     },
94 108
     mineBookStatus (item) {
95 109
       return ((this.mineBooks.list || []).filter(x => x.BookId === item.BookId && (x.BorrowStatus == '4' || x.BorrowStatus == '1' || x.BorrowStatus == '0'))[0] || {}).BorrowStatus
110
+    },
111
+    onInfinite () {
112
+      let more = this.$el.querySelector('.load-more')
113
+      this.getBookList(this.query).then((res) => {
114
+        this.show = true
115
+        this.query.page++
116
+        res.list = res.list || []
117
+        if (res.list.length < res.pageSize) {
118
+          more.style.display = 'none'// 隐藏加载条
119
+          this.scrollData.noFlag = true
120
+        } else {
121
+          more.style.display = 'none'// 隐藏加载条
122
+        }
123
+      })
96 124
     }
97 125
   }
98 126
 }
@@ -100,16 +128,16 @@ export default {
100 128
 
101 129
 <style lang="scss" scoped>
102 130
 .mainPage {
103
-  > div {
131
+  .box {
104 132
     width: 100%;
105
-    position: absolute;
106
-    left: 0;
107
-    top: 0;
108
-    bottom: 0;
109
-    overflow-y: scroll;
110
-    -webkit-overflow-scrolling: touch;
111
-    transform: translateZ(0);
112
-    -webkit-transform: translateZ(0);
133
+    // position: absolute;
134
+    // left: 0;
135
+    // top: 0;
136
+    // bottom: 0;
137
+    // overflow-y: scroll;
138
+    // -webkit-overflow-scrolling: touch;
139
+    // transform: translateZ(0);
140
+    // -webkit-transform: translateZ(0);
113 141
     .noData {
114 142
       width: 100%;
115 143
       margin: 0.5rem auto 0;
@@ -130,13 +158,13 @@ export default {
130 158
         margin: 0.05rem auto 0;
131 159
       }
132 160
     }
133
-    >ul{
134
-      padding: 0 .16rem;
135
-      margin-bottom: .1rem;
161
+    > ul {
162
+      padding: 0 0.16rem;
163
+      margin-bottom: 0.1rem;
136 164
       position: relative;
137 165
       overflow: hidden;
138
-      li{
139
-        margin: .1rem auto 0;
166
+      li {
167
+        margin: 0.1rem auto 0;
140 168
       }
141 169
     }
142 170
   }

+ 68
- 38
src/pages/user/library/booksSearch/index.vue 查看文件

@@ -1,35 +1,41 @@
1 1
 <template>
2 2
   <div class="mainPage flex-v">
3
-    <div class="header flex-h">
4
-      <div class="flex-item flex-h">
5
-        <i class="iconfont icon-sousuo"></i>
6
-        <div class="flex-item">
7
-          <div>
8
-            <input type="text" v-model="searchKey" placeholder="请输入图书名">
3
+    <loadMore :on-infinite="onInfinite" :dataList="scrollData">
4
+      <div class="header flex-h">
5
+        <div class="flex-item flex-h">
6
+          <i class="iconfont icon-sousuo"></i>
7
+          <div class="flex-item">
8
+            <div>
9
+              <input type="text" v-model="searchKey" placeholder="请输入图书名">
10
+            </div>
9 11
           </div>
10 12
         </div>
13
+        <a @click="search">搜索</a>
11 14
       </div>
12
-      <a @click="search">搜索</a>
13
-    </div>
14
-    <div class="searchRemark" v-if="showSearch">
15
-      <span>
16
-        关于“
17
-        <em>{{doSearchKey}}</em>”的搜索结果:
18
-      </span>
19
-    </div>
20
-    <div class="flex-item" :hidden="!showSearch">
21
-      <div>
22
-        <div class="noData" v-if="(books.list || []).length < 1">
23
-          <img src="../../../../common/icon/kong.png" alt>
24
-          <span>暂无内容</span>
15
+      <div class="searchRemark" v-if="showSearch">
16
+        <span>
17
+          关于“
18
+          <em>{{doSearchKey}}</em>”的搜索结果:
19
+        </span>
20
+      </div>
21
+      <div class="flex-item list" :hidden="!showSearch">
22
+        <div>
23
+          <div class="noData" v-if="(books.list || []).length < 1">
24
+            <img src="../../../../common/icon/kong.png" alt>
25
+            <span>暂无内容</span>
26
+          </div>
27
+          <ul v-else>
28
+            <li v-for="(item, index) in books.list" :key="index">
29
+              <libraryListItem
30
+                :data="item"
31
+                :status="mineBookStatus(item)"
32
+                @appointmentBook="appointmentBook"
33
+              ></libraryListItem>
34
+            </li>
35
+          </ul>
25 36
         </div>
26
-        <ul v-else>
27
-          <li v-for="(item, index) in books.list" :key="index">
28
-            <libraryListItem :data="item" :status="mineBookStatus(item)" @appointmentBook="appointmentBook"></libraryListItem>
29
-          </li>
30
-        </ul>
31 37
       </div>
32
-    </div>
38
+    </loadMore>
33 39
     <van-dialog v-model="showAppointmentDialog" :show-confirm-button="false">
34 40
       <div class="dialogContent">
35 41
         <span class="title">确认在线预约当前图书?</span>
@@ -48,6 +54,7 @@
48 54
 <script>
49 55
 import libraryListItem from '../../../../components/libraryListItem/index'
50 56
 import toolClass from '../../../../util/util'
57
+import loadMore from '@/components/vue-load-more/index'
51 58
 import { mapState, createNamespacedHelpers } from 'vuex'
52 59
 const { mapState: mapBookState, mapActions: mapBookAction } = createNamespacedHelpers('book')
53 60
 export default {
@@ -62,6 +69,9 @@ export default {
62 69
       pagesize: 10,
63 70
       doSearchKey: '',
64 71
       reserveBookId: '',
72
+      scrollData: {
73
+        noFlag: false // 暂无更多数据显示
74
+      },
65 75
     }
66 76
   },
67 77
   created () {
@@ -76,13 +86,14 @@ export default {
76 86
       books: x => x.books,
77 87
       mineBooks: x => x.minebooks,
78 88
     }),
79
-    reserveEndDate() {
89
+    reserveEndDate () {
80 90
       return toolClass.calDate(7)
81 91
     }
82 92
   },
83 93
   mounted () {
84 94
   },
85 95
   components: {
96
+    loadMore,
86 97
     libraryListItem
87 98
   },
88 99
   methods: {
@@ -95,7 +106,7 @@ export default {
95 106
     search () { // 搜索
96 107
       if (this.searchKey !== '') {
97 108
         this.doSearchKey = this.searchKey
98
-        this.getSearchList()
109
+        this.onInfinite()
99 110
       } else {
100 111
         this.$toast('搜索关键词不能为空')
101 112
       }
@@ -128,7 +139,26 @@ export default {
128 139
     },
129 140
     mineBookStatus (item) {
130 141
       return ((this.mineBooks.list || []).filter(x => x.BookId === item.BookId && (x.BorrowStatus == '4' || x.BorrowStatus == '1' || x.BorrowStatus == '0'))[0] || {}).BorrowStatus
131
-    }
142
+    },
143
+    onInfinite () {
144
+      let more = this.$el.querySelector('.load-more')
145
+      this.getBookList({
146
+        caseid: this.caseid,
147
+        name: this.doSearchKey,
148
+        page: this.page,
149
+        pagesize: this.pagesize,
150
+      }).then((res) => {
151
+        this.showSearch = true
152
+        this.page++
153
+        res.list = res.list || []
154
+        if (res.list.length < res.pageSize) {
155
+          more.style.display = 'none'// 隐藏加载条
156
+          this.scrollData.noFlag = true
157
+        } else {
158
+          more.style.display = 'none'// 隐藏加载条
159
+        }
160
+      })
161
+    },
132 162
   }
133 163
 }
134 164
 </script>
@@ -187,19 +217,19 @@ export default {
187 217
       }
188 218
     }
189 219
   }
190
-  > .flex-item {
220
+  .list {
191 221
     position: relative;
192 222
     overflow: hidden;
193 223
     > div {
194 224
       width: 100%;
195
-      position: absolute;
196
-      left: 0;
197
-      top: 0;
198
-      bottom: 0;
199
-      overflow-y: scroll;
200
-      -webkit-overflow-scrolling: touch;
201
-      transform: translateZ(0);
202
-      -webkit-transform: translateZ(0);
225
+      // position: absolute;
226
+      // left: 0;
227
+      // top: 0;
228
+      // bottom: 0;
229
+      // overflow-y: scroll;
230
+      // -webkit-overflow-scrolling: touch;
231
+      // transform: translateZ(0);
232
+      // -webkit-transform: translateZ(0);
203 233
       .noData {
204 234
         width: 100%;
205 235
         margin: 0.5rem auto 0;
@@ -229,7 +259,7 @@ export default {
229 259
           width: 100%;
230 260
           position: relative;
231 261
           overflow: hidden;
232
-          margin: .1rem auto 0;
262
+          margin: 0.1rem auto 0;
233 263
         }
234 264
       }
235 265
     }

+ 12
- 9
src/pages/user/mainPage/libraryIndex/index.vue 查看文件

@@ -34,7 +34,11 @@
34 34
           <h1>精选推荐</h1>
35 35
           <ul>
36 36
             <li v-for="(item, index) in books.list" :key="index">
37
-              <libraryListItem :data="item" :status="mineBookStatus(item)" @appointmentBook="appointmentBook"></libraryListItem>
37
+              <libraryListItem
38
+                :data="item"
39
+                :status="mineBookStatus(item)"
40
+                @appointmentBook="appointmentBook"
41
+              ></libraryListItem>
38 42
             </li>
39 43
           </ul>
40 44
         </div>
@@ -85,8 +89,8 @@ export default {
85 89
       currentCaseName: '',
86 90
       cases: [],
87 91
       indexSearchKey: '',
88
-      page: 0,
89
-      pagesize: 8,
92
+      page: 1,
93
+      pagesize: 3,
90 94
       scrollData: {
91 95
         noFlag: false // 暂无更多数据显示
92 96
       },
@@ -103,7 +107,7 @@ export default {
103 107
       books: x => x.recommends,
104 108
       mineBooks: x => x.minebooks,
105 109
     }),
106
-    reserveEndDate() {
110
+    reserveEndDate () {
107 111
       return toolClass.calDate(7)
108 112
     }
109 113
   },
@@ -175,20 +179,19 @@ export default {
175 179
         page: 1,
176 180
         pagesize: 1000,
177 181
       })
178
-      this.page++
179 182
       let more = this.$el.querySelector('.load-more')
180 183
       this.getRecommendBook({
181 184
         caseid: this.currentCaseId,
182 185
         page: this.page,
183 186
         pagesize: this.pagesize,
184 187
       }).then((res) => {
185
-        console.log(res)
188
+        this.page++
186 189
         res.list = res.list || []
187 190
         if (res.list.length < res.pageSize) {
188
-          more.style.display='none'// 隐藏加载条
191
+          more.style.display = 'none'// 隐藏加载条
189 192
           this.scrollData.noFlag = true
190 193
         } else {
191
-          more.style.display='none'// 隐藏加载条
194
+          more.style.display = 'none'// 隐藏加载条
192 195
         }
193 196
       })
194 197
     },
@@ -212,7 +215,7 @@ export default {
212 215
       this.$router.push({ name: 'booksList', query: { type: item.BookTypeId, caseid: this.currentCaseId } })
213 216
     },
214 217
     moreNav () {
215
-      this.$router.push({ name: 'libraryNavList', query: {caseid: this.currentCaseId} })
218
+      this.$router.push({ name: 'libraryNavList', query: { caseid: this.currentCaseId } })
216 219
     },
217 220
     mineBookStatus (item) {
218 221
       return ((this.mineBooks.list || []).filter(x => x.BookId === item.BookId && (x.BorrowStatus == '4' || x.BorrowStatus == '1' || x.BorrowStatus == '0'))[0] || {}).BorrowStatus