<template>
	<view></view>
</template>

<script>
	import store from "@/store";
	export default {
		data() {
			return {
				show: false
			}
		},
		computed: {
			statusValue() {
				return store.state.networkErrorInfo.networkError
			}
		},
		watch: {
			statusValue(newVal, oldVal) {
				console.log('value changed========:', newVal, oldVal)
				if (newVal == '1'&&!this.show) {
					const that = this
					uni.showModal({
						title: '提示',
						content: '网络异常，请重试',
						showCancel: false,
						confirmText: '刷新',
						success: function(res) {
							store.commit("networkErrorInfo/setStatus", '0');
							that.show = true
							
							if (res.confirm) {
								that.show = false
								that.$emit('refreshAll')
							} else if (res.cancel) {
								that.show = false
								that.$emit('refreshAll')
								console.log('用户点击取消');
							}
						}
					});
				} else {
					that.show = false
				}
			}
		},
		mounted() {
			store.commit("networkErrorInfo/setStatus", '0');
		}
	}
</script>

<style scoped lang="scss">
</style>
