vr-shopxo-uniapp/components/no-data/no-data.vue

330 lines
12 KiB
Vue
Raw Normal View History

2021-09-26 15:40:23 +00:00
<template>
2023-12-15 03:44:04 +00:00
<view :class="theme_view">
<!-- 是否有网络 -->
2024-01-23 15:48:49 +00:00
<view v-if="network_type_value == 'none' && not_network_await_status == 0" class="network-type-tips wh-auto tc bs-bb padding-horizontal-main">
2024-01-15 10:39:38 +00:00
<view class="cr-base text-size">{{$t('no-data.no-data.1u202v')}}</view>
<view class="cr-grey margin-top-sm">{{$t('no-data.no-data.imw8f1')}}{{title}}{{$t('no-data.no-data.q87572')}}</view>
<view class="margin-top-lg tc">
<button type="default" class="br-main bg-main cr-white round padding-horizontal-xxl" size="mini" @tap="open_setting_event">{{ $t('setup.setup.377uwg') }}</button>
</view>
2023-12-15 03:44:04 +00:00
</view>
<view v-else>
2024-03-19 09:29:49 +00:00
<!-- 1 加载中(0loog, 1名称) -->
2024-05-09 12:02:45 +00:00
<view v-if="propStatus == 1 && network_type_value != 'none'" :class="'no-data-box tc no-data-loading '+(is_loading_use_skeleton == 1 && (propPage || null) != null ? 'skeleton' : '')">
<block v-if="is_loading_use_skeleton == 1 && (propPage || null) != null">
<!-- 是否展示头站位 -->
<view v-if="propIsHeader" class="skeleton-header"></view>
<!-- 首页 -->
<block v-if="propPage == 'home'">
<x-skeleton propType="banner"></x-skeleton>
<x-skeleton propType="menu"></x-skeleton>
<x-skeleton propType="waterfall"></x-skeleton>
<x-skeleton propType="list" propRowNumber="4"></x-skeleton>
</block>
<!-- 商品分类-整体内容 -->
<block v-else-if="propPage == 'goods-category'">
<x-skeleton propType="menu" propRowNumber="1"></x-skeleton>
<view class="goods-category-content flex-row jc-sb">
<view class="left">
<x-skeleton :propConfig="skeleton_goods_category_left_config"></x-skeleton>
</view>
<view class="right">
<x-skeleton propType="list" propRowNumber="7"></x-skeleton>
</view>
</view>
</block>
<!-- 商品分类-内容项 -->
<block v-else-if="propPage == 'goods-category-item'">
<x-skeleton propType="list" propRowNumber="6"></x-skeleton>
</block>
<!-- 购物车 -->
<block v-else-if="propPage == 'cart'">
<x-skeleton propType="list" propRowNumber="3"></x-skeleton>
<x-skeleton propType="waterfall" propRowNumber="4"></x-skeleton>
</block>
<!-- 商品详情 -->
<block v-else-if="propPage == 'goods'">
<x-skeleton propType="banner" propHeightNumber="600"></x-skeleton>
<x-skeleton propType="text"></x-skeleton>
<x-skeleton propType="info"></x-skeleton>
<x-skeleton propType="waterfall" propRowNumber="4"></x-skeleton>
</block>
</block>
<block v-else>
<view v-if="loading_content_type == 1" class="loading-title-animation">
2024-09-25 16:23:30 +00:00
<text class="title">{{title}}</text>
2024-05-09 12:02:45 +00:00
</view>
2024-08-23 08:03:12 +00:00
<view v-else class="loading-logo-content" :style="'margin-top: '+propLoadingLogoTop+';'">
2024-05-09 12:02:45 +00:00
<view class="loading-logo" :style="'background-image: url('+loading_logo+')'"></view>
<view class="loading-border" :style="'background-image: url('+loading_logo_border+')'"></view>
</view>
</block>
2023-12-15 03:44:04 +00:00
</view>
<!-- 2 处理错误 -->
<view v-else-if="propStatus == 2" class="no-data-box tc">
2024-09-25 16:23:30 +00:00
<image class="image" :src="static_dir + 'error.png'" mode="widthFix"></image>
2024-01-15 10:39:38 +00:00
<view class="no-data-tips">{{propMsg || $t('form.form.bniyyt')}}</view>
2023-12-15 03:44:04 +00:00
<view v-if="propBackBtn" class="margin-top-xxxl tc">
2024-01-15 10:39:38 +00:00
<button type="default" size="mini" class="bg-grey-e br-grey cr-base round" @tap="back_event">{{$t('common.return')}}</button>
2023-12-15 03:44:04 +00:00
</view>
</view>
<!-- 0 默认没有数据 -->
<view v-else-if="propStatus == 0" class="no-data-box tc">
2024-09-25 16:23:30 +00:00
<image class="image" :src="propUrl ? propUrl : static_dir + 'empty.png'" mode="widthFix"></image>
2024-01-15 10:39:38 +00:00
<view class="no-data-tips">{{propMsg || $t('common.no_relevant_data_tips')}}</view>
2023-12-15 03:44:04 +00:00
</view>
2023-10-12 08:37:02 +00:00
</view>
</view>
2021-09-26 15:40:23 +00:00
</template>
2023-09-05 09:38:15 +00:00
<script>
2023-10-12 08:37:02 +00:00
const app = getApp();
export default {
data() {
return {
2023-11-06 11:43:27 +00:00
theme_view: app.globalData.get_theme_value_view(),
2024-03-19 09:29:49 +00:00
static_dir: '/static/images/common/',
2024-05-09 12:02:45 +00:00
is_loading_use_skeleton: app.globalData.data.is_loading_use_skeleton,
2024-03-19 09:29:49 +00:00
loading_logo_border: app.globalData.data.static_url+'static/common/svg/loading-border.svg',
loading_logo: app.globalData.get_application_logo_square() || app.globalData.data.static_url+'favicon.ico',
2024-03-19 09:29:49 +00:00
loading_content_type: app.globalData.data.loading_content_type,
2023-12-15 03:44:04 +00:00
title: app.globalData.get_application_title(),
2024-01-23 15:48:49 +00:00
network_type_value: '',
2024-05-09 12:02:45 +00:00
not_network_await_status: 0,
// 骨架屏配置
// 商品分类内容-左侧
skeleton_goods_category_left_config: {
padding: '30rpx',
gridRows: 19,
gridColumns: 1,
gridRowsGap: '30rpx',
headShow: true,
headWidth: '200rpx',
headHeight: '60rpx',
headBorderRadius: '16rpx',
textShow: false,
},
2023-10-12 08:37:02 +00:00
};
},
components: {},
props: {
propStatus: {
type: [Number, String],
default: 0,
},
propMsg: {
type: String,
2024-01-15 10:39:38 +00:00
default: '',
2023-10-12 08:37:02 +00:00
},
propUrl: {
type: String,
default: '',
},
2023-12-15 03:44:04 +00:00
propBackBtn: {
type: Boolean,
default: true,
2024-01-23 15:48:49 +00:00
},
propNetworkTimeNum: {
type: Number,
default: 40,
2024-05-09 12:02:45 +00:00
},
propPage: {
type: String,
default: '',
},
propIsHeader: {
type: Boolean,
default: false,
2024-08-23 08:03:12 +00:00
},
propLoadingLogoTop: {
type: String,
default: '50%',
2024-05-09 12:02:45 +00:00
}
2023-12-15 03:44:04 +00:00
},
// 页面被展示
created: function () {
self = this;
uni.getNetworkType({
2024-01-23 15:48:49 +00:00
success: function (res) {
// 当前网络
self.network_type_value = res.networkType;
// 无网络进入等待网络中
if(self.network_type_value == 'none') {
self.not_network_await_status = 1;
}
// 定时处理
self.countdown(self);
2023-12-15 03:44:04 +00:00
}
});
2024-01-23 15:48:49 +00:00
},
// #ifndef VUE2
destroyed() {
clearInterval(this.timer);
},
// #endif
// #ifdef VUE3
unmounted() {
clearInterval(this.timer);
},
// #endif
methods: {
// 定时任务
countdown(self) {
// 销毁之前的任务
clearInterval(self.timer);
// 没有网络则启动定时任务
if(self.network_type_value == 'none') {
var temp_num = self.propNetworkTimeNum;
self.timer = setInterval(function () {
// 读取网络状态
uni.getNetworkType({
success: function (res) {
self.network_type_value = res.networkType;
// 已经有网络了则结束定时任务、并正常继续等待走加载过程
if(self.network_type_value != 'none') {
clearInterval(self.timer);
}
}
});
// 每次减1
temp_num--;
// 0则结束
if(temp_num <= 0) {
// 销毁任务
clearInterval(self.timer);
// 无需等待网络
self.not_network_await_status = 0;
}
}, 500);
}
},
2023-12-15 03:44:04 +00:00
// 返回事件
back_event(e) {
app.globalData.page_back_prev_event();
},
// 打开权限管理中心
open_setting_event() {
app.globalData.open_setting_event();
},
2023-11-08 16:30:57 +00:00
},
2023-10-12 08:37:02 +00:00
};
2021-09-26 15:40:23 +00:00
</script>
2024-05-09 12:02:45 +00:00
<style scoped>
2023-10-12 08:37:02 +00:00
.no-data-box {
padding: 15% 0;
}
2024-09-25 16:23:30 +00:00
.no-data-box .image {
2023-10-12 08:37:02 +00:00
width: 160rpx;
margin-bottom: 30rpx;
}
.no-data-box .no-data-tips {
font-size: 24rpx;
color: #999;
}
2024-09-25 16:23:30 +00:00
.no-data-loading .title {
2023-10-12 08:37:02 +00:00
color: #999;
2024-03-19 09:29:49 +00:00
}
/**
* 名称加载
*/
.loading-title-animation,
2024-01-15 10:39:38 +00:00
.network-type-tips {
padding-top: 25%;
2023-10-12 08:37:02 +00:00
}
2024-03-19 09:29:49 +00:00
.loading-title-animation {
2023-10-12 08:37:02 +00:00
background: #e7e7e7 -webkit-linear-gradient(left, #c6c6c6 0%, #c6c6c6 90%) no-repeat 0 0;
background-size: 20% 100%;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-size: 60rpx;
2024-01-15 10:39:38 +00:00
font-weight: bold;
2024-03-19 09:29:49 +00:00
-webkit-animation: loading-text-animation 2s linear infinite;
animation: loading-text-animation 2s linear infinite;
2023-10-12 08:37:02 +00:00
}
2024-03-19 09:29:49 +00:00
@-webkit-keyframes loading-text-animation {
2023-10-12 08:37:02 +00:00
0% {
background-position: 0 0;
}
100% {
background-position: 100% 100%;
}
}
2024-03-19 09:29:49 +00:00
@keyframes loading-text-animation {
2023-10-12 08:37:02 +00:00
0% {
background-position: 0 0;
}
100% {
background-position: 100% 100%;
}
2024-03-19 09:29:49 +00:00
}
/**
* logo加载
*/
.loading-logo-content {
position: absolute;
2024-04-21 16:27:55 +00:00
width: 140rpx;
height: 140rpx;
2024-04-25 15:51:00 +00:00
left: calc(50% - 70rpx);
2024-03-19 09:29:49 +00:00
top: 0;
border-radius: 50%;
overflow: hidden;
background: #fff;
margin-top: 50%;
}
.loading-logo-content .loading-logo {
content: '';
display: block;
position: absolute;
2024-04-21 16:27:55 +00:00
left: 30rpx;
top: 30rpx;
width: 80rpx;
height: 80rpx;
2024-03-19 09:29:49 +00:00
opacity: 0.8;
background-size: contain;
background-position: center center;
background-repeat: no-repeat;
}
.loading-logo-content .loading-border {
content: '';
display: block;
position: absolute;
2024-04-21 16:27:55 +00:00
width: 168rpx;
height: 168rpx;
left: -14rpx;
top: -14rpx;
2024-03-19 09:29:49 +00:00
opacity: 0.8;
background-size: contain;
background-position: center center;
background-repeat: no-repeat;
2024-05-09 12:02:45 +00:00
}
/**
* 骨架屏
*/
.skeleton-header {
/* #ifndef H5 || APP */
padding-top: var(--status-bar-height);
padding-bottom: 55px;
/* #endif */
}
.no-data-box.skeleton {
padding: 0;
}
.no-data-loading .goods-category-content > .left {
width: 30%;
}
.no-data-loading .goods-category-content > .right {
width: 70%;
2023-10-12 08:37:02 +00:00
}
</style>