|
|
@ -5,6 +5,7 @@ |
|
|
'background-color': perspective ? 'rgba(0,0,0,0.5)' : '#000000'}" |
|
|
'background-color': perspective ? 'rgba(0,0,0,0.5)' : '#000000'}" |
|
|
:current="swiper_current" :circular="circular" |
|
|
:current="swiper_current" :circular="circular" |
|
|
v-if="show_assembly" @click="hideAssembly" |
|
|
v-if="show_assembly" @click="hideAssembly" |
|
|
|
|
|
@transition="transition" |
|
|
@touchmove.stop.prevent="touchmove" |
|
|
@touchmove.stop.prevent="touchmove" |
|
|
@change="e => switchItem(e.detail.current)"> |
|
|
@change="e => switchItem(e.detail.current)"> |
|
|
<swiper-item v-for="(item, index) in images" :key="index" |
|
|
<swiper-item v-for="(item, index) in images" :key="index" |
|
|
@ -12,7 +13,7 @@ |
|
|
<!-- 可移动缩放操作的容器 --> |
|
|
<!-- 可移动缩放操作的容器 --> |
|
|
<movable-area class="movable-area" :scale-area="true"> |
|
|
<movable-area class="movable-area" :scale-area="true"> |
|
|
<movable-view class="movable-view" direction="all" :scale="true" :inertia="true" @scale="scale" :scale-value="scale_values[swiper_current]"> |
|
|
<movable-view class="movable-view" direction="all" :scale="true" :inertia="true" @scale="scale" :scale-value="scale_values[swiper_current]"> |
|
|
<image :src="item" class="swiper-image" mode="aspectFit" @mousewheel.stop="mousewheel"></image> |
|
|
|
|
|
|
|
|
<image :src="item" class="swiper-image" mode="aspectFit" @mousewheel.stop="mousewheel" @longpress="longpress"></image> |
|
|
</movable-view> |
|
|
</movable-view> |
|
|
</movable-area> |
|
|
</movable-area> |
|
|
<!-- 控制器 --> |
|
|
<!-- 控制器 --> |
|
|
@ -40,6 +41,10 @@ |
|
|
<view v-for="(item, index) in images" :key="index" class="indicators-icon" :style="swiper_current == index ? 'background-color:'+ themeColor : ''"></view> |
|
|
<view v-for="(item, index) in images" :key="index" class="indicators-icon" :style="swiper_current == index ? 'background-color:'+ themeColor : ''"></view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
<!-- 底部菜单弹出层 --> |
|
|
|
|
|
<view class="menu-popup" v-if="menu && show_menu" @click.stop> |
|
|
|
|
|
<button @click="download">保存图片</button> |
|
|
|
|
|
</view> |
|
|
</swiper-item> |
|
|
</swiper-item> |
|
|
</swiper> |
|
|
</swiper> |
|
|
</view> |
|
|
</view> |
|
|
@ -75,6 +80,10 @@ |
|
|
animation: { |
|
|
animation: { |
|
|
type: Boolean, // 是否开启动画 |
|
|
type: Boolean, // 是否开启动画 |
|
|
default: false |
|
|
default: false |
|
|
|
|
|
}, |
|
|
|
|
|
menu: { |
|
|
|
|
|
type: Boolean, // 长按图片时是否显示菜单按钮,H5不支持,传参无效果 |
|
|
|
|
|
default: true |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
data(){ |
|
|
data(){ |
|
|
@ -86,7 +95,8 @@ |
|
|
animationObj: {}, // 动画配置对象 |
|
|
animationObj: {}, // 动画配置对象 |
|
|
animationData: {}, // 动画导出执行对象 |
|
|
animationData: {}, // 动画导出执行对象 |
|
|
scale_values: [], // 每张图的缩放比例 |
|
|
scale_values: [], // 每张图的缩放比例 |
|
|
clientY: 0 |
|
|
|
|
|
|
|
|
clientY: 0, |
|
|
|
|
|
show_menu: false |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
created(){ |
|
|
created(){ |
|
|
@ -109,6 +119,12 @@ |
|
|
touchmove(){ |
|
|
touchmove(){ |
|
|
return false; |
|
|
return false; |
|
|
}, |
|
|
}, |
|
|
|
|
|
// swiper 位置发生变化 |
|
|
|
|
|
transition(){ |
|
|
|
|
|
if(this.show_menu){ |
|
|
|
|
|
this.show_menu = false; |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
// swiper被改变 |
|
|
// swiper被改变 |
|
|
switchItem(current){ |
|
|
switchItem(current){ |
|
|
this.swiper_current = current; |
|
|
this.swiper_current = current; |
|
|
@ -151,6 +167,10 @@ |
|
|
}, |
|
|
}, |
|
|
// 关闭隐藏图片 |
|
|
// 关闭隐藏图片 |
|
|
hideAssembly(){ |
|
|
hideAssembly(){ |
|
|
|
|
|
if(this.show_menu){ |
|
|
|
|
|
this.show_menu = false; |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
if(this.$props.animation){ |
|
|
if(this.$props.animation){ |
|
|
this.animationObj.opacity(0).step(); |
|
|
this.animationObj.opacity(0).step(); |
|
|
this.animationData = this.animationObj.export(); |
|
|
this.animationData = this.animationObj.export(); |
|
|
@ -160,6 +180,44 @@ |
|
|
}else{ |
|
|
}else{ |
|
|
this.show_assembly = false; |
|
|
this.show_assembly = false; |
|
|
} |
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
// 长按事件 |
|
|
|
|
|
longpress(event){ |
|
|
|
|
|
// #ifndef H5 |
|
|
|
|
|
if(this.$props.menu){ |
|
|
|
|
|
this.show_menu = true; |
|
|
|
|
|
} |
|
|
|
|
|
// #endif |
|
|
|
|
|
}, |
|
|
|
|
|
// 保存图片 |
|
|
|
|
|
download(){ |
|
|
|
|
|
uni.showLoading({ |
|
|
|
|
|
title: '正在保存' |
|
|
|
|
|
}) |
|
|
|
|
|
this.show_menu = false; |
|
|
|
|
|
uni.downloadFile({ |
|
|
|
|
|
url: this.images[this.swiper_current], |
|
|
|
|
|
success: res => { |
|
|
|
|
|
let tempFilePath = res.tempFilePath; |
|
|
|
|
|
uni.saveFile({ |
|
|
|
|
|
tempFilePath, |
|
|
|
|
|
success: result => { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: '保存成功', |
|
|
|
|
|
icon: 'success' |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
fail: err => { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: '保存失败', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
complete: () => uni.hideLoading() |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
complete: () => uni.hideLoading() |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -230,6 +288,26 @@ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
.menu-popup{ |
|
|
|
|
|
position: fixed; |
|
|
|
|
|
bottom: 0; |
|
|
|
|
|
left: 0; |
|
|
|
|
|
height: max-content; |
|
|
|
|
|
width: 100%; |
|
|
|
|
|
background-color: #FFFFFF; |
|
|
|
|
|
z-index: 1004; |
|
|
|
|
|
padding-bottom: constant(safe-area-inset-bottom); |
|
|
|
|
|
padding-bottom: env(safe-area-inset-bottom); |
|
|
|
|
|
button{ |
|
|
|
|
|
height: 100rpx; |
|
|
|
|
|
line-height: 100rpx; |
|
|
|
|
|
background-color: transparent; |
|
|
|
|
|
border-bottom: 1rpx solid #e5e5e5; |
|
|
|
|
|
&:last-child{ |
|
|
|
|
|
border-bottom: none; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
// 轻提示框样式 |
|
|
// 轻提示框样式 |
|
|
/deep/.uni-sample-toast{ |
|
|
/deep/.uni-sample-toast{ |
|
|
z-index: 1002; |
|
|
z-index: 1002; |
|
|
|