This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
yoshop-wechat/components/toast/index.js

36 lines
712 B
JavaScript
Raw Normal View History

2021-07-16 16:36:54 +08:00
'use strict';
var DEFAULT_DATA = {
show: false,
message: '',
icon: '',
image: '',
mask: false
};
var SUPPORT_TYPE = ['loading', 'success', 'fail'];
Component({
data: Object.assign({}, DEFAULT_DATA),
methods: {
show: function show(options) {
var toastOptions = Object.assign({}, options);
var icon = options.icon || '';
var image = options.image || '';
if (SUPPORT_TYPE.indexOf(options.type) > -1) {
icon = options.type;
image = '';
}
this.setData(Object.assign({}, toastOptions, {
icon: icon,
image: image
}));
},
clear: function clear() {
this.setData(Object.assign({}, DEFAULT_DATA));
}
}
});