networkError.vue 1021 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <view></view>
  3. </template>
  4. <script>
  5. import store from "@/store";
  6. export default {
  7. data() {
  8. return {
  9. show: false
  10. }
  11. },
  12. computed: {
  13. statusValue() {
  14. return store.state.networkErrorInfo.networkError
  15. }
  16. },
  17. watch: {
  18. statusValue(newVal, oldVal) {
  19. const that = this
  20. if (newVal == '1'&&!this.show) {
  21. uni.showModal({
  22. title: '提示',
  23. content: '网络异常,请重试',
  24. showCancel: false,
  25. confirmText: '刷新',
  26. success: function(res) {
  27. store.commit("networkErrorInfo/setStatus", '0');
  28. that.show = true
  29. if (res.confirm) {
  30. that.show = false
  31. that.$emit('refreshAll')
  32. } else if (res.cancel) {
  33. that.show = false
  34. that.$emit('refreshAll')
  35. console.log('用户点击取消');
  36. }
  37. }
  38. });
  39. } else {
  40. that.show = false
  41. }
  42. }
  43. },
  44. mounted() {
  45. store.commit("networkErrorInfo/setStatus", '0');
  46. }
  47. }
  48. </script>
  49. <style scoped lang="scss">
  50. </style>