error.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <!-- 错误界面 -->
  2. <template>
  3. <view class="error-page">
  4. <s-empty
  5. v-if="errCode === 'NetworkError'"
  6. icon="/static/internet-empty.png"
  7. text="网络连接失败"
  8. showAction
  9. actionText="重新连接"
  10. @clickAction="onReconnect"
  11. buttonColor="#132b85"
  12. />
  13. <s-empty
  14. v-else-if="errCode === 'TemplateError'"
  15. icon="/static/internet-empty.png"
  16. text="未找到模板"
  17. showAction
  18. actionText="重新加载"
  19. @clickAction="onReconnect"
  20. buttonColor="#132b85"
  21. />
  22. <s-empty
  23. v-else-if="errCode !== ''"
  24. icon="/static/internet-empty.png"
  25. :text="errMsg"
  26. showAction
  27. actionText="重新加载"
  28. @clickAction="onReconnect"
  29. buttonColor="#132b85"
  30. />
  31. </view>
  32. </template>
  33. <script setup>
  34. import { onLoad } from '@dcloudio/uni-app';
  35. import { ref } from 'vue';
  36. import { ShoproInit } from '@/sheep';
  37. const errCode = ref('');
  38. const errMsg = ref('');
  39. onLoad((options) => {
  40. errCode.value = options.errCode;
  41. errMsg.value = options.errMsg;
  42. });
  43. // 重新连接
  44. async function onReconnect() {
  45. uni.reLaunch({
  46. url: '/pages/index/index',
  47. });
  48. await ShoproInit();
  49. }
  50. </script>
  51. <style lang="scss" scoped>
  52. .error-page {
  53. width: 100%;
  54. }
  55. </style>