You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.0 KiB

Component({
externalClasses: ['class'],
properties: {
info: String,
type: String,
size: {
type:Number,
value: 23
},
fontsize:{
type:Number,
value:14
},
color: {
type:String,
value:"inherit"
},
showtype:{
type:String,
value:"default"
},
duration:{
type:Number,
value:1500
}
},
methods: {
onTap() {
let {info, showtype, duration} = this.data;
if(info){
if(showtype=='toast')
wx.showToast({
title: info,icon:"none", duration
})
else if(showtype=='modal')
wx.showModal({
content: info, showCancel:false
})
else
this.showInfo()
}
},
showInfo(){
if (this.timeid)
clearTimeout(this.timeid);
this.setData({showInfo:1});
this.timeid = setTimeout(() => {
this.hideInfo();
},this.data.duration);
},
hideInfo(){
this.setData({showInfo:0});
this.timeid = null;
}
}
});