diff --git a/pages/index/index.vue b/pages/index/index.vue index 8c5f3df..a917ecc 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -14,7 +14,8 @@ if (token) { } else if (user_info.type == 3) { utils.toUrl("/mall/index/index", "redirectTo") } else { - uni.clearStorage(); // 预防本地数据错误 + // uni.clearStorage(); // 预防本地数据错误 + uni.setStorageSync('user_info', null) } } else { utils.toUrl("/pages/login/index", "redirectTo") diff --git a/pages/login/index.vue b/pages/login/index.vue index 4bb0e91..3cf6b09 100644 --- a/pages/login/index.vue +++ b/pages/login/index.vue @@ -21,23 +21,28 @@ - + - - - + + 记住密码? + + + - 登录 + 登录 @@ -50,7 +55,7 @@ import user from '@/api/modules/user.js' import systemApi from '@/api/modules/system.js' import utils from '@/utils/utils.js' import md5 from 'js-md5'; -uni.clearStorage(); // 预防本地数据错误 +// uni.clearStorage(); // 预防本地数据错误 const webInfo = ref({}) @@ -61,14 +66,15 @@ const getWebInfo = () => { } getWebInfo() - - +console.log(uni.getStorageSync('user_pwd'), 'user_pwd') const model = ref({ username: "", password: "", + ...(uni.getStorageSync('user_pwd') || {}) }) const loading = ref(false) +const is_save_user_pwd = ref(true) const form = ref(null) // if (token) { @@ -86,7 +92,9 @@ function handleSubmit() { .validate() .then(({ valid, errors }) => { if (valid) { - + if (is_save_user_pwd.value) { + uni.setStorageSync("user_pwd", model.value); + } user.login({ ...model.value, password: md5(model.value.password) diff --git a/utils/utils.js b/utils/utils.js index 33bf54e..acb9c54 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -158,8 +158,10 @@ export default { loginOut() { const [curRoute, curRouteParam] = this.getRouterInfo() uni.setStorageSync("backPage", "/" + curRoute + curRouteParam) - - uni.clearStorage(); + // uni.clearStorage(); + uni.setStorageSync("store_info", null) + uni.setStorageSync("user_info", null) + uni.setStorageSync("token", null) this.toUrl("/pages/login/index", "redirectTo"); },