mirror of
https://gitee.com/java110/PropertyApp.git
synced 2026-02-23 21:36:39 +08:00
登录页面开发完成
This commit is contained in:
parent
23258bc320
commit
9b05f390a7
@ -61,38 +61,26 @@ class LoginFactory {
|
||||
|
||||
let _userInfo = JSON.parse(util.des.desDecrypt(userInfo));
|
||||
|
||||
let _tmpUserInfo = {
|
||||
userName:_userInfo.userName,
|
||||
password:_userInfo.password
|
||||
}
|
||||
|
||||
uni.request({
|
||||
url: constant.url.loginUrl,
|
||||
method: 'post',
|
||||
header: {
|
||||
APP_ID: constant.app.appId
|
||||
},
|
||||
data: _userInfo,
|
||||
data: _tmpUserInfo,
|
||||
success: function (res) {
|
||||
console.log('login success...:');
|
||||
res = res.data;
|
||||
|
||||
if (res.result == 0) {
|
||||
//that.globalData.userInfo = res.userInfo;
|
||||
wx.setStorageSync(constant.mapping.USER_INFO, JSON.stringify(userInfo));
|
||||
let date = new Date();
|
||||
let year = date.getFullYear(); //获取当前年份
|
||||
|
||||
let mon = date.getMonth(); //获取当前月份
|
||||
|
||||
let da = date.getDate(); //获取当前日
|
||||
|
||||
let h = date.getHours() + 1; //获取小时
|
||||
|
||||
let m = date.getMinutes(); //获取分钟
|
||||
|
||||
let s = date.getSeconds(); //获取秒
|
||||
|
||||
console.log("获取过去时间", year, mon, da, h, m, s); //将时间格式转化为时间戳
|
||||
|
||||
let afterOneHourDate = new Date(year, mon, da, h, m, s); //30s之后的时间
|
||||
|
||||
console.log("afterOneHourDate", afterOneHourDate);
|
||||
//wx.setStorageSync(constant.mapping.USER_INFO, JSON.stringify(userInfo));
|
||||
let afterOneHourDate = util.date.addHour(new Date(),1);
|
||||
wx.setStorageSync(constant.mapping.LOGIN_FLAG, {
|
||||
sessionKey: userInfo.userName,
|
||||
expireTime: afterOneHourDate.getTime()
|
||||
|
||||
@ -45,56 +45,66 @@
|
||||
},
|
||||
methods: {
|
||||
|
||||
doLogin:function(){
|
||||
if(this.username == ''){
|
||||
doLogin: function() {
|
||||
let _that = this;
|
||||
if (this.username == '') {
|
||||
uni.showToast({
|
||||
icon:none,
|
||||
title:"用户名不能为空"
|
||||
icon: none,
|
||||
title: "用户名不能为空"
|
||||
});
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.password == ''){
|
||||
if (this.password == '') {
|
||||
uni.showToast({
|
||||
icon:none,
|
||||
title:"密码不能为空"
|
||||
icon: none,
|
||||
title: "密码不能为空"
|
||||
});
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
let userInfo = {
|
||||
username:this.username,
|
||||
password:this.password
|
||||
username: this.username,
|
||||
password: this.password
|
||||
}
|
||||
|
||||
uni.request({
|
||||
url: this.java110Constant.url.loginUrl,
|
||||
header: this.java110Context.getHeaders(),
|
||||
data: userInfo,
|
||||
success: function (res) {
|
||||
console.log('login success');
|
||||
res = res.data;
|
||||
url: this.java110Constant.url.loginUrl,
|
||||
header: this.java110Context.getHeaders(),
|
||||
method: "POST",
|
||||
data: userInfo,
|
||||
success: function(res) {
|
||||
console.log('login success',res);
|
||||
if (res.statusCode != 200) {
|
||||
uni.showToast({
|
||||
title: res.data
|
||||
});
|
||||
return;
|
||||
}
|
||||
let data = res.data;
|
||||
|
||||
if(res.statusCode != 200){
|
||||
uni.showToast({
|
||||
title: res.data
|
||||
});
|
||||
return;
|
||||
}
|
||||
let _userInfo = this.java110Util.dec.desEncrypt(JSON.stringify(userInfo));
|
||||
uni.setStorageSync(constant.mapping.USER_INFO,_userInfo);
|
||||
uni.redirectTo({
|
||||
url:"/page/index/index"
|
||||
});
|
||||
},
|
||||
fail: function (error) {
|
||||
// 调用服务端登录接口失败
|
||||
uni.showToast({
|
||||
title: '调用接口失败'
|
||||
});
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
let _tmpUserInfo = data.userInfo;
|
||||
_tmpUserInfo['password'] = _that.password;
|
||||
let _userInfo = _that.java110Util.des.desEncrypt(JSON.stringify(_tmpUserInfo));
|
||||
uni.setStorageSync(_that.java110Constant.mapping.USER_INFO, _userInfo);
|
||||
uni.setStorageSync(_that.java110Constant.mapping.TOKEN, data.token);
|
||||
let afterOneHourDate = _that.java110Util.date.addHour(new Date(),1);
|
||||
wx.setStorageSync(_that.java110Constant.mapping.LOGIN_FLAG, {
|
||||
sessionKey: _tmpUserInfo.userName,
|
||||
expireTime: afterOneHourDate.getTime()
|
||||
});
|
||||
uni.switchTab({
|
||||
url: "/pages/index/index"
|
||||
});
|
||||
},
|
||||
fail: function(error) {
|
||||
// 调用服务端登录接口失败
|
||||
uni.showToast({
|
||||
title: '调用接口失败'
|
||||
});
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@ -103,21 +113,23 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.logo{
|
||||
.logo {
|
||||
margin-top: 200upx;
|
||||
margin-bottom: 100upx;
|
||||
}
|
||||
.logo view{
|
||||
|
||||
.logo view {
|
||||
height: 200upx;
|
||||
width: 200upx;
|
||||
}
|
||||
.login-nav{
|
||||
|
||||
.login-nav {
|
||||
background-color: #00AA00;
|
||||
height: 90upx;
|
||||
}
|
||||
.login-nav text{
|
||||
|
||||
.login-nav text {
|
||||
color: #FFFFFF;
|
||||
font-size: 30upx;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user