|
@@ -12,21 +12,8 @@
|
|
|
:class="
|
|
:class="
|
|
|
direction == 'horizontal' ? 'pullrefresh-top-h' : 'pullrefresh-top-v'
|
|
direction == 'horizontal' ? 'pullrefresh-top-h' : 'pullrefresh-top-v'
|
|
|
"
|
|
"
|
|
|
|
|
+ >{{ refreshTopTem }}</view
|
|
|
>
|
|
>
|
|
|
- {{ refreshTem }}
|
|
|
|
|
- <!-- <template
|
|
|
|
|
- v-if="status == 'loading' && (reachTop || reachLeft) && distance > 0"
|
|
|
|
|
- >{{ loadingText.top }}</template
|
|
|
|
|
- >
|
|
|
|
|
- <template
|
|
|
|
|
- v-if="status == 'pulling' && (reachTop || reachLeft) && distance > 0"
|
|
|
|
|
- >{{ pullingText.top }}</template
|
|
|
|
|
- >
|
|
|
|
|
- <template
|
|
|
|
|
- v-if="status == 'loosing' && (reachTop || reachLeft) && distance > 0"
|
|
|
|
|
- >{{ loosingText.top }}</template
|
|
|
|
|
- > -->
|
|
|
|
|
- </view>
|
|
|
|
|
<view class="pullrefresh-content" ref="pull">
|
|
<view class="pullrefresh-content" ref="pull">
|
|
|
<slot></slot>
|
|
<slot></slot>
|
|
|
</view>
|
|
</view>
|
|
@@ -39,26 +26,8 @@
|
|
|
: 'pullrefresh-bottom-v'
|
|
: 'pullrefresh-bottom-v'
|
|
|
"
|
|
"
|
|
|
:style="getBottomStyle"
|
|
:style="getBottomStyle"
|
|
|
|
|
+ >{{ refreshBottomTem }}</view
|
|
|
>
|
|
>
|
|
|
- <template
|
|
|
|
|
- v-if="
|
|
|
|
|
- status == 'loading' && (reachBottom || reachRight) && distance < 0
|
|
|
|
|
- "
|
|
|
|
|
- >{{ loadingText.bottom }}</template
|
|
|
|
|
- >
|
|
|
|
|
- <template
|
|
|
|
|
- v-if="
|
|
|
|
|
- status == 'pulling' && (reachBottom || reachRight) && distance < 0
|
|
|
|
|
- "
|
|
|
|
|
- >{{ pullingText.bottom }}</template
|
|
|
|
|
- >
|
|
|
|
|
- <template
|
|
|
|
|
- v-if="
|
|
|
|
|
- status == 'loosing' && (reachBottom || reachRight) && distance < 0
|
|
|
|
|
- "
|
|
|
|
|
- >{{ loosingText.bottom }}</template
|
|
|
|
|
- >
|
|
|
|
|
- </view>
|
|
|
|
|
</view>
|
|
</view>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
@@ -103,8 +72,8 @@ export default create({
|
|
|
default: {
|
|
default: {
|
|
|
top: '松手释放刷新',
|
|
top: '松手释放刷新',
|
|
|
bottom: '松手释放刷新',
|
|
bottom: '松手释放刷新',
|
|
|
- left: '松手释放刷新',
|
|
|
|
|
- right: '松手释放刷新'
|
|
|
|
|
|
|
+ left: '释放刷新',
|
|
|
|
|
+ right: '加载更多'
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
loadingText: {
|
|
loadingText: {
|
|
@@ -118,7 +87,7 @@ export default create({
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
components: {},
|
|
components: {},
|
|
|
- emits: ['refresh'],
|
|
|
|
|
|
|
+ emits: ['refresh', 'downRefresh'], // refresh 上拉加载、右滑加载更多 downRefresh 下拉刷新、左滑刷新
|
|
|
|
|
|
|
|
setup(props, { emit }) {
|
|
setup(props, { emit }) {
|
|
|
console.log('componentName', componentName);
|
|
console.log('componentName', componentName);
|
|
@@ -203,16 +172,17 @@ export default create({
|
|
|
return style;
|
|
return style;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- const refreshTem = computed(() => {
|
|
|
|
|
|
|
+ /** 刷新 顶部或左侧 */
|
|
|
|
|
+ const refreshTopTem = computed(() => {
|
|
|
const { status, distance } = state;
|
|
const { status, distance } = state;
|
|
|
|
|
|
|
|
- /** 刷新 顶部或左侧 */
|
|
|
|
|
|
|
+ const tag = direction.value == 'vertical' ? 'top' : 'left';
|
|
|
if (
|
|
if (
|
|
|
status == 'loading' &&
|
|
status == 'loading' &&
|
|
|
(reachTop.value || reachLeft.value) &&
|
|
(reachTop.value || reachLeft.value) &&
|
|
|
distance > 0
|
|
distance > 0
|
|
|
) {
|
|
) {
|
|
|
- return props.loadingText.top;
|
|
|
|
|
|
|
+ return props.loadingText[tag];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
if (
|
|
@@ -220,7 +190,7 @@ export default create({
|
|
|
(reachTop.value || reachLeft.value) &&
|
|
(reachTop.value || reachLeft.value) &&
|
|
|
distance > 0
|
|
distance > 0
|
|
|
) {
|
|
) {
|
|
|
- return props.pullingText.top;
|
|
|
|
|
|
|
+ return props.pullingText[tag];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
if (
|
|
@@ -228,10 +198,39 @@ export default create({
|
|
|
(reachTop.value || reachLeft.value) &&
|
|
(reachTop.value || reachLeft.value) &&
|
|
|
distance > 0
|
|
distance > 0
|
|
|
) {
|
|
) {
|
|
|
- return props.loosingText.top;
|
|
|
|
|
|
|
+ return props.loosingText[tag];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return '';
|
|
|
|
|
+ });
|
|
|
|
|
+ /** 刷新 底部或右侧 */
|
|
|
|
|
+ const refreshBottomTem = computed(() => {
|
|
|
|
|
+ const { status, distance } = state;
|
|
|
|
|
+
|
|
|
|
|
+ const tag = direction.value == 'vertical' ? 'bottom' : 'right';
|
|
|
|
|
+ if (
|
|
|
|
|
+ status == 'loading' &&
|
|
|
|
|
+ (reachBottom.value || reachRight.value) &&
|
|
|
|
|
+ distance < 0
|
|
|
|
|
+ ) {
|
|
|
|
|
+ return props.loadingText[tag];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /** 刷新 底部或右侧 */
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ status == 'pulling' &&
|
|
|
|
|
+ (reachBottom.value || reachRight.value) &&
|
|
|
|
|
+ distance < 0
|
|
|
|
|
+ ) {
|
|
|
|
|
+ return props.pullingText[tag];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (
|
|
|
|
|
+ status == 'loosing' &&
|
|
|
|
|
+ (reachBottom.value || reachRight.value) &&
|
|
|
|
|
+ distance < 0
|
|
|
|
|
+ ) {
|
|
|
|
|
+ return props.loosingText[tag];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return '';
|
|
return '';
|
|
|
});
|
|
});
|
|
@@ -321,6 +320,8 @@ export default create({
|
|
|
touch.start(event);
|
|
touch.start(event);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ } else {
|
|
|
|
|
+ preventDefault(event);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -348,6 +349,8 @@ export default create({
|
|
|
preventDefault(event);
|
|
preventDefault(event);
|
|
|
setStatus(ease(deltaX.value));
|
|
setStatus(ease(deltaX.value));
|
|
|
}
|
|
}
|
|
|
|
|
+ } else {
|
|
|
|
|
+ preventDefault(event);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
const touchEnd = () => {
|
|
const touchEnd = () => {
|
|
@@ -362,6 +365,7 @@ export default create({
|
|
|
deltaY.value > 0
|
|
deltaY.value > 0
|
|
|
) {
|
|
) {
|
|
|
dis = 50;
|
|
dis = 50;
|
|
|
|
|
+ emit('downRefresh', refreshDone);
|
|
|
}
|
|
}
|
|
|
if (
|
|
if (
|
|
|
direction.value == 'vertical' &&
|
|
direction.value == 'vertical' &&
|
|
@@ -369,6 +373,7 @@ export default create({
|
|
|
deltaY.value < 0
|
|
deltaY.value < 0
|
|
|
) {
|
|
) {
|
|
|
dis = -50;
|
|
dis = -50;
|
|
|
|
|
+ emit('refresh', refreshDone);
|
|
|
}
|
|
}
|
|
|
if (
|
|
if (
|
|
|
direction.value == 'horizontal' &&
|
|
direction.value == 'horizontal' &&
|
|
@@ -376,6 +381,7 @@ export default create({
|
|
|
deltaX.value > 0
|
|
deltaX.value > 0
|
|
|
) {
|
|
) {
|
|
|
dis = 50;
|
|
dis = 50;
|
|
|
|
|
+ emit('downRefresh', refreshDone);
|
|
|
}
|
|
}
|
|
|
if (
|
|
if (
|
|
|
direction.value == 'horizontal' &&
|
|
direction.value == 'horizontal' &&
|
|
@@ -383,9 +389,9 @@ export default create({
|
|
|
deltaX.value < 0
|
|
deltaX.value < 0
|
|
|
) {
|
|
) {
|
|
|
dis = -50;
|
|
dis = -50;
|
|
|
|
|
+ emit('refresh', refreshDone);
|
|
|
}
|
|
}
|
|
|
setStatus(dis, true);
|
|
setStatus(dis, true);
|
|
|
- emit('refresh', refreshDone);
|
|
|
|
|
} else {
|
|
} else {
|
|
|
setStatus(0);
|
|
setStatus(0);
|
|
|
}
|
|
}
|
|
@@ -402,7 +408,8 @@ export default create({
|
|
|
reachRight,
|
|
reachRight,
|
|
|
reachLeft,
|
|
reachLeft,
|
|
|
getBottomStyle,
|
|
getBottomStyle,
|
|
|
- refreshTem,
|
|
|
|
|
|
|
+ refreshTopTem,
|
|
|
|
|
+ refreshBottomTem,
|
|
|
...toRefs(state)
|
|
...toRefs(state)
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|