瀏覽代碼

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

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

二進制
src/common/icon/Rectangle.png 查看文件


二進制
src/common/icon/pointer.png 查看文件


+ 264
- 0
src/components/vue-load-more/index.vue 查看文件

1
+<template>
2
+  <div class="yo-scroll" :class="{'down':(state===0),'up':(state==1),refresh:(state===2),touch:touching}" @touchstart="touchStart($event)" @touchmove="touchMove($event)" @touchend="touchEnd($event)">
3
+    <section class="inner" :style="{ transform: 'translate3d(0, 0px, 0)' }">
4
+      <header class="pull-refresh">
5
+        <slot name="pull-refresh">
6
+          <span class="down-tip">下拉更新</span>
7
+          <span class="up-tip">松开刷新数据</span>
8
+          <span class="refresh-tip">加载中……</span>
9
+        </slot>
10
+      </header>
11
+      <slot>
12
+      </slot>
13
+      <footer class="load-more">
14
+        <slot name="load-more">
15
+          <span v-show="downFlag === false">上拉加载更多</span>
16
+          <span v-show="downFlag === true">加载中……</span>
17
+        </slot>
18
+      </footer>
19
+      <div class="nullData" v-show="dataList.noFlag">暂无更多数据</div>
20
+    </section>
21
+  </div>
22
+</template>
23
+
24
+<script>
25
+export default {
26
+  props: {
27
+    offset: { // 默认高度
28
+      type: Number,
29
+      default: 100
30
+    },
31
+    enableInfinite: { // 上拉加载
32
+      type: Boolean,
33
+      default: true
34
+    },
35
+    enableRefresh: { // 下拉刷新
36
+      type: Boolean,
37
+      default: true
38
+    },
39
+    dataList: { // 数据列表
40
+      default: false,
41
+      required: false
42
+    },
43
+    onRefresh: { // 加载方法
44
+      type: Function,
45
+      default: undefined,
46
+      required: false
47
+    },
48
+    onInfinite: { // 刷新方法
49
+      type: Function,
50
+      default: undefined,
51
+      require: false
52
+    }
53
+  },
54
+  data () {
55
+    return {
56
+      top: 0,
57
+      state: 0,
58
+      startX: 0,
59
+      startY: 0,
60
+      touching: false,
61
+      infiniteLoading: false,
62
+      downFlag: false // 用来显示是否加载中
63
+    }
64
+  },
65
+  created () {
66
+
67
+  },
68
+  methods: {
69
+    touchStart (e) {
70
+      this.startY = e.targetTouches[0].pageY
71
+      this.startX = e.targetTouches[0].pageX
72
+      this.startScroll = this.$el.scrollTop || 0
73
+      this.touching = true // 留着有用,不能删除
74
+
75
+      this.dataList.noFlag = false
76
+      this.$el.querySelector('.load-more').style.display = 'block'
77
+    },
78
+    touchMove (e) {
79
+      if (!this.enableRefresh || this.dataList.noFlag || !this.touching) {
80
+        return
81
+      }
82
+      let diff = e.targetTouches[0].pageY - this.startY - this.startScroll
83
+      if (diff > 0) e.preventDefault()
84
+      this.top = Math.pow(diff, 0.8) + (this.state === 2 ? this.offset : 0)
85
+      if (this.state === 2) { // in refreshing
86
+        return
87
+      }
88
+      if (this.top >= this.offset) {
89
+        this.state = 1
90
+      } else {
91
+        this.state = 0
92
+      }
93
+
94
+      let more = this.$el.querySelector('.load-more')
95
+      if (!this.top && this.state === 0) {
96
+        more.style.display = 'block'
97
+      } else {
98
+        more.style.display = 'none'
99
+      }
100
+    },
101
+    touchEnd (e) {
102
+      if (!this.enableRefresh) {
103
+        return
104
+      }
105
+      this.touching = false
106
+      if (this.state === 2) { // in refreshing
107
+        this.state = 2
108
+        this.top = this.offset
109
+        return
110
+      }
111
+      if (this.top >= this.offset) { // do refresh
112
+        this.refresh()
113
+      } else { // cancel refresh
114
+        this.state = 0
115
+        this.top = 0
116
+      }
117
+
118
+      // 用于判断滑动是否在原地 ----begin
119
+      let endX = e.changedTouches[0].pageX
120
+      let endY = e.changedTouches[0].pageY
121
+      let dy = this.startY - endY
122
+      let dx = endX - this.startX
123
+      // 如果滑动距离太短
124
+      if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
125
+        // console.log("滑动距离太短")
126
+        this.downFlag = false
127
+        return
128
+      }
129
+      // --------end--------
130
+
131
+      if (!this.enableInfinite || this.infiniteLoading) {
132
+        return
133
+      }
134
+
135
+      let outerHeight = this.$el.clientHeight
136
+      let innerHeight = this.$el.querySelector('.inner').clientHeight
137
+      let scrollTop = this.$el.scrollTop
138
+      let ptrHeight = this.onRefresh ? this.$el.querySelector('.pull-refresh').clientHeight : 0
139
+      let bottom = innerHeight - outerHeight - scrollTop - ptrHeight
140
+
141
+      // console.log(bottom + " __ " + this.offset)
142
+
143
+      if (bottom <= this.offset && this.state === 0) {
144
+        this.downFlag = true
145
+        this.infinite()
146
+      } else {
147
+        this.$el.querySelector('.load-more').style.display = 'none'
148
+        this.downFlag = false
149
+      }
150
+    },
151
+    refresh () {
152
+      this.state = 2
153
+      this.top = this.offset
154
+      setTimeout(() => {
155
+        this.onRefresh(this.refreshDone)
156
+      }, 1000)
157
+    },
158
+    refreshDone () {
159
+      this.state = 0
160
+      this.top = 0
161
+    },
162
+
163
+    infinite () {
164
+      this.infiniteLoading = true
165
+
166
+      setTimeout(() => {
167
+        this.onInfinite(this.infiniteDone)
168
+      }, 2000)
169
+    },
170
+
171
+    infiniteDone () {
172
+      this.infiniteLoading = false
173
+    }
174
+  }
175
+}
176
+</script>
177
+
178
+<style lang="scss" scoped>
179
+.yo-scroll {
180
+  font-size: 0.24rem;
181
+  position: absolute;
182
+  top: 0;
183
+  right: 0;
184
+  bottom: 0;
185
+  left: 0;
186
+  overflow: auto;
187
+  z-index: 100;
188
+  height: auto;
189
+  -webkit-overflow-scrolling: touch;
190
+  .inner {
191
+    position: absolute;
192
+    top: -0.5rem;
193
+    width: 100%;
194
+    height: auto;
195
+    transition-duration: 300ms;
196
+    .pull-refresh {
197
+      position: relative;
198
+      left: 0;
199
+      top: 0;
200
+      width: 100%;
201
+      height: 0.5rem;
202
+      display: flex;
203
+      display: -webkit-flex;
204
+      align-items: center;
205
+      justify-content: center;
206
+    }
207
+    .load-more {
208
+      height: 0.5rem;
209
+      line-height: 0.5rem;
210
+      display: flex;
211
+      text-align: center;
212
+      align-items: center;
213
+      justify-content: center;
214
+      display: none;
215
+    }
216
+    .nullData {
217
+      // 暂无更多数据样式
218
+      font-size: 0.13rem;
219
+      color: #999999;
220
+      height: 0.5rem;
221
+      line-height: 0.5rem;
222
+      text-align: center;
223
+    }
224
+    .down-tip,
225
+    .refresh-tip,
226
+    .up-tip {
227
+      display: none;
228
+    }
229
+    .up-tip:before,
230
+    .refresh-tip:before {
231
+      content: "";
232
+      display: inline-block;
233
+      width: 1.6rem;
234
+      height: 0.7rem;
235
+      background-size: 70% !important;
236
+      position: absolute;
237
+      top: 0;
238
+      left: 20%;
239
+    }
240
+    // .up-tip:before {
241
+    //   background: url(./loading.gif) no-repeat center;
242
+    // }
243
+    // .refresh-tip:before {
244
+    //   background: url(./loading.gif) no-repeat center;
245
+    // }
246
+  }
247
+}
248
+
249
+.yo-scroll.touch .inner {
250
+  transition-duration: 0;
251
+}
252
+
253
+.yo-scroll.down .down-tip {
254
+  display: block;
255
+}
256
+
257
+.yo-scroll.up .up-tip {
258
+  display: block;
259
+}
260
+
261
+.yo-scroll.refresh .refresh-tip {
262
+  display: block;
263
+}
264
+</style>

二進制
src/components/vue-load-more/loading.gif 查看文件


+ 67
- 35
src/pages/user/mainPage/libraryIndex/index.vue 查看文件

1
 <template>
1
 <template>
2
   <div class="mainPage">
2
   <div class="mainPage">
3
     <div>
3
     <div>
4
-      <div class="header flex-h">
5
-        <div class="flex-item flex-h">
6
-          <i class="iconfont icon-sousuo"></i>
7
-          <router-link
8
-            class="flex-item"
9
-            :to="{name: 'booksSearch', query: {caseid: currentCaseId}}"
10
-          >{{indexSearchKey}}</router-link>
4
+      <loadMore :on-infinite="onInfinite" :dataList="scrollData">
5
+        <div class="header flex-h">
6
+          <div class="flex-item flex-h">
7
+            <i class="iconfont icon-sousuo"></i>
8
+            <router-link
9
+              class="flex-item"
10
+              :to="{name: 'booksSearch', query: {caseid: currentCaseId}}"
11
+            >{{indexSearchKey}}</router-link>
12
+          </div>
13
+          <a @click="showDialog = true">
14
+            <i class="iconfont icon-dingwei"></i>
15
+            <span>{{currentCaseName}}</span>
16
+          </a>
17
+        </div>
18
+        <nav class="nav">
19
+          <a
20
+            v-for="(item, index) in navList"
21
+            v-if="(navList || []).length < 9 || index<7"
22
+            :key="index"
23
+            @click="navClick(item)"
24
+          >
25
+            <img :src="item.BookTypeImg" alt>
26
+            <span>{{item.BookTypeName}}</span>
27
+          </a>
28
+          <a v-if="(navList || []).length >8 " @click="moreNav()">
29
+            <img src="https://spaceofcheng.oss-cn-beijing.aliyuncs.com/test-icon8.png" alt>
30
+            <span>更多</span>
31
+          </a>
32
+        </nav>
33
+        <div class="list">
34
+          <h1>精选推荐</h1>
35
+          <ul>
36
+            <li v-for="(item, index) in books.list" :key="index">
37
+              <libraryListItem :data="item" @appointmentBook="appointmentBook"></libraryListItem>
38
+            </li>
39
+          </ul>
11
         </div>
40
         </div>
12
-        <a @click="showDialog = true">
13
-          <i class="iconfont icon-dingwei"></i>
14
-          <span>{{currentCaseName}}</span>
15
-        </a>
16
-      </div>
17
-      <nav class="nav">
18
-        <a v-for="(item, index) in navList" v-if="(navList || []).length < 9 || index<7" :key="index" @click="navClick(item)">
19
-          <img :src="item.BookTypeImg" alt>
20
-          <span>{{item.BookTypeName}}</span>
21
-        </a>
22
-        <a v-if="(navList || []).length >8 " @click="moreNav()">
23
-          <img src="https://spaceofcheng.oss-cn-beijing.aliyuncs.com/test-icon8.png" alt>
24
-          <span>更多</span>
25
-        </a>
26
-      </nav>
27
-      <div class="list">
28
-        <h1>精选推荐</h1>
29
-        <ul>
30
-          <li v-for="(item, index) in books.list" :key="index">
31
-            <libraryListItem :data="item" :status="mineBookStatus(item)" @appointmentBook="appointmentBook"></libraryListItem>
32
-          </li>
33
-        </ul>
34
-      </div>
41
+      </loadMore>
35
       <van-dialog v-model="showDialog" :show-confirm-button="false">
42
       <van-dialog v-model="showDialog" :show-confirm-button="false">
36
         <div class="dialogContent">
43
         <div class="dialogContent">
37
           <span class="title">选择案场</span>
44
           <span class="title">选择案场</span>
60
 </template>
67
 </template>
61
 
68
 
62
 <script>
69
 <script>
70
+import loadMore from '@/components/vue-load-more/index'
63
 import libraryListItem from '../../../../components/libraryListItem/index'
71
 import libraryListItem from '../../../../components/libraryListItem/index'
64
 import radio from '../../../../components/radio/index'
72
 import radio from '../../../../components/radio/index'
65
 import toolClass from '../../../../util/util'
73
 import toolClass from '../../../../util/util'
77
       currentCaseName: '',
85
       currentCaseName: '',
78
       cases: [],
86
       cases: [],
79
       indexSearchKey: '',
87
       indexSearchKey: '',
80
-      page: 1,
81
-      pagesize: 10,
88
+      page: 0,
89
+      pagesize: 4,
90
+      scrollData: {
91
+        noFlag: false // 暂无更多数据显示
92
+      },
82
       reserveBookId: '',
93
       reserveBookId: '',
83
     }
94
     }
84
   },
95
   },
98
   },
109
   },
99
   components: {
110
   components: {
100
     libraryListItem,
111
     libraryListItem,
101
-    radio
112
+    radio,
113
+    loadMore
102
   },
114
   },
103
   created () {
115
   created () {
104
     if (!this.CaseList.length || this.CaseList === null) {
116
     if (!this.CaseList.length || this.CaseList === null) {
128
   methods: {
140
   methods: {
129
     ...mapAppActions(['getCaseList']),
141
     ...mapAppActions(['getCaseList']),
130
     ...mapBookActions([
142
     ...mapBookActions([
131
-      'getBookType', 
132
-      'getRecommendBook', 
143
+      'getBookType',
144
+      'getRecommendBook',
133
       'getMineBook',
145
       'getMineBook',
134
       'reserveBook',
146
       'reserveBook',
135
     ]),
147
     ]),
150
         page: 1,
162
         page: 1,
151
         pagesize: 10,
163
         pagesize: 10,
152
       })
164
       })
165
+      // this.getRecommendBook({
166
+      //   caseid: this.currentCaseId,
167
+      //   page: this.page,
168
+      //   pagesize: this.pagesize,
169
+      // })
170
+      this.onInfinite()
171
+    },
172
+    onInfinite () {
173
+      this.page++
174
+      let more = this.$el.querySelector('.load-more')
153
       this.getRecommendBook({
175
       this.getRecommendBook({
154
         caseid: this.currentCaseId,
176
         caseid: this.currentCaseId,
155
         page: this.page,
177
         page: this.page,
156
         pagesize: this.pagesize,
178
         pagesize: this.pagesize,
179
+      }).then((res) => {
180
+        console.log(res)
181
+        if (res.list.length < res.pageSize) {
182
+          console.log(more.style.display)
183
+          more.style.display='none'// 隐藏加载条
184
+        } else {
185
+          console.log(more.style.display)
186
+          more.style.display='none'// 隐藏加载条
187
+          this.scrollData.noFlag = true
188
+        }
157
       })
189
       })
158
       this.getMineBook({
190
       this.getMineBook({
159
         page: 1,
191
         page: 1,

+ 5
- 2
src/pages/user/mainPage/userCenter/index.vue 查看文件

12
               <div v-if="user.Phone">{{user.Phone}}</div>
12
               <div v-if="user.Phone">{{user.Phone}}</div>
13
               <div v-else>未绑定</div>
13
               <div v-else>未绑定</div>
14
             </div>
14
             </div>
15
-            <div></div>
15
+            <div class="vip">
16
+              <span>vip1</span>
17
+              <img src="../../../../common/icon/Rectangle.png" alt="">
18
+            </div>
16
           </div>
19
           </div>
17
           <div v-if="user.Phone" class="code">
20
           <div v-if="user.Phone" class="code">
18
             <div>卡号:{{user.Barcode}}</div>
21
             <div>卡号:{{user.Barcode}}</div>
52
         <div class="flex-item privilege-item">
55
         <div class="flex-item privilege-item">
53
           <!-- <i class="iconfont icon-01" @click.stop="toVip"></i> -->
56
           <!-- <i class="iconfont icon-01" @click.stop="toVip"></i> -->
54
           <div class="img-box">
57
           <div class="img-box">
55
-            <img src="../../../../common/icon/userCenter-icon-3.png" width="100%" height="100%" alt>
58
+            <img src="../../../../common/icon/pointer.png" width="100%" height="100%" alt>
56
           </div>
59
           </div>
57
           <span>积分</span>
60
           <span>积分</span>
58
           <span>
61
           <span>

+ 22
- 2
src/pages/user/mainPage/userCenter/page.scss 查看文件

29
   >div:nth-of-type(1){
29
   >div:nth-of-type(1){
30
     display: flex;
30
     display: flex;
31
     margin-bottom: .1rem;
31
     margin-bottom: .1rem;
32
-    img{
32
+    >img{
33
       width: .56rem;
33
       width: .56rem;
34
       height: .56rem;
34
       height: .56rem;
35
       margin-right: .1rem;
35
       margin-right: .1rem;
43
       color: #000;
43
       color: #000;
44
       font-size: .18rem;
44
       font-size: .18rem;
45
     }
45
     }
46
+    .vip{
47
+      width: .24rem;
48
+      position: relative;
49
+      span{
50
+        position: absolute;
51
+        top: 0;
52
+        left: 0;
53
+        font-size: .09rem;
54
+        text-align: center;
55
+        width: 100%;
56
+        line-height: .22rem;
57
+        color: #fff;
58
+      }
59
+      img{
60
+        width: 100%;
61
+      }
62
+    }
46
   }
63
   }
47
   .code{
64
   .code{
48
     text-align: center;
65
     text-align: center;
151
       font-size: .18rem;
168
       font-size: .18rem;
152
     }
169
     }
153
     .img-box {
170
     .img-box {
154
-      width: 0.24rem;
171
+      width: 0.2rem;
155
       height: 0.18rem;
172
       height: 0.18rem;
173
+      img{
174
+        object-fit: contain;
175
+      }
156
     }
176
     }
157
     span:nth-of-type(1){
177
     span:nth-of-type(1){
158
       font-size: .14rem;
178
       font-size: .14rem;

+ 4
- 2
src/store/book/index.js 查看文件

5
   namespaced: true,
5
   namespaced: true,
6
   state: {
6
   state: {
7
     types: {},
7
     types: {},
8
-    recommends: {},
8
+    recommends: {
9
+      list: []
10
+    },
9
     books: {},
11
     books: {},
10
     minebooks: {},
12
     minebooks: {},
11
   },
13
   },
14
       state.types = payload
16
       state.types = payload
15
     },
17
     },
16
     updateRecommendBooks (state, payload) {
18
     updateRecommendBooks (state, payload) {
17
-      state.recommends = payload
19
+      state.recommends.list = state.recommends.list.concat(payload.list)
18
     },
20
     },
19
     updateBookList (state, payload) {
21
     updateBookList (state, payload) {
20
       state.books = payload
22
       state.books = payload

+ 1
- 1
vue.config.js 查看文件

18
   baseUrl: './',
18
   baseUrl: './',
19
   // 生产环境是否生成 sourceMap 文件
19
   // 生产环境是否生成 sourceMap 文件
20
   productionSourceMap: true,
20
   productionSourceMap: true,
21
+  // devtool: 'source-map',
21
   chainWebpack: config => config.plugins.delete('named-chunks'),
22
   chainWebpack: config => config.plugins.delete('named-chunks'),
22
   devServer: {
23
   devServer: {
23
     proxy: {
24
     proxy: {
34
       },
35
       },
35
     },
36
     },
36
     // compress: true,
37
     // compress: true,
37
-    // devtool: 'source-map',
38
     disableHostCheck: true,   // That solved it
38
     disableHostCheck: true,   // That solved it
39
   }
39
   }
40
 }
40
 }