jiaqingjiayi-xiaochengxu/甲情_甲意/miniprogram/node_modules/antd-mini/less/Toast/index.js
2024-11-10 15:01:22 +08:00

50 lines
1.5 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var props_1 = require("./props");
var fmtEvent_1 = tslib_1.__importDefault(require("../_util/fmtEvent"));
Component({
props: props_1.ToastDefaultProps,
data: {
show: false,
timer: null,
},
didUpdate: function (prev) {
if (!prev.visible && this.props.visible) {
this.handleShowToast();
}
else if (!this.props.visible && this.data.show) {
this.closeMask();
}
},
didMount: function () {
if (this.props.visible) {
this.handleShowToast();
}
},
methods: {
closeMask: function () {
var _a, _b;
if (this.data.timer) {
clearTimeout(this.data.timer);
}
this.setData({ show: false, timer: null });
(_b = (_a = this.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a, (0, fmtEvent_1.default)(this.props, {}));
},
handleShowToast: function () {
var _this = this;
this.setData({ show: true });
if (this.props.duration > 0) {
var timer = setTimeout(function () {
_this.closeMask();
}, this.props.duration);
this.setData({ timer: timer });
}
},
handleClickMask: function () {
if (this.props.showMask && this.props.maskCloseable) {
this.closeMask();
}
},
},
});