ucToast 支持position:top/bottom
This commit is contained in:
parent
7bec07d04b
commit
a2d4c4b9af
@ -9,11 +9,21 @@ based on
|
||||
*duration: 消失时间(Number),默认2000
|
||||
*distance: 弹窗间距,默认128,可设为0代表重叠
|
||||
*clickable: 是否点击消失(Boolean),默认false
|
||||
*position: top|bottom, 出现在屏幕顶部或底部,默认为 top
|
||||
-->
|
||||
<template>
|
||||
<view class="popup_list">
|
||||
<view v-for="(toast, index) of popup_list" :id="toast.uuid" :key="toast.uuid">
|
||||
<view class="mpopup" :style="{ background: toast.color ,top:index*toast.distance+50+'px'}" :class="[toast.animator,'mpopup-'+toast.type]" @click="close(toast.uuid,index)">
|
||||
<view
|
||||
class="mpopup"
|
||||
:style="{
|
||||
background: toast.color,
|
||||
top: toast.position === 'top' ? index * toast.distance + 50 + 'px' : 'initial',
|
||||
bottom: toast.position === 'bottom' ? index * toast.distance + 50 + 'px' : 'initial',
|
||||
}"
|
||||
:class="[toast.animator, 'mpopup-' + toast.type]"
|
||||
@click="close(toast.uuid, index)"
|
||||
>
|
||||
<view class="icon"></view>
|
||||
<text class="text">{{ toast.content }}</text>
|
||||
</view>
|
||||
@ -28,17 +38,13 @@ based on
|
||||
popup_list: [], //弹窗数组
|
||||
}
|
||||
},
|
||||
props:{
|
||||
},
|
||||
props: {},
|
||||
methods: {
|
||||
open: function (toast) {
|
||||
//生成uuid
|
||||
let uuid=this.guid()
|
||||
toast.uuid=uuid
|
||||
//添加动画
|
||||
toast.animator='fade_Down'
|
||||
|
||||
toast.clickable = toast.clickable || false //判断是否可点击消失/可控制消失
|
||||
toast.uuid = this.guid() //生成uuid
|
||||
toast.animator = 'fade_Down' //添加动画
|
||||
toast.clickable = toast.clickable || false //判断是否可点击消失
|
||||
toast.position = toast.position || 'top'
|
||||
toast.duration = toast.duration || 1500
|
||||
toast.distance = toast.distance || 128 // 弹窗间距
|
||||
toast.type = toast.type || 'info'
|
||||
@ -48,15 +54,15 @@ based on
|
||||
|
||||
if (!toast.clickable) {
|
||||
this.disappear(toast.uuid, toast.duration, toast.complete)
|
||||
}else{ //可点击消失
|
||||
} else {
|
||||
//可点击消失
|
||||
this.$emit('uuidCallback', toast.uuid)
|
||||
}
|
||||
|
||||
},
|
||||
//自动消失
|
||||
disappear: function (uuid, duration, complete) {
|
||||
//退出动画之后,短暂延迟后移除本元素
|
||||
this.fade_out_animator(uuid,duration).then(res=>{
|
||||
this.fade_out_animator(uuid, duration).then((res) => {
|
||||
setTimeout(() => {
|
||||
for (let i = 0; i < this.popup_list.length; i++) {
|
||||
if (this.popup_list[i].uuid == res) {
|
||||
@ -65,7 +71,7 @@ based on
|
||||
this.$forceUpdate()
|
||||
}
|
||||
}
|
||||
if (typeof(complete)==='function'){
|
||||
if (typeof complete === 'function') {
|
||||
complete()
|
||||
}
|
||||
}, 250)
|
||||
@ -73,8 +79,10 @@ based on
|
||||
},
|
||||
fade_out_animator: function (uuid, duration) {
|
||||
//duration秒后退出
|
||||
if(!duration||typeof(duration)!='number'){duration=1500}
|
||||
return new Promise(res=>{
|
||||
if (!duration || typeof duration != 'number') {
|
||||
duration = 1500
|
||||
}
|
||||
return new Promise((res) => {
|
||||
setTimeout(() => {
|
||||
for (let i = 0; i < this.popup_list.length; i++) {
|
||||
if (this.popup_list[i].uuid == uuid) {
|
||||
@ -89,7 +97,9 @@ based on
|
||||
//可控制关闭的弹出框
|
||||
close: function (uuid, ind) {
|
||||
if (ind) {
|
||||
if(!this.popup_list[ind].clickable){return}
|
||||
if (!this.popup_list[ind].clickable) {
|
||||
return
|
||||
}
|
||||
}
|
||||
this.remove_element(uuid).then((res) => {
|
||||
setTimeout(() => {
|
||||
@ -106,7 +116,7 @@ based on
|
||||
},
|
||||
//控制移除元素
|
||||
remove_element: function (uuid) {
|
||||
return new Promise(res=>{
|
||||
return new Promise((res) => {
|
||||
for (var i = 0; i < this.popup_list.length; i++) {
|
||||
if (this.popup_list[i].uuid == uuid) {
|
||||
this.popup_list[i].animator = 'fade_Top'
|
||||
@ -115,13 +125,12 @@ based on
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
//更新
|
||||
update: function (update_list) {
|
||||
for (var i = 0; i < this.popup_list.length; i++) {
|
||||
if (this.popup_list[i].uuid == update_list.uuid) {
|
||||
this.popup_list[i].type=update_list.type;
|
||||
this.popup_list[i].type = update_list.type
|
||||
this.init(this.popup_list[i])
|
||||
this.popup_list[i].content = update_list.content
|
||||
break
|
||||
@ -131,11 +140,12 @@ based on
|
||||
//生成uuid
|
||||
guid: function () {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8)
|
||||
var r = (Math.random() * 16) | 0,
|
||||
v = c == 'x' ? r : (r & 0x3) | 0x8
|
||||
return v.toString(16)
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -148,14 +158,16 @@ based on
|
||||
align-items: center;
|
||||
min-height: 45px;
|
||||
max-width: 80%;
|
||||
transition :all .5s;
|
||||
transition: all 0.5s;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
left: 0;
|
||||
margin: 0 auto;
|
||||
border-radius: 5px;
|
||||
z-index: 998;
|
||||
@media screen and (min-width: 751px) { max-width: 500px }
|
||||
@media screen and (min-width: 751px) {
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
.icon {
|
||||
display: flex;
|
||||
@ -194,7 +206,6 @@ based on
|
||||
.icon {
|
||||
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAHLElEQVR4nOWba2xURRTHfzO73W0trQ8oBEWsRlF8RBQTowLxRXxElGgQjRUfMQpoVEh8xS/yBTBI0A8o8oWHwWciGqPRhKhJozHGDxoDioSXBhAUqTzqttu9Y+bc2e2Wu9su23uXpftPJtCzc++Zc+6Zc2bOnFHGUBy/AF8DdYAHX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YvlzrbHzWS4FTXIAkzDb2g+Q/MpSpK3XdV5eboXXWi+QPEFPcxzZnoLirEYWoEzXUyx26L86/M22Ha4C/o7MPyO5nMybMxljMLOFwD/A16F+qoDPA/VAAAAAElFTkSuQmCC');
|
||||
}
|
||||
|
||||
}
|
||||
.mpopup-info {
|
||||
background: #edf2fc;
|
||||
@ -220,8 +231,7 @@ based on
|
||||
animation: fadeInTop 0.5s forwards;
|
||||
}
|
||||
/*从上到下*/
|
||||
@keyframes fadeInDown
|
||||
{
|
||||
@keyframes fadeInDown {
|
||||
from {
|
||||
opacity: 0;
|
||||
-webkit-transform: translate(0, -100px);
|
||||
@ -234,22 +244,19 @@ based on
|
||||
}
|
||||
}
|
||||
/*从下到上*/
|
||||
@keyframes fadeInTop
|
||||
{
|
||||
@keyframes fadeInTop {
|
||||
from {
|
||||
opacity: 1;
|
||||
-webkit-transform: translate(0, 10px);
|
||||
transform: stranslate(0, 10px);
|
||||
}
|
||||
to {
|
||||
|
||||
opacity: 0;
|
||||
-webkit-transform: translate(0, -100px);
|
||||
transform: stranslate(0, -100px);
|
||||
}
|
||||
}
|
||||
@keyframes rotate360
|
||||
{
|
||||
@keyframes rotate360 {
|
||||
from {
|
||||
transform: rotate(0);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ module.exports = {
|
||||
cloudPath = tempFiles[0].name
|
||||
// #endif
|
||||
} else if (mediaType === 'video') {
|
||||
let [errorChoose, { tempFilePath, tempFile, name }] = await uni.chooseVideo({ sourceType })
|
||||
let [errorChoose, { tempFilePath, tempFile, duration, size, width, height, name }] = await uni.chooseVideo({ sourceType })
|
||||
filePath = tempFilePath
|
||||
cloudPath = 'cloud.mp4'
|
||||
// #ifdef H5
|
||||
|
Loading…
Reference in New Issue
Block a user