export default { name: 'AppLoginWithCode', props: { connected: null, }, data: () => { return { phone: '', submitting: false, pair_code: null, }; }, methods: { async openModal() { try { $('#modalLoginWithCode').modal({ onApprove: function() { return false; }, }).modal('show'); } catch (err) { showErrorInfo(err); } }, async handleSubmit() { if (this.submitting) return; try { this.submitting = true; const { response } = await this.submitApi(); this.pair_code = response.pair_code; } catch (err) { showErrorInfo(err); } finally { this.submitting = false; } }, async submitApi() { try { return http.get(`/app/login-with-code`, { params: { phone: this.phone, }, }); } catch (error) { if (error.response) { throw Error(error.response.data.message); } throw Error(error.message); } }, }, template: `
{{ pair_code }}