|
|
@@ -1,14 +1,6 @@
|
|
|
<template>
|
|
|
- <div class="nut-address-list-general">
|
|
|
- <item-contents
|
|
|
- :item="item"
|
|
|
- @delIcon="delShellClick"
|
|
|
- @editIcon="editShellClick"
|
|
|
- @itemClick="itemShellClick"
|
|
|
- @touchstart="holddownstart"
|
|
|
- @touchend="holddownend"
|
|
|
- @touchmove="holddownmove"
|
|
|
- >
|
|
|
+ <div class="nut-address-list-general" v-if="!swipeEdition">
|
|
|
+ <component :is="renderCompontent()" @touchstart="holddownstart" @touchend="holddownend" @touchmove="holddownmove">
|
|
|
<template v-slot:contentTop>
|
|
|
<slot name="contentInfo"></slot>
|
|
|
</template>
|
|
|
@@ -18,7 +10,7 @@
|
|
|
<template v-slot:contentAddr>
|
|
|
<slot name="contentAddrs"></slot>
|
|
|
</template>
|
|
|
- </item-contents>
|
|
|
+ </component>
|
|
|
<div class="nut-address-list-general__mask" v-if="longPress && showMaskRef" @click="maskClick">
|
|
|
<slot name="longpressAll">
|
|
|
<div class="nut-address-list-general__mask-copy" @click="copyCLick">
|
|
|
@@ -27,16 +19,36 @@
|
|
|
<div class="nut-address-list-general__mask-set" @click="setDefault">
|
|
|
<div class="nut-address-list-mask-contain"> 设置<br />默认 </div>
|
|
|
</div>
|
|
|
- <div class="nut-address-list-general__mask-del" @click="delClick">
|
|
|
+ <div class="nut-address-list-general__mask-del" @click="delLongClick">
|
|
|
<div class="nut-address-list-mask-contain"> 删除<br />地址 </div>
|
|
|
</div>
|
|
|
</slot>
|
|
|
</div>
|
|
|
<div class="nut-address-list__mask-bottom" v-if="showMaskRef" @click="hideMaskClick"></div>
|
|
|
</div>
|
|
|
+ <nut-swipe v-else>
|
|
|
+ <div class="nut-address-list-swipe">
|
|
|
+ <component :is="renderCompontent()" @touchmove="swipemove" @touchstart="swipestart">
|
|
|
+ <template v-slot:contentTop>
|
|
|
+ <slot name="contentInfo"></slot>
|
|
|
+ </template>
|
|
|
+ <template v-slot:contentIcon>
|
|
|
+ <slot name="contentIcons"></slot>
|
|
|
+ </template>
|
|
|
+ <template v-slot:contentAddr>
|
|
|
+ <slot name="contentAddrs"></slot>
|
|
|
+ </template>
|
|
|
+ </component>
|
|
|
+ </div>
|
|
|
+ <template #right>
|
|
|
+ <slot name="swiperightbtn">
|
|
|
+ <nut-button shape="square" style="height: 100%" type="danger" @click="swipeDelClick">删除</nut-button>
|
|
|
+ </slot>
|
|
|
+ </template>
|
|
|
+ </nut-swipe>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
-import { ref } from 'vue';
|
|
|
+import { ref, h } from 'vue';
|
|
|
import { createComponent } from '@/packages/utils/create';
|
|
|
const { create } = createComponent('addresslist-general');
|
|
|
import ItemContents from './ItemContents.vue';
|
|
|
@@ -50,29 +62,53 @@ export default create({
|
|
|
longPress: {
|
|
|
type: Boolean,
|
|
|
default: false
|
|
|
+ },
|
|
|
+ swipeEdition: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
}
|
|
|
},
|
|
|
- emits: ['delIcon', 'editIcon', 'itemClick', 'longDown', 'longCopy', 'longSet', 'longDel'],
|
|
|
+ emits: ['delIcon', 'editIcon', 'itemClick', 'longDown', 'longCopy', 'longSet', 'longDel', 'swipeDel'],
|
|
|
components: {
|
|
|
ItemContents
|
|
|
},
|
|
|
|
|
|
setup(props, { emit }) {
|
|
|
+ const renderCompontent = () => {
|
|
|
+ return h(ItemContents, {
|
|
|
+ item: props.item,
|
|
|
+ onDelIcon(event: Event) {
|
|
|
+ delClick(event);
|
|
|
+ },
|
|
|
+ onEditIcon(event: Event) {
|
|
|
+ editClick(event);
|
|
|
+ },
|
|
|
+ onItemClick(event: Event) {
|
|
|
+ itemClick(event);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
let loop: any = null;
|
|
|
+ const moveRef = ref(false);
|
|
|
const showMaskRef = ref(false);
|
|
|
|
|
|
- const delShellClick = (event: Event) => {
|
|
|
+ const delClick = (event: Event) => {
|
|
|
emit('delIcon', event, props.item);
|
|
|
event.stopPropagation();
|
|
|
};
|
|
|
- const editShellClick = (event: Event) => {
|
|
|
+ const editClick = (event: Event) => {
|
|
|
emit('editIcon', event, props.item);
|
|
|
event.stopPropagation();
|
|
|
};
|
|
|
- const itemShellClick = (event: Event) => {
|
|
|
+ const itemClick = (event: Event) => {
|
|
|
+ if (moveRef.value) return;
|
|
|
emit('itemClick', event, props.item);
|
|
|
event.stopPropagation();
|
|
|
};
|
|
|
+ const delLongClick = (event: Event) => {
|
|
|
+ emit('longDel', event, props.item);
|
|
|
+ event.stopPropagation();
|
|
|
+ };
|
|
|
const holdingFunc = (event: Event) => {
|
|
|
loop = 0;
|
|
|
showMaskRef.value = true;
|
|
|
@@ -103,10 +139,6 @@ export default create({
|
|
|
emit('longSet', event, props.item);
|
|
|
event.stopPropagation();
|
|
|
};
|
|
|
- const delClick = (event: Event) => {
|
|
|
- emit('longDel', event, props.item);
|
|
|
- event.stopPropagation();
|
|
|
- };
|
|
|
const maskClick = (event: Event) => {
|
|
|
if (loop != 0) {
|
|
|
// 排除长按时触发点击的情况
|
|
|
@@ -115,20 +147,34 @@ export default create({
|
|
|
event.stopPropagation();
|
|
|
event.preventDefault();
|
|
|
};
|
|
|
+ const swipeDelClick = (event: Event) => {
|
|
|
+ emit('swipeDel', event, props.item);
|
|
|
+ event.stopPropagation();
|
|
|
+ };
|
|
|
+ const swipestart = () => {
|
|
|
+ moveRef.value = false;
|
|
|
+ };
|
|
|
+ const swipemove = () => {
|
|
|
+ moveRef.value = true;
|
|
|
+ };
|
|
|
|
|
|
return {
|
|
|
- delShellClick,
|
|
|
- editShellClick,
|
|
|
- itemShellClick,
|
|
|
+ renderCompontent,
|
|
|
+ showMaskRef,
|
|
|
+ itemClick,
|
|
|
+ editClick,
|
|
|
+ delClick,
|
|
|
+ delLongClick,
|
|
|
holddownstart,
|
|
|
holddownmove,
|
|
|
holddownend,
|
|
|
- showMaskRef,
|
|
|
- delClick,
|
|
|
copyCLick,
|
|
|
hideMaskClick,
|
|
|
setDefault,
|
|
|
- maskClick
|
|
|
+ maskClick,
|
|
|
+ swipeDelClick,
|
|
|
+ swipestart,
|
|
|
+ swipemove
|
|
|
};
|
|
|
}
|
|
|
});
|