仿互站小程序
This commit is contained in:
39
vant/notify/index.js
Normal file
39
vant/notify/index.js
Normal file
@@ -0,0 +1,39 @@
|
||||
var e = require("../common/component"), t = require("../common/color"), i = require("../mixins/safe-area");
|
||||
|
||||
(0, e.VantComponent)({
|
||||
mixins: [ (0, i.safeArea)() ],
|
||||
props: {
|
||||
text: String,
|
||||
color: {
|
||||
type: String,
|
||||
value: "#fff"
|
||||
},
|
||||
backgroundColor: {
|
||||
type: String,
|
||||
value: t.RED
|
||||
},
|
||||
duration: {
|
||||
type: Number,
|
||||
value: 3e3
|
||||
},
|
||||
zIndex: {
|
||||
type: Number,
|
||||
value: 110
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
show: function() {
|
||||
var e = this, t = this.data.duration;
|
||||
clearTimeout(this.timer), this.set({
|
||||
show: !0
|
||||
}), t > 0 && t !== 1 / 0 && (this.timer = setTimeout(function() {
|
||||
e.hide();
|
||||
}, t));
|
||||
},
|
||||
hide: function() {
|
||||
clearTimeout(this.timer), this.set({
|
||||
show: !1
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
14
vant/notify/index.json
Normal file
14
vant/notify/index.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-transition": "../transition/index",
|
||||
"forview": "/utils/forview/index",
|
||||
"van-loading": "/vant/loading/index",
|
||||
"van-dialog": "/vant/dialog/index",
|
||||
"van-button": "/vant/button/index",
|
||||
"van-icon": "/vant/icon/index",
|
||||
"van-popup": "/vant/popup/index",
|
||||
"van-tab": "/vant/tab/index",
|
||||
"van-tabs": "/vant/tabs/index"
|
||||
}
|
||||
}
|
4
vant/notify/index.wxml
Normal file
4
vant/notify/index.wxml
Normal file
@@ -0,0 +1,4 @@
|
||||
<van-transition customClass="van-notify" customStyle="background-color:{{backgroundColor}}; color: {{color}}; z-index: {{zIndex}};" name="slide-down" show="{{show}}">
|
||||
<view class="van-notify__safe-top" style="padding-top: {{statusBarHeight}}px" wx:if="{{safeAreaInsetTop}}"></view>
|
||||
{{text}}
|
||||
</van-transition>
|
17
vant/notify/index.wxss
Normal file
17
vant/notify/index.wxss
Normal file
@@ -0,0 +1,17 @@
|
||||
@import "../area/index.wxss";
|
||||
|
||||
.van-notify {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
padding: 6px 15px;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
text-align: center;
|
||||
word-break: break-all;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.van-notify__safe-top {
|
||||
height: 44px;
|
||||
}
|
22
vant/notify/notify.js
Normal file
22
vant/notify/notify.js
Normal file
@@ -0,0 +1,22 @@
|
||||
function e(e) {
|
||||
return (0, n.isObj)(e) ? e : {
|
||||
text: e
|
||||
};
|
||||
}
|
||||
|
||||
function t() {
|
||||
var e = getCurrentPages();
|
||||
return e[e.length - 1];
|
||||
}
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: !0
|
||||
}), exports.default = function(n) {
|
||||
var r = ((n = Object.assign({}, o, e(n))).context || t()).selectComponent(n.selector);
|
||||
delete n.selector, r ? (r.set(n), r.show()) : console.warn("未找到 van-notify 节点,请确认 selector 及 context 是否正确");
|
||||
};
|
||||
|
||||
var n = require("../common/utils"), o = {
|
||||
selector: "#van-notify",
|
||||
duration: 3e3
|
||||
};
|
Reference in New Issue
Block a user