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.

65 lines
1.1 KiB

const STORAGE_KEY = 'PLUG-ADD-MYAPP-KEY';
Component({
/**
* 组件的属性列表
*/
properties: {
// 提示文字
text: {
type: String,
value: '点击「添加小程序」,下次访问更便捷 >'
},
// 多少秒后关闭
duration: {
type: Number,
value: 3
}
},
data: {
SHOW:false,
SHOW_TOP: true,
SHOW_MODAL: false,
statusBarHeight:20
},
ready: function () {
let cache = wx.getStorageSync(STORAGE_KEY);
if (cache) return;
this.setData({
SHOW:true
});
setTimeout(() => {
this.setData({
SHOW_TOP: false
})
}, this.data.duration * 1000);
},
attached(){
wx.getSystemInfo({
success: res=> {
let {statusBarHeight} = res;
this.setData({statusBarHeight});
}
})
},
methods: {
showModal: function () {
this.setData({
SHOW_TOP: false,
SHOW_MODAL: true
});
},
okHandler: function () {
this.setData({
SHOW: false
});
wx.setStorage({
key: STORAGE_KEY,
data: +new Date,
});
}
}
})