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.
iot/projects/WebMVC/wwwroot/pages/login.html

53 lines
2.3 KiB

<template>
<form class="weui-form" id="form" method="post">
<div class="weui-cells weui-cells_form">
<div class="weui-cell">
<div class="weui-cell__hd"><label class="weui-label">用户名</label></div>
<div class="weui-cell__bd">
<input class="weui-input" type="text" name="userName" placeholder="用户名" maxlength="100" required pattern="REG_userName" emptytips="请输入用户名" notmatchtips="用户名输入不合法">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__hd"><label class="weui-label">密码</label></div>
<div class="weui-cell__bd">
<input class="weui-input" type="password" name="password" placeholder="密码" maxlength="100" required pattern="REG_password" tips="请输入密码" notmatchtips="密码输入不合法">
</div>
</div>
</div>
<a class="weui-btn weui-btn_primary my-3" href="javascript:" id="showTooltips" v-on:click="submit()">确定</a>
</form>
</template>
<script>
export default {
data: function (){
return {
title: '登录',
url: '/UserCenter/api/v1/token/getToken'
}
},
mounted: function () {
document.querySelector('title').innerHTML = this.title;
},
methods: {
submit: function () {
var form = $("#form");
var data = form.serializeJSON();
var url = config.baseUrl + this.url;
axios.post(url, data).then(function (response) {
store.commit('setState', { key: 'token', value: 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();
});
}
}
}
</script>