error.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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="#ff3000"
  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="#ff3000"
  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="#ff3000"
  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. console.log(options)
  41. errCode.value = options.errCode;
  42. errMsg.value = options.errMsg;
  43. });
  44. // 重新连接
  45. async function onReconnect() {
  46. uni.reLaunch({
  47. url: '/pages/index/index',
  48. });
  49. await ShoproInit();
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. .error-page {
  54. width: 100%;
  55. }
  56. </style>