Authored by 陈峰

commit

@@ -22,18 +22,16 @@ @@ -22,18 +22,16 @@
22 :pullDownRefresh="pullDownRefresh" 22 :pullDownRefresh="pullDownRefresh"
23 :pullDownStyle="pullDownStyle" 23 :pullDownStyle="pullDownStyle"
24 :beforePullDown="beforePullDown" 24 :beforePullDown="beforePullDown"
25 - :isPullingDown="isPullingDown"  
26 :bubbleY="bubbleY" 25 :bubbleY="bubbleY"
27 > 26 >
28 <div ref="pulldown" class="pulldown-wrapper" :style="pullDownStyle" v-if="pullDownRefresh"> 27 <div ref="pulldown" class="pulldown-wrapper" :style="pullDownStyle" v-if="pullDownRefresh">
29 - <div class="before-trigger" v-if="beforePullDown">  
30 - <span>加载中</span> 28 + <div class="before-trigger" v-show="beforePullDown">
  29 + <div id="beforePullDown"></div>
31 </div> 30 </div>
32 - <div class="after-trigger" v-else>  
33 - <div v-if="isPullingDown" class="loading">  
34 - <span>...</span> 31 + <div class="after-trigger" v-show="!beforePullDown">
  32 + <div class="loading">
  33 + <div id="afterPullDown"></div>
35 </div> 34 </div>
36 - <div v-else><span>{{refreshTxt}}</span></div>  
37 </div> 35 </div>
38 </div> 36 </div>
39 </slot> 37 </slot>
@@ -42,6 +40,7 @@ @@ -42,6 +40,7 @@
42 40
43 <script> 41 <script>
44 import {BetterScroll} from 'cube-ui'; 42 import {BetterScroll} from 'cube-ui';
  43 +import lottie from 'lottie-web';
45 44
46 function getRect(el) { 45 function getRect(el) {
47 if (el instanceof window.SVGElement) { 46 if (el instanceof window.SVGElement) {
@@ -106,7 +105,12 @@ export default { @@ -106,7 +105,12 @@ export default {
106 }, 105 },
107 pullDownRefresh: { 106 pullDownRefresh: {
108 type: null, 107 type: null,
109 - default: false 108 + default() {
  109 + return {
  110 + threshold: 70,
  111 + stop: 90
  112 + };
  113 + }
110 }, 114 },
111 pullUpLoad: { 115 pullUpLoad: {
112 type: null, 116 type: null,
@@ -143,7 +147,6 @@ export default { @@ -143,7 +147,6 @@ export default {
143 return { 147 return {
144 beforePullDown: true, 148 beforePullDown: true,
145 isRebounding: false, 149 isRebounding: false,
146 - isPullingDown: false,  
147 isPullUpLoad: false, 150 isPullUpLoad: false,
148 pullUpDirty: true, 151 pullUpDirty: true,
149 pullDownStyle: '', 152 pullDownStyle: '',
@@ -162,11 +165,14 @@ export default { @@ -162,11 +165,14 @@ export default {
162 } 165 }
163 }, 166 },
164 created() { 167 created() {
165 - this.pullDownInitTop = -50; 168 + this.pullDownInitTop = -90;
166 }, 169 },
167 mounted() { 170 mounted() {
168 setTimeout(() => { 171 setTimeout(() => {
169 this.initScroll(); 172 this.initScroll();
  173 + setTimeout(() => {
  174 + this.pullDownInitTop = 0 - this.$refs.pulldown.clientHeight;
  175 + }, 0);
170 }, 20); 176 }, 20);
171 }, 177 },
172 methods: { 178 methods: {
@@ -214,6 +220,7 @@ export default { @@ -214,6 +220,7 @@ export default {
214 if (this.pullUpLoad) { 220 if (this.pullUpLoad) {
215 this._initPullUpLoad(); 221 this._initPullUpLoad();
216 } 222 }
  223 + this._initLottie();
217 }, 224 },
218 disable() { 225 disable() {
219 this.scroll && this.scroll.disable(); 226 this.scroll && this.scroll.disable();
@@ -234,8 +241,7 @@ export default { @@ -234,8 +241,7 @@ export default {
234 this.scroll.destroy(); 241 this.scroll.destroy();
235 }, 242 },
236 forceUpdate(dirty) { 243 forceUpdate(dirty) {
237 - if (this.pullDownRefresh && this.isPullingDown) {  
238 - this.isPullingDown = false; 244 + if (this.pullDownRefresh) {
239 this._reboundPullDown().then(() => { 245 this._reboundPullDown().then(() => {
240 this._afterPullDown(); 246 this._afterPullDown();
241 }); 247 });
@@ -248,10 +254,26 @@ export default { @@ -248,10 +254,26 @@ export default {
248 this.refresh(); 254 this.refresh();
249 } 255 }
250 }, 256 },
  257 + _initLottie() {
  258 + this.lottieBefore = lottie.loadAnimation({
  259 + container: document.getElementById('beforePullDown'), // the dom element that will contain the animation
  260 + renderer: 'svg',
  261 + loop: false,
  262 + autoplay: true,
  263 + path: 'https://cdn.yoho.cn/mapp/lottie/ufo-pull-1227.json' // the path to the animation json
  264 + });
  265 + this.lottieAfter = lottie.loadAnimation({
  266 + container: document.getElementById('afterPullDown'), // the dom element that will contain the animation
  267 + renderer: 'svg',
  268 + loop: true,
  269 + autoplay: true,
  270 + path: 'https://cdn.yoho.cn/mapp/lottie/ufo-refresh-1227.json' // the path to the animation json
  271 + });
  272 +
  273 + },
251 _initPullDownRefresh() { 274 _initPullDownRefresh() {
252 this.scroll.on('pullingDown', () => { 275 this.scroll.on('pullingDown', () => {
253 this.beforePullDown = false; 276 this.beforePullDown = false;
254 - this.isPullingDown = true;  
255 this.$emit('pullingDown'); 277 this.$emit('pullingDown');
256 }); 278 });
257 this.scroll.on('scroll', (pos) => { 279 this.scroll.on('scroll', (pos) => {
@@ -259,13 +281,15 @@ export default { @@ -259,13 +281,15 @@ export default {
259 return; 281 return;
260 } 282 }
261 if (this.beforePullDown) { 283 if (this.beforePullDown) {
262 - this.bubbleY = Math.max(0, pos.y + this.pullDownInitTop);  
263 - this.pullDownStyle = `top:${Math.min(pos.y + this.pullDownInitTop, 10)}px`;  
264 - } else {  
265 - this.bubbleY = 0; 284 + if (pos.y > 43) {
  285 + this.lottieBefore.goToAndStop(Math.abs(pos.y - 43) * 15);
  286 + } else {
  287 + this.lottieBefore.goToAndStop(0);
  288 + }
266 } 289 }
  290 + this.pullDownStyle = `top:${Math.min(pos.y + this.pullDownInitTop, 0)}px`;
267 if (this.isRebounding) { 291 if (this.isRebounding) {
268 - this.pullDownStyle = `top:${10 - (this.pullDownRefresh.stop || 40 - pos.y)}px`; 292 + this.pullDownStyle = `top:${0 - (this.pullDownRefresh.stop || 40 - pos.y)}px`;
269 } 293 }
270 }); 294 });
271 }, 295 },
@@ -333,16 +357,14 @@ export default { @@ -333,16 +357,14 @@ export default {
333 357
334 .pulldown-wrapper { 358 .pulldown-wrapper {
335 position: absolute; 359 position: absolute;
336 - width: 100%;  
337 - left: 0; 360 + left: 60px;
  361 + right: 60px;
338 display: flex; 362 display: flex;
339 justify-content: center; 363 justify-content: center;
340 align-items: center; 364 align-items: center;
341 transition: all; 365 transition: all;
342 -  
343 - .after-trigger {  
344 - margin-top: 10px;  
345 - } 366 + width: 630px;
  367 + height: 168px;
346 } 368 }
347 369
348 .pullup-wrapper { 370 .pullup-wrapper {
1 <template> 1 <template>
2 <LayoutApp class="ufo-font" :class="classes"> 2 <LayoutApp class="ufo-font" :class="classes">
3 - <ScrollView ref="scroll" :observe-dom="false" :pull-up-load="true" @pullingUp="onPullingUp"> 3 + <ScrollView ref="scroll" :observe-dom="false" :pull-up-load="true" @pullingUp="onPullingUp" @pullingDown="onPullingDown">
4 <div class="order-page"> 4 <div class="order-page">
5 <div class="title">出售中</div> 5 <div class="title">出售中</div>
6 <div class="product"> 6 <div class="product">
@@ -86,6 +86,11 @@ export default { @@ -86,6 +86,11 @@ export default {
86 } 86 }
87 this.$refs.scroll.forceUpdate(); 87 this.$refs.scroll.forceUpdate();
88 }, 88 },
  89 + onPullingDown() {
  90 + setTimeout(() => {
  91 + this.$refs.scroll.forceUpdate();
  92 + }, 2000);
  93 + },
89 onChangePrice(skc) { 94 onChangePrice(skc) {
90 this.$refs.modalPrice.show({skc, product: this.productInfo}); 95 this.$refs.modalPrice.show({skc, product: this.productInfo});
91 }, 96 },