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
@ -60,6 +60,11 @@ class LoginFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let _userInfo = JSON.parse(util.des.desDecrypt(userInfo));
|
let _userInfo = JSON.parse(util.des.desDecrypt(userInfo));
|
||||||
|
|
||||||
|
let _tmpUserInfo = {
|
||||||
|
userName:_userInfo.userName,
|
||||||
|
password:_userInfo.password
|
||||||
|
}
|
||||||
|
|
||||||
uni.request({
|
uni.request({
|
||||||
url: constant.url.loginUrl,
|
url: constant.url.loginUrl,
|
||||||
@ -67,32 +72,15 @@ class LoginFactory {
|
|||||||
header: {
|
header: {
|
||||||
APP_ID: constant.app.appId
|
APP_ID: constant.app.appId
|
||||||
},
|
},
|
||||||
data: _userInfo,
|
data: _tmpUserInfo,
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
console.log('login success...:');
|
console.log('login success...:');
|
||||||
res = res.data;
|
res = res.data;
|
||||||
|
|
||||||
if (res.result == 0) {
|
if (res.result == 0) {
|
||||||
//that.globalData.userInfo = res.userInfo;
|
//that.globalData.userInfo = res.userInfo;
|
||||||
wx.setStorageSync(constant.mapping.USER_INFO, JSON.stringify(userInfo));
|
//wx.setStorageSync(constant.mapping.USER_INFO, JSON.stringify(userInfo));
|
||||||
let date = new Date();
|
let afterOneHourDate = util.date.addHour(new Date(),1);
|
||||||
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.LOGIN_FLAG, {
|
wx.setStorageSync(constant.mapping.LOGIN_FLAG, {
|
||||||
sessionKey: userInfo.userName,
|
sessionKey: userInfo.userName,
|
||||||
expireTime: afterOneHourDate.getTime()
|
expireTime: afterOneHourDate.getTime()
|
||||||
|
|||||||
@ -40,62 +40,72 @@
|
|||||||
uni.hideTabBar({
|
uni.hideTabBar({
|
||||||
animation: false
|
animation: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
doLogin:function(){
|
doLogin: function() {
|
||||||
if(this.username == ''){
|
let _that = this;
|
||||||
|
if (this.username == '') {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon:none,
|
icon: none,
|
||||||
title:"用户名不能为空"
|
title: "用户名不能为空"
|
||||||
});
|
});
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.password == ''){
|
if (this.password == '') {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon:none,
|
icon: none,
|
||||||
title:"密码不能为空"
|
title: "密码不能为空"
|
||||||
});
|
});
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let userInfo = {
|
let userInfo = {
|
||||||
username:this.username,
|
username: this.username,
|
||||||
password:this.password
|
password: this.password
|
||||||
}
|
}
|
||||||
|
|
||||||
uni.request({
|
uni.request({
|
||||||
url: this.java110Constant.url.loginUrl,
|
url: this.java110Constant.url.loginUrl,
|
||||||
header: this.java110Context.getHeaders(),
|
header: this.java110Context.getHeaders(),
|
||||||
data: userInfo,
|
method: "POST",
|
||||||
success: function (res) {
|
data: userInfo,
|
||||||
console.log('login success');
|
success: function(res) {
|
||||||
res = res.data;
|
console.log('login success',res);
|
||||||
|
if (res.statusCode != 200) {
|
||||||
if(res.statusCode != 200){
|
uni.showToast({
|
||||||
uni.showToast({
|
title: res.data
|
||||||
title: res.data
|
});
|
||||||
});
|
return;
|
||||||
return;
|
}
|
||||||
}
|
let data = res.data;
|
||||||
let _userInfo = this.java110Util.dec.desEncrypt(JSON.stringify(userInfo));
|
|
||||||
uni.setStorageSync(constant.mapping.USER_INFO,_userInfo);
|
let _tmpUserInfo = data.userInfo;
|
||||||
uni.redirectTo({
|
_tmpUserInfo['password'] = _that.password;
|
||||||
url:"/page/index/index"
|
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);
|
||||||
fail: function (error) {
|
let afterOneHourDate = _that.java110Util.date.addHour(new Date(),1);
|
||||||
// 调用服务端登录接口失败
|
wx.setStorageSync(_that.java110Constant.mapping.LOGIN_FLAG, {
|
||||||
uni.showToast({
|
sessionKey: _tmpUserInfo.userName,
|
||||||
title: '调用接口失败'
|
expireTime: afterOneHourDate.getTime()
|
||||||
});
|
});
|
||||||
console.log(error);
|
uni.switchTab({
|
||||||
}
|
url: "/pages/index/index"
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
fail: function(error) {
|
||||||
|
// 调用服务端登录接口失败
|
||||||
|
uni.showToast({
|
||||||
|
title: '调用接口失败'
|
||||||
|
});
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -103,21 +113,23 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.logo{
|
.logo {
|
||||||
margin-top: 200upx;
|
margin-top: 200upx;
|
||||||
margin-bottom: 100upx;
|
margin-bottom: 100upx;
|
||||||
}
|
}
|
||||||
.logo view{
|
|
||||||
|
.logo view {
|
||||||
height: 200upx;
|
height: 200upx;
|
||||||
width: 200upx;
|
width: 200upx;
|
||||||
}
|
}
|
||||||
.login-nav{
|
|
||||||
|
.login-nav {
|
||||||
background-color: #00AA00;
|
background-color: #00AA00;
|
||||||
height: 90upx;
|
height: 90upx;
|
||||||
}
|
}
|
||||||
.login-nav text{
|
|
||||||
|
.login-nav text {
|
||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
font-size: 30upx;
|
font-size: 30upx;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user