登录记录缓存
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
"name" : "干巷仓库APP",
|
"name" : "干巷仓库APP",
|
||||||
"appid" : "__UNI__A67E78B",
|
"appid" : "__UNI__A67E78B",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "2.2.5",
|
"versionName" : "2.2.6",
|
||||||
"versionCode" : 225,
|
"versionCode" : 226,
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
"app-plus" : {
|
"app-plus" : {
|
||||||
"usingComponents" : true,
|
"usingComponents" : true,
|
||||||
|
|||||||
@@ -9,20 +9,25 @@
|
|||||||
<!-- 登录表单 -->
|
<!-- 登录表单 -->
|
||||||
<u--form labelPosition="left" :model="loginForm" ref="uForm">
|
<u--form labelPosition="left" :model="loginForm" ref="uForm">
|
||||||
<u-form-item prop="username" borderBottom>
|
<u-form-item prop="username" borderBottom>
|
||||||
<u--input v-model="loginForm.username" border="none" placeholder="账号" prefixIcon="account" prefixIconStyle="font-size: 22px;color: #909399"></u--input>
|
<u--input v-model="loginForm.username" border="none" placeholder="账号" prefixIcon="account"
|
||||||
|
prefixIconStyle="font-size: 22px;color: #909399"></u--input>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
<u-form-item prop="password" borderBottom>
|
<u-form-item prop="password" borderBottom>
|
||||||
<u--input v-model="loginForm.password" border="none" placeholder="密码" prefixIcon="lock" prefixIconStyle="font-size: 22px;color: #909399"></u--input>
|
<u--input v-model="loginForm.password" border="none" placeholder="密码" prefixIcon="lock"
|
||||||
|
prefixIconStyle="font-size: 22px;color: #909399"></u--input>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
<u-form-item prop="BaseUrl" borderBottom>
|
<u-form-item prop="BaseUrl" borderBottom>
|
||||||
<u-input v-model="BaseUrl" border="none" placeholder="连接地址,例:127.0.0.1:8888" prefixIcon="ie" prefixIconStyle="font-size: 22px;color: #909399">
|
<u-input v-model="BaseUrl" border="none" placeholder="连接地址,例:127.0.0.1:8888" prefixIcon="ie"
|
||||||
|
prefixIconStyle="font-size: 22px;color: #909399">
|
||||||
<template slot="suffix">
|
<template slot="suffix">
|
||||||
<u-button type="primary" size="mini" text="修改地址" @click="handlerBaseUrlConfirm" shape="circle"></u-button>
|
<u-button type="primary" size="mini" text="修改地址" @click="handlerBaseUrlConfirm"
|
||||||
|
shape="circle"></u-button>
|
||||||
</template>
|
</template>
|
||||||
</u-input>
|
</u-input>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
<u-form-item prop="button" style="margin-top: 60px">
|
<u-form-item prop="button" style="margin-top: 60px">
|
||||||
<u-button @click="handleLogin" type="primary" :color="buttonColor" text="登录" shape="circle"></u-button>
|
<u-button @click="handleLogin" type="primary" :color="buttonColor" text="登录"
|
||||||
|
shape="circle"></u-button>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
</u--form>
|
</u--form>
|
||||||
</view>
|
</view>
|
||||||
@@ -34,11 +39,26 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getCodeImg } from '@/api/login';
|
import {
|
||||||
import { getToken, setToken, removeToken } from '@/utils/auth';
|
getCodeImg
|
||||||
import { getBaseUrl, setBaseUrl, removeBaseUrl } from '@/utils/baseUrl';
|
} from '@/api/login';
|
||||||
import config from '@/config';
|
import {
|
||||||
export default {
|
getToken,
|
||||||
|
setToken,
|
||||||
|
removeToken
|
||||||
|
} from '@/utils/auth';
|
||||||
|
import {
|
||||||
|
getBaseUrl,
|
||||||
|
setBaseUrl,
|
||||||
|
removeBaseUrl
|
||||||
|
} from '@/utils/baseUrl';
|
||||||
|
import {
|
||||||
|
getLoginInfo,
|
||||||
|
setLoginInfo,
|
||||||
|
removeLoginInfo
|
||||||
|
} from '@/utils/loginInfo';
|
||||||
|
import config from '@/config';
|
||||||
|
export default {
|
||||||
onLoad() {
|
onLoad() {
|
||||||
const systemInfo = uni.getSystemInfoSync();
|
const systemInfo = uni.getSystemInfoSync();
|
||||||
this.version = systemInfo.appVersion;
|
this.version = systemInfo.appVersion;
|
||||||
@@ -54,8 +74,8 @@ export default {
|
|||||||
BaseUrl: '127.0.0.1:8888',
|
BaseUrl: '127.0.0.1:8888',
|
||||||
buttonColor: 'linear-gradient(to right, #3296F9, #235FF5)',
|
buttonColor: 'linear-gradient(to right, #3296F9, #235FF5)',
|
||||||
loginForm: {
|
loginForm: {
|
||||||
username: 'admin',
|
username: '',
|
||||||
password: '123456',
|
password: '',
|
||||||
code: '',
|
code: '',
|
||||||
uuid: ''
|
uuid: ''
|
||||||
}
|
}
|
||||||
@@ -74,6 +94,19 @@ export default {
|
|||||||
setBaseUrl(baseUrl);
|
setBaseUrl(baseUrl);
|
||||||
}
|
}
|
||||||
this.BaseUrl = baseUrl;
|
this.BaseUrl = baseUrl;
|
||||||
|
// 初始化用户登录存储
|
||||||
|
try {
|
||||||
|
let loginInfoStr = getLoginInfo();
|
||||||
|
let loginInfo = JSON.parse(loginInfoStr);
|
||||||
|
if (loginInfo) {
|
||||||
|
this.loginForm.username = loginInfo.username;
|
||||||
|
this.loginForm.password = loginInfo.password;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// console.log(e);
|
||||||
|
//TODO handle the exception
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
// 获取图形验证码
|
// 获取图形验证码
|
||||||
getCode() {
|
getCode() {
|
||||||
@@ -123,6 +156,16 @@ export default {
|
|||||||
this.$store
|
this.$store
|
||||||
.dispatch('Login', this.loginForm)
|
.dispatch('Login', this.loginForm)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
try {
|
||||||
|
const loginInfo = {
|
||||||
|
username: this.loginForm.username,
|
||||||
|
password: this.loginForm.password
|
||||||
|
}
|
||||||
|
const loginInfoStr = JSON.stringify(loginInfo);
|
||||||
|
setLoginInfo(loginInfoStr);
|
||||||
|
} catch (e) {
|
||||||
|
// console.log(e);
|
||||||
|
}
|
||||||
this.$modal.closeLoading();
|
this.$modal.closeLoading();
|
||||||
this.loginSuccess();
|
this.loginSuccess();
|
||||||
})
|
})
|
||||||
@@ -143,7 +186,7 @@ export default {
|
|||||||
// 确认修改链接地址
|
// 确认修改链接地址
|
||||||
handlerBaseUrlConfirm() {
|
handlerBaseUrlConfirm() {
|
||||||
const baseUrl = this.BaseUrl;
|
const baseUrl = this.BaseUrl;
|
||||||
console.log('changeBaseUrl', baseUrl);
|
// console.log('changeBaseUrl', baseUrl);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '链接地址已修改:' + baseUrl,
|
title: '链接地址已修改:' + baseUrl,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
@@ -151,14 +194,15 @@ export default {
|
|||||||
setBaseUrl(baseUrl);
|
setBaseUrl(baseUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.bangben {
|
.bangben {
|
||||||
margin-top: 110px;
|
margin-top: 110px;
|
||||||
margin-left: 35%;
|
margin-left: 35%;
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
}
|
}
|
||||||
@import url('login.scss');
|
|
||||||
|
@import url('login.scss');
|
||||||
</style>
|
</style>
|
||||||
13
utils/loginInfo.js
Normal file
13
utils/loginInfo.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
const key = '_LoginInfo'
|
||||||
|
|
||||||
|
export function getLoginInfo() {
|
||||||
|
return uni.getStorageSync(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setLoginInfo(data) {
|
||||||
|
return uni.setStorageSync(key, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeLoginInfo() {
|
||||||
|
return uni.removeStorageSync(key)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user