index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="rf-no-data hideToShow" :style="{ backgroundColor: bgColor }">
  3. <view class="image"
  4. ><image :src="custom == true ? notFoundImg : noNetWorkImg"></image
  5. ></view>
  6. <!-- 网络连接失败默认显示内容 -->
  7. <view class="content" v-if="netType == 'none' && custom == false">
  8. <text class="title" :style="{ color: mainColor }">{{ mainText }}</text>
  9. <text class="desc" :style="{ color: viceColor }">{{ viceText }}</text>
  10. <!-- #ifdef MP -->
  11. <!--<button class="btn" type="default" @tap="setting(true)">刷新试试</button>-->
  12. <!-- #endif -->
  13. <!-- #ifdef APP-PLUS -->
  14. <!--<button class="btn" type="default" @tap="setting(netWorkStatus)">{{ netWorkStatus ? '刷新试试' : '去设置' }}</button>-->
  15. <!-- #endif -->
  16. </view>
  17. <!-- 自定义内容 -->
  18. <slot />
  19. <view class="back">
  20. <text class="spec-color" @tap="navTo('/pages/index/index')"
  21. >返回主页</text
  22. >
  23. </view>
  24. <slot name="refresh" />
  25. </view>
  26. </template>
  27. <script>
  28. import { mapGetters } from 'vuex';
  29. // import settings from '@/library/settings.js';
  30. export default {
  31. props: {
  32. isShow: {
  33. type: Boolean,
  34. default: false
  35. },
  36. /* 背景颜色自定义 */
  37. bgColor: {
  38. type: String,
  39. default: '#ffffff'
  40. },
  41. /* 标题颜色自定义 */
  42. mainColor: {
  43. type: String,
  44. default: '#373a40'
  45. },
  46. /* 描述颜色自定义 */
  47. viceColor: {
  48. type: String,
  49. default: '#8b8b8b'
  50. },
  51. // 是否开启自定义
  52. custom: {
  53. type: Boolean,
  54. default: false
  55. }
  56. },
  57. computed: {
  58. ...mapGetters(['networkStatus'])
  59. },
  60. data() {
  61. return {
  62. type: '',
  63. netType: this.networkType,
  64. mainText: '网络居然崩溃了',
  65. viceText: '别紧张,去检测一下网络设置',
  66. notFoundImg: this.$mAssetsPath.notFoundImg,
  67. noNetWorkImg: this.$mAssetsPath.noNetWorkImg
  68. };
  69. },
  70. methods: {
  71. setting(status) {
  72. /* 检查到网络已打开,请点击按钮手动刷新数据 */
  73. if (status) {
  74. this.$emit('handle', status);
  75. /* 如果没有网络,打开系统设置检查网络连接 */
  76. }
  77. // else {
  78. // settings.open(settings.SETTINGS);
  79. // }
  80. },
  81. navTo(route) {
  82. this.$mRouter.reLaunch({ route });
  83. }
  84. }
  85. };
  86. </script>
  87. <style lang="scss" scoped>
  88. .rf-no-data {
  89. width: 100%;
  90. height: 100vh;
  91. display: flex;
  92. align-items: center;
  93. justify-content: center;
  94. flex-direction: column;
  95. .image {
  96. width: 60vw;
  97. height: 40vw;
  98. margin-bottom: 20upx;
  99. image {
  100. width: 100%;
  101. height: 100%;
  102. }
  103. }
  104. .content {
  105. width: 100%;
  106. display: flex;
  107. align-items: center;
  108. flex-direction: column;
  109. justify-content: center;
  110. letter-spacing: 1upx;
  111. .title {
  112. font-size: $font-lg;
  113. color: $font-color-dark;
  114. }
  115. .desc {
  116. font-size: 28upx;
  117. margin-top: 6upx;
  118. }
  119. .btn {
  120. width: 160upx;
  121. height: 65upx;
  122. color: #868d91;
  123. font-size: 24upx;
  124. margin-top: 34upx;
  125. border-radius: 36upx;
  126. border: 1upx solid #d4d4d4;
  127. }
  128. .btn::after {
  129. border: none;
  130. }
  131. }
  132. .back {
  133. margin: 300upx 0 40upx;
  134. }
  135. }
  136. </style>