v3.0.6
This commit is contained in:
45
source/wx/xzs-student/component/iView/message/index.js
Normal file
45
source/wx/xzs-student/component/iView/message/index.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const default_data = {
|
||||
visible: false,
|
||||
content: '',
|
||||
duration: 2,
|
||||
type: 'default', // default || success || warning || error
|
||||
};
|
||||
|
||||
let timmer = null;
|
||||
|
||||
Component({
|
||||
externalClasses: ['i-class'],
|
||||
|
||||
data: {
|
||||
...default_data
|
||||
},
|
||||
|
||||
methods: {
|
||||
handleShow (options) {
|
||||
const { type = 'default', duration = 2 } = options;
|
||||
|
||||
this.setData({
|
||||
...options,
|
||||
type,
|
||||
duration,
|
||||
visible: true
|
||||
});
|
||||
|
||||
const d = this.data.duration * 1000;
|
||||
|
||||
if (timmer) clearTimeout(timmer);
|
||||
if (d !== 0) {
|
||||
timmer = setTimeout(() => {
|
||||
this.handleHide();
|
||||
timmer = null;
|
||||
}, d);
|
||||
}
|
||||
},
|
||||
|
||||
handleHide () {
|
||||
this.setData({
|
||||
...default_data
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
3
source/wx/xzs-student/component/iView/message/index.json
Normal file
3
source/wx/xzs-student/component/iView/message/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
3
source/wx/xzs-student/component/iView/message/index.wxml
Normal file
3
source/wx/xzs-student/component/iView/message/index.wxml
Normal file
@@ -0,0 +1,3 @@
|
||||
<view class="i-class i-message i-message-{{type}} {{ visible ? 'i-message-show' : '' }}">
|
||||
{{ content }}
|
||||
</view>
|
||||
1
source/wx/xzs-student/component/iView/message/index.wxss
Normal file
1
source/wx/xzs-student/component/iView/message/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
.i-message{display:block;width:100%;min-height:32px;line-height:2.3;position:fixed;top:0;left:0;right:0;background:#2d8cf0;color:#fff;text-align:center;font-size:14px;z-index:1010;opacity:0;-webkit-transform:translateZ(0) translateY(-100%);transition:all .4s ease-in-out}.i-message-show{-webkit-transform:translateZ(0) translateY(0);opacity:1}.i-message-default{background:#2d8cf0}.i-message-success{background:#19be6b}.i-message-warning{background:#f90}.i-message-error{background:#ed3f14}
|
||||
Reference in New Issue
Block a user