You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.9 KiB
50 lines
1.9 KiB
function login() {
|
|
return Vue.component('login', function (resolve, reject) {
|
|
axios.get("/login.html").then(function (response) {
|
|
resolve({
|
|
template: response.data,
|
|
data() {
|
|
return {
|
|
name: 'login'
|
|
};
|
|
},
|
|
mounted: function () {
|
|
console.log('mounted:login');
|
|
weui.form.checkIfBlur('#form', this.regexp);
|
|
},
|
|
computed: {
|
|
regexp: function () {
|
|
return {
|
|
regexp: {
|
|
userName: /^[^\s]+/,
|
|
password: /^[^\s]+$/
|
|
}
|
|
};
|
|
}
|
|
},
|
|
methods: {
|
|
submit: function () {
|
|
weui.form.validate('#form', function (error) {
|
|
console.log(error);
|
|
if (!error) {
|
|
var loading = weui.loading('提交中...');
|
|
var form = $("#form");
|
|
var url = form.attr('action');
|
|
$.ajax({
|
|
url: url,
|
|
type: "POST",
|
|
data: form.serializeJSON(),
|
|
contentType: "application/json",
|
|
success: function (response) {
|
|
loading.hide();
|
|
weui.toast(response, 3000);
|
|
}
|
|
});
|
|
}
|
|
}, this.regexp);
|
|
}
|
|
}
|
|
})
|
|
});
|
|
});
|
|
} |