mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-08-07 05:49:44 +08:00
[build] 2.4.5
This commit is contained in:
parent
d36f5d5118
commit
feefd39966
2
dist/index.wxss
vendored
2
dist/index.wxss
vendored
File diff suppressed because one or more lines are too long
50
dist/toast/index.js
vendored
50
dist/toast/index.js
vendored
@ -1,32 +1,66 @@
|
||||
module.exports = {
|
||||
showZanToast(title, timeout) {
|
||||
var zanToast = this.data.zanToast || {};
|
||||
clearTimeout(zanToast.timer);
|
||||
const options = formatParameter(title, timeout);
|
||||
|
||||
// 清除上一轮的计时器
|
||||
const { timer = 0 } = this.data.zanToast || {};
|
||||
clearTimeout(timer);
|
||||
|
||||
// 弹层设置~
|
||||
zanToast = {
|
||||
const zanToast = {
|
||||
show: true,
|
||||
title
|
||||
icon: options.icon,
|
||||
image: options.image,
|
||||
title: options.title
|
||||
};
|
||||
this.setData({
|
||||
zanToast
|
||||
});
|
||||
|
||||
var timer = setTimeout(() => {
|
||||
// 传入的显示时长小于0,就认为需要一直显示
|
||||
if (timeout < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 下一轮计时器
|
||||
const nextTimer = setTimeout(() => {
|
||||
this.clearZanToast();
|
||||
}, timeout || 3000);
|
||||
|
||||
this.setData({
|
||||
'zanToast.timer': timer
|
||||
'zanToast.timer': nextTimer
|
||||
});
|
||||
},
|
||||
|
||||
// 清除所有 toast
|
||||
clearZanToast() {
|
||||
var zanToast = this.data.zanToast || {};
|
||||
clearTimeout(zanToast.timer);
|
||||
const { timer = 0 } = this.data.zanToast || {};
|
||||
clearTimeout(timer);
|
||||
|
||||
this.setData({
|
||||
'zanToast.show': false
|
||||
});
|
||||
},
|
||||
|
||||
// 快捷方法,显示 loading
|
||||
showZanLoading(title) {
|
||||
const options = formatParameter(title);
|
||||
|
||||
this.showZanToast({
|
||||
...options,
|
||||
icon: 'loading'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function formatParameter(title, timeout = 0) {
|
||||
// 如果传入的 title 是对象,那么认为所有的配置属性都在这个对象中了
|
||||
if (typeof title === 'object') {
|
||||
return title;
|
||||
}
|
||||
|
||||
return {
|
||||
title,
|
||||
timeout
|
||||
};
|
||||
}
|
||||
|
30
dist/toast/index.wxml
vendored
30
dist/toast/index.wxml
vendored
@ -1,3 +1,31 @@
|
||||
<template name="zan-toast">
|
||||
<view class="zan-toast" wx:if="{{ zanToast.show }}" bindtap="clearZanToast">{{ zanToast.title }}</view>
|
||||
<view
|
||||
class="zan-toast {{ !zanToast.title ? 'zan-toast--notitle' : '' }}"
|
||||
wx:if="{{ zanToast.show }}"
|
||||
bindtap="clearZanToast"
|
||||
>
|
||||
<!-- icon 展示 -->
|
||||
<block
|
||||
wx:if="{{ zanToast.icon || zanToast.image }}"
|
||||
>
|
||||
<view
|
||||
wx:if="{{ zanToast.image }}"
|
||||
class="zan-toast__icon zan-toast__icon-image"
|
||||
style="background-image: url({{ zanToast.image }});"
|
||||
></view>
|
||||
<view
|
||||
wx:elif="{{ zanToast.icon === 'loading' }}"
|
||||
class="zan-toast__icon zan-toast__icon-loading"
|
||||
>
|
||||
<view class="zan-loading"></view>
|
||||
</view>
|
||||
<view
|
||||
wx:else
|
||||
class="zan-toast__icon zan-icon zan-icon-{{ zanToast.icon }}"
|
||||
></view>
|
||||
</block>
|
||||
|
||||
<!-- 文案展示 -->
|
||||
<view wx:if="{{ zanToast.title }}">{{ zanToast.title }}</view>
|
||||
</view>
|
||||
</template>
|
||||
|
2
dist/toast/index.wxss
vendored
2
dist/toast/index.wxss
vendored
@ -1 +1 @@
|
||||
.zan-toast{position:fixed;top:35%;left:20%;transform:translateZ(0) translateY(-100%);background:rgba(0,0,0,.7);color:#fff;font-size:14px;width:60%;line-height:1.5em;margin:0 auto;box-sizing:border-box;padding:10px;text-align:center;border-radius:4px;z-index:100}
|
||||
.zan-toast{position:fixed;top:35%;left:50%;transform:translate3d(-50%,-50%,0);background:rgba(0,0,0,.7);color:#fff;font-size:14px;line-height:1.5em;margin:0 auto;box-sizing:border-box;padding:10px 18px;text-align:center;border-radius:4px;z-index:100}.zan-toast--notitle{padding:18px}.zan-toast__icon{width:40px;height:40px;line-height:40px;margin:0 auto;padding:12px 15px;font-size:38px;text-align:center}.zan-toast__icon-loading{line-height:0}.zan-toast__icon-loading .zan-loading{width:40px;height:40px}.zan-toast__icon-image{background-size:40px;background-position:center;background-repeat:no-repeat}
|
4
dist/toptips/index.js
vendored
4
dist/toptips/index.js
vendored
@ -4,7 +4,7 @@ module.exports = {
|
||||
// 如果已经有一个计时器在了,就清理掉先
|
||||
if (zanTopTips.timer) {
|
||||
clearTimeout(zanTopTips.timer);
|
||||
zanTopTips.timer = undefined;
|
||||
zanTopTips.timer = 0;
|
||||
}
|
||||
|
||||
if (typeof options === 'number') {
|
||||
@ -22,7 +22,7 @@ module.exports = {
|
||||
let timer = setTimeout(() => {
|
||||
this.setData({
|
||||
'zanTopTips.show': false,
|
||||
'zanTopTips.timer': undefined
|
||||
'zanTopTips.timer': 0
|
||||
});
|
||||
}, options.duration);
|
||||
|
||||
|
2
dist/toptips/index.wxss
vendored
2
dist/toptips/index.wxss
vendored
@ -1 +1 @@
|
||||
.zan-toptips{display:block;position:fixed;-webkit-transform:translateZ(0) translateY(-100%);width:100%;min-height:32px;top:0;line-height:2.3;font-size:14px;text-align:center;color:#fff;background-color:#e64340;z-index:110;transition:all .4s ease}.zan-toptips--show{-webkit-transform:translateZ(0) translateY(0)}
|
||||
.zan-toptips{display:block;position:fixed;-webkit-transform:translateZ(0) translateY(-100%);width:100%;min-height:32px;top:0;line-height:2.3;font-size:14px;text-align:center;color:#fff;background-color:#e64340;z-index:110;opacity:0;transition:all .4s ease}.zan-toptips--show{-webkit-transform:translateZ(0) translateY(0);opacity:1}
|
Loading…
x
Reference in New Issue
Block a user