networkError.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. console.log('value changed========:', newVal, oldVal)
  20. if (newVal == '1'&&!this.show) {
  21. const that = this
  22. uni.showModal({
  23. title: '提示',
  24. content: '网络异常,请重试',
  25. showCancel: false,
  26. confirmText: '刷新',
  27. success: function(res) {
  28. store.commit("networkErrorInfo/setStatus", '0');
  29. that.show = true
  30. if (res.confirm) {
  31. that.show = false
  32. that.$emit('refreshAll')
  33. } else if (res.cancel) {
  34. that.show = false
  35. that.$emit('refreshAll')
  36. console.log('用户点击取消');
  37. }
  38. }
  39. });
  40. } else {
  41. that.show = false
  42. }
  43. }
  44. },
  45. mounted() {
  46. store.commit("networkErrorInfo/setStatus", '0');
  47. }
  48. }
  49. </script>
  50. <style scoped lang="scss">
  51. </style>