diff --git a/mes-ui/mini-app/src/pages/login/login.vue b/mes-ui/mini-app/src/pages/login/login.vue index 6499831..9067af5 100644 --- a/mes-ui/mini-app/src/pages/login/login.vue +++ b/mes-ui/mini-app/src/pages/login/login.vue @@ -2,7 +2,12 @@ import { postLoginAPI, getDictAPI } from '@/services/login' import { useLoginStore } from '@/stores/modules/login' import type { LoginResult } from '@/types/login' +import { defineStore } from 'pinia' import { ref } from 'vue' + import { + onLoad, + onShow + } from '@dcloudio/uni-app' const loginStore = useLoginStore() const formRef = ref() // 表单数据 @@ -12,6 +17,17 @@ const form = ref({ // username: 'heli000', // password: '123456', }) +onLoad((options) => { + console.log('ssss') + //#ifdef MP-WEIXIN + console.log('jinlaile') + if(uni.getStorageSync('hlxcxzh')!=null){ + var userInfo = uni.getStorageSync('hlxcxzh'); + form.value.username = userInfo.lg_name; + form.value.password = userInfo.pwd; + } + // #endif +}) // 定义校验规则 const rules: UniHelper.UniFormsRules = { username: { @@ -56,6 +72,15 @@ const loginSuccess = async (data: LoginResult) => { } const resDict = await getDictAPI(params) loginStore.setDict(resDict) + if(uni.getStorageSync('hlxcxzh') !=null){ + var userInfo = uni.getStorageSync('hlxcxzh'); + if(!(userInfo.lg_name == form.value.username && userInfo.pwd == form.value.password)){ + uni.setStorageSync('hlxcxzh', {lg_name:form.value.username,pwd:form.value.password}); + } + }else{ + defineStore('hlxcxzh',) + uni.setStorageSync('hlxcxzh', {lg_name:form.value.username,pwd:form.value.password}); + } // 成功提示 uni.showToast({ icon: 'success', title: '登录成功' }) setTimeout(() => { diff --git a/mes-ui/mini-app/src/pages/my/my.vue b/mes-ui/mini-app/src/pages/my/my.vue index 762bdd7..369b9ac 100644 --- a/mes-ui/mini-app/src/pages/my/my.vue +++ b/mes-ui/mini-app/src/pages/my/my.vue @@ -22,7 +22,7 @@ const handleLogut = async () => { const params = {} const data = await postLogoutAPI(params) userStore.clearInfo() - uni.clearStorage() + // uni.clearStorage() uni.navigateTo({ url: '/pages/login/login' }) } onShow(async () => {