Authored by 陈峰

commit

  1 +<template>
  2 + <Scroll ref="scroll" class="scroll-view" v-bind="attrMerge" v-on="listenerMerge">
  3 + <slot slot="default"></slot>
  4 + <template slot="pulldown" slot-scope="props">
  5 + <div v-if="props.pullDownRefresh"
  6 + class="pulldown-wrapper"
  7 + :style="props.pullDownStyle">
  8 + <div class="pulldown-content">
  9 + <div v-show="props.beforePullDown">
  10 + <div id="beforePullDown"></div>
  11 + </div>
  12 + <div v-show="!props.beforePullDown">
  13 + <div id="afterPullDown"></div>
  14 + </div>
  15 + </div>
  16 + </div>
  17 + </template>
  18 + </Scroll>
  19 +</template>
  20 +
  21 +<script>
  22 +import {Scroll} from 'cube-ui';
  23 +
  24 +export default {
  25 + name: 'ScrollView',
  26 + mounted() {
  27 + this.$nextTick(() => {
  28 + this._initLottie();
  29 + });
  30 + },
  31 + computed: {
  32 + attrMerge() {
  33 + return Object.assign({},
  34 + {
  35 + scrollEvents: ['scroll']
  36 + },
  37 + this.$attrs,
  38 + );
  39 + },
  40 + listenerMerge() {
  41 + return Object.assign({},
  42 + this.$listeners,
  43 + {
  44 + scroll: this.onScroll.bind(this)
  45 + }
  46 + );
  47 + }
  48 + },
  49 + methods: {
  50 + onScroll(pos) {
  51 + if (!this.$refs.scroll.pullDownRefresh) {
  52 + return;
  53 + }
  54 + if (this.$refs.scroll.beforePullDown) {
  55 + if (pos.y > 43) {
  56 + this.lottieBefore.goToAndStop(Math.abs(pos.y - 43) * 15);
  57 + }
  58 + } else {
  59 + this.lottieBefore.goToAndStop(0);
  60 + }
  61 + this.$emit('scroll', pos);
  62 + },
  63 + forceUpdate(dirty) {
  64 + this.$refs.scroll.forceUpdate(dirty);
  65 + },
  66 + _initLottie() {
  67 + setTimeout(() => {
  68 + import(/* webpackChunkName: "lottie-web" */ 'lottie-web').then(lottie => {
  69 + this.lottieBefore = lottie.loadAnimation({
  70 + container: document.getElementById('beforePullDown'), // the dom element that will contain the animation
  71 + renderer: 'svg',
  72 + loop: false,
  73 + autoplay: false,
  74 + path: 'https://cdn.yoho.cn/mapp/lottie/ufo-pull-1227.json' // the path to the animation json
  75 + });
  76 + this.lottieAfter = lottie.loadAnimation({
  77 + container: document.getElementById('afterPullDown'), // the dom element that will contain the animation
  78 + renderer: 'svg',
  79 + loop: true,
  80 + autoplay: true,
  81 + path: 'https://cdn.yoho.cn/mapp/lottie/ufo-refresh-1227.json' // the path to the animation json
  82 + });
  83 + });
  84 + }, 200);
  85 + }
  86 + },
  87 + components: {Scroll}
  88 +};
  89 +</script>
  90 +
  91 +<style lang="scss" scoped>
  92 +.scroll-view {
  93 + position: absolute;
  94 + top: 0;
  95 + right: 0;
  96 + left: 0;
  97 + bottom: 0;
  98 + overflow: hidden;
  99 + background: #fff;
  100 +}
  101 +
  102 +.pulldown-wrapper {
  103 + position: absolute;
  104 + width: 100%;
  105 + left: 0;
  106 + top: -200px;
  107 + display: flex;
  108 + justify-content: center;
  109 + align-items: center;
  110 + transition: all;
  111 +
  112 + .pulldown-content {
  113 + padding-left: 60px;
  114 + padding-right: 60px;
  115 + width: 100%;
  116 + height: 168px;
  117 + }
  118 +}
  119 +</style>
1 <template> 1 <template>
2 <LayoutApp :class="classes"> 2 <LayoutApp :class="classes">
3 - <ScrollView ref="scroll" :observe-dom="false" :pull-up-load="true" @pullingUp="onPullingUp" @pullingDown="onPullingDown"> 3 + <ScrollView ref="scroll" :options="scrollOption" @pulling-up="onPullingUp" @pulling-down="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" @click="onClickProduct"> 6 <div class="product" @click="onClickProduct">
@@ -44,7 +44,7 @@ import ModalUnstock from './components/modal-unstock'; @@ -44,7 +44,7 @@ import ModalUnstock from './components/modal-unstock';
44 import ImgSize from 'components/img-size'; 44 import ImgSize from 'components/img-size';
45 import {Button} from 'cube-ui'; 45 import {Button} from 'cube-ui';
46 import {get} from 'lodash'; 46 import {get} from 'lodash';
47 -import ScrollView from '../../components/layout/scroll-ufo'; 47 +import ScrollView from '../../components/layout/scroll-view';
48 import ProductList from './components/product-list'; 48 import ProductList from './components/product-list';
49 import {createNamespacedHelpers} from 'vuex'; 49 import {createNamespacedHelpers} from 'vuex';
50 50
@@ -55,6 +55,14 @@ export default { @@ -55,6 +55,14 @@ export default {
55 title: '订单', 55 title: '订单',
56 data() { 56 data() {
57 return { 57 return {
  58 + scrollOption: {
  59 + pullDownRefresh: {
  60 + threshold: 70,
  61 + stop: 90
  62 + },
  63 + observeDOM: false,
  64 + pullUpLoad: true
  65 + },
58 classes: {}, 66 classes: {},
59 page: 1, 67 page: 1,
60 modalLoad: false, 68 modalLoad: false,