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.

129 lines
2.7 KiB

1 month ago
<template>
<view
v-if="visible"
class="common-loading"
:class="{'common-loading--mask': mask}"
@touchmove.stop.prevent="noop"
@tap.stop="noop"
>
<view class="common-loading__box">
2 days ago
<view class="common-loading__halo"></view>
1 month ago
<image class="common-loading__gif" src="/static/images/img/loading.gif" mode="aspectFit"></image>
<view v-if="title" class="common-loading__text">{{ title }}</view>
2 days ago
<view class="common-loading__hint">请稍候正在为你处理</view>
1 month ago
</view>
</view>
</template>
<script>
import { LOADING_HIDE_EVENT, LOADING_SHOW_EVENT, getLoadingState } from '@/utils/loading.js'
export default {
name: 'CommonLoading',
data() {
return {
visible: false,
title: '加载中...',
mask: true
}
},
created() {
const state = getLoadingState()
this.visible = state.visible
this.title = state.title
this.mask = state.mask
uni.$on(LOADING_SHOW_EVENT, this.show)
uni.$on(LOADING_HIDE_EVENT, this.hide)
},
beforeDestroy() {
uni.$off(LOADING_SHOW_EVENT, this.show)
uni.$off(LOADING_HIDE_EVENT, this.hide)
},
methods: {
show(options = {}) {
this.visible = true
this.title = options.title || '加载中...'
this.mask = options.mask !== false
},
hide() {
this.visible = false
},
noop() {}
}
}
</script>
<style lang="scss" scoped>
.common-loading {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 99999;
display: flex;
align-items: center;
justify-content: center;
pointer-events: none;
2 days ago
background: rgba(13, 18, 34, 0.46);
backdrop-filter: blur(16rpx);
1 month ago
}
.common-loading--mask {
pointer-events: auto;
}
.common-loading__box {
2 days ago
position: relative;
min-width: 280rpx;
min-height: 242rpx;
overflow: hidden;
padding: 44rpx 44rpx 36rpx;
border-radius: 40rpx;
background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(245,249,255,.96));
border: 1rpx solid rgba(255,255,255,.86);
box-shadow: 0 28rpx 82rpx rgba(28, 35, 74, 0.28);
1 month ago
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
2 days ago
.common-loading__halo {
position: absolute;
top: -82rpx;
right: -74rpx;
width: 220rpx;
height: 220rpx;
border-radius: 50%;
background: rgba(169, 255, 231, .72);
}
1 month ago
.common-loading__gif {
2 days ago
position: relative;
1 month ago
width: 92rpx;
height: 92rpx;
}
.common-loading__text {
2 days ago
position: relative;
1 month ago
margin-top: 18rpx;
2 days ago
max-width: 380rpx;
font-size: 28rpx;
line-height: 40rpx;
color: #11162a;
font-weight: 900;
white-space: pre-line;
text-align: center;
}
.common-loading__hint {
position: relative;
margin-top: 10rpx;
color: rgba(17, 22, 42, .48);
font-size: 22rpx;
line-height: 32rpx;
1 month ago
text-align: center;
}
</style>