71 lines
1.3 KiB
Vue
71 lines
1.3 KiB
Vue
<template>
|
|
<view class="_dialog" @tap="close('click')" v-if="popsh">
|
|
<view class="_content" :style="dialogstyle" v-html="tobr(content, true)"></view>
|
|
</view>
|
|
</template>
|
|
|
|
<style scoped>
|
|
._dialog {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
text-align: center;
|
|
z-index:50030;
|
|
}
|
|
|
|
._dialog ._content {
|
|
border-radius: 0.5em;
|
|
background: var(--txt7);
|
|
color: var(--bg2);
|
|
display: inline-block;
|
|
max-width:100%;
|
|
padding: 1em 2em;
|
|
text-align: center;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
export default {
|
|
props: {},
|
|
data() {
|
|
return {
|
|
popsh: false,
|
|
dialogstyle: {},
|
|
content: ''
|
|
};
|
|
},
|
|
methods: {
|
|
async Open(res) {
|
|
return new Promise(async (resolve, reject) => {
|
|
this.cb = resolve;
|
|
res = res || {};
|
|
if (typeof(res) == 'string') {
|
|
res = {
|
|
content: res,
|
|
sec: 2
|
|
};
|
|
}
|
|
var sec = this.toint(res.sec);
|
|
this.content = res.content;
|
|
var app = getApp();
|
|
this.dialogstyle.marginTop = (app.globalData._sysinfo.windowHeight / 3) + 'px';
|
|
this.popsh = true;
|
|
if (sec <= 0)
|
|
return;
|
|
this._tick = setTimeout(() => {
|
|
this.close('timeout');
|
|
}, sec * 1000);
|
|
}).catch(e => {
|
|
return e;
|
|
});
|
|
},
|
|
close(act) {
|
|
clearTimeout(this._tick);
|
|
this.popsh = false;
|
|
this.cb(act);
|
|
}
|
|
}
|
|
}
|
|
</script> |