function pages_login() { return Vue.component('pages_login', function (resolve, reject) { axios.get("/pages/login.html").then(function (response) { resolve({ template: response.data, data() { return { title: '登录', url: apiHost + '/UserCenter/api/v1/token/getToken' }; }, mounted: function () { $('title').text(this.title); weui.form.checkIfBlur('#form', this.regexp); }, computed: { regexp: function () { return { regexp: { userName: /^[^\s]+/, password: /^[^\s]+$/ } }; }, user: function () { return this.$store.user; } }, methods: { submit: function () { var url = this.url; weui.form.validate('#form', function (error) { if (!error) { var loading = weui.loading('提交中...'); var form = $("#form"); var data = form.serializeJSON(); axios.post(url, data).then(function (response) { store.commit('setToken', response.data); router.push('/'); }).catch(function (error) { console.log(error.response); var data = error.response.data; var key = error.response.data.key; if (key) { $("[name='" + key + "']").parents('.weui-cell').addClass('weui-cell_warn'); } weui.topTips(data.message, { duration: 3000 }); }).finally(function () { loading.hide(); }); } else { console.log(error); } }, this.regexp); } } }); }); }); }