| | |
| | | }, |
| | | |
| | | methods: { |
| | | asyncChange(e) { |
| | | if (this.isChanging) return; |
| | | this.isChanging = true; |
| | | |
| | | |
| | | // 先显示loading状态 |
| | | this.$refs.uToast.show({ |
| | | title: '正在切换模式...', |
| | | type: 'loading', |
| | | duration: 1000 |
| | | }); |
| | | |
| | | this.$u.post('/api/PDA/AutoStatus?auto='+( e ? 'true' : 'false'), {}).then(result => { |
| | | console.log(result); |
| | | if (result) { |
| | | this.value = e; // 只有在请求成功后才更新实际值 |
| | | this.switchValue = e; // 同步switch的状态 |
| | | this.$refs.uToast.show({ |
| | | title: '模式切换成功', |
| | | type: 'success', |
| | | duration: 1000 |
| | | }); |
| | | } else { |
| | | this.switchValue = !e; // 请求失败则恢复switch状态 |
| | | this.$refs.uToast.show({ |
| | | title: '模式切换失败', |
| | | type: 'error', |
| | | duration: 1000 |
| | | }); |
| | | } |
| | | }).catch(error => { |
| | | this.switchValue = !e; // 请求失败则恢复switch状态 |
| | | this.$refs.uToast.show({ |
| | | title: '请求出错', |
| | | type: 'error', |
| | | duration: 1000 |
| | | }); |
| | | }).finally(() => { |
| | | this.isChanging = false; |
| | | }); |
| | | }, |
| | | AndroidCheckUpdate: function() { |
| | | var _this = this; |
| | | uni.request({ |