From 3cc575268b3042b35e785ffeebf51a6ea3b5e73d Mon Sep 17 00:00:00 2001 From: gerson <1405270578@qq.com> Date: 星期五, 01 十一月 2024 11:32:13 +0800 Subject: [PATCH] Merge branch 'test' of http://47.103.154.90:83/r/WI/Web.V1.0 into test --- src/layout/component/sidebar/components/MenuList.vue | 118 ++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 81 insertions(+), 37 deletions(-) diff --git a/src/layout/component/sidebar/components/MenuList.vue b/src/layout/component/sidebar/components/MenuList.vue index e9e438f..aa1689e 100644 --- a/src/layout/component/sidebar/components/MenuList.vue +++ b/src/layout/component/sidebar/components/MenuList.vue @@ -21,14 +21,14 @@ ><span class="user_name"> {{ userName }} </span></span ><span ref="toggleExitLoginBtnRef" ><span - class="ywicon text-white" - :class="{ 'icon-fold': !state.isShowExitLogin, 'icon-unfold': state.isShowExitLogin }" + class="ywifont text-white" + :class="{ 'ywicon-fold': !state.isShowExitLogin, 'ywicon-unfold': state.isShowExitLogin }" @click="toggleShowExitLogin" ></span ></span> </div> <div class="pop_up actived" v-show="state.isShowExitLogin"> - <div class="exit" @click="logoutClick"><i class="ywicon icon-tuichu"></i> 閫�鍑虹櫥褰�</div> + <div class="exit" @click="logoutClick"><i class="ywifont ywicon-tuichu"></i> 閫�鍑虹櫥褰�</div> </div> </div> <div v-else class="user_login"> @@ -40,15 +40,15 @@ <div class="pc-login items-center justify-center" style="display: flex" v-show="state.isShowLogin"> <div class="login_box"> <div class="sign_in"> - <i class="ywicon icon-guanbi closes" @click="handleClose"></i> - <h1><span>鐧诲綍 WI 姘村姟</span></h1> + <i class="ywifont ywicon-guanbi closes" @click="handleClose"></i> + <h1><span>鐧诲綍 WI 姘村姟鏅鸿兘</span></h1> <el-tabs v-model="state.activeLoginName" class="mt-[24px]" @tab-change="handleUserClick"> <el-tab-pane label="璐︽埛瀵嗙爜鐧诲綍" name="accountUser"> <el-form ref="loginFormRef" :model="state.loginForm" :rules="loginRules" - class="demo-ruleForm mt-[24px] min-h-[126px]" + class="demo-ruleForm mt-[24px] min-h-[140px]" size="large" > <el-form-item label="璐﹀彿" prop="account"> @@ -65,8 +65,7 @@ :rules="loginPhoneRules" :model="state.loginPhoneForm" size="large" - label-width="67px" - class="mt-[24px] min-h-[126px]" + class="mt-[24px] min-h-[140px]" > <el-form-item label="鎵嬫満鍙�" prop="phoneUser"> <el-input v-model="state.loginPhoneForm.phoneUser" placeholder="璇疯緭鍏ユ墜鏈哄彿鐮�" clearable> @@ -76,7 +75,7 @@ <el-form-item prop="verifyCode" label="楠岃瘉鐮�"> <el-input v-model="state.loginPhoneForm.verifyCode" placeholder="璇疯緭鍏ュ洓浣嶉獙璇佺爜" maxlength="6" clearable> <template #append> - <el-button type="primary" @click="handleSendVerifyCode">鑾峰彇楠岃瘉鐮�</el-button> + <el-button type="primary" @click="handleSendVerifyCode" :disabled="hasSended">{{ sendCodeMsg }}</el-button> </template> </el-input> </el-form-item> @@ -93,9 +92,9 @@ </template> <script setup lang="ts"> -import type { FormInstance } from 'element-plus'; +import { ElMessage, type FormInstance } from 'element-plus'; import { computed, onMounted, reactive, ref, watchEffect } from 'vue'; -import { PostLogin, loginMessageUser } from '/@/api/ai/user'; +import { PostLogin, loginMessageUser, loginVerifyMessage } from '/@/api/ai/user'; import router from '/@/router'; import emitter from '/@/utils/mitt'; import { accessSessionKey, userNameKey } from '/@/utils/request'; @@ -105,6 +104,7 @@ const formPhoneRef = ref(); //鎵嬫満鍙风櫥褰� const isLoginStatus = ref(!!Local.get(accessSessionKey)); const userName = ref(''); +const countdown = ref(null); const firstUserCharacter = computed(() => userName.value?.[0]?.toUpperCase()); watchEffect(() => { if (!isLoginStatus.value) return; @@ -112,23 +112,23 @@ }); let state = reactive({ asideTitleList: [ - { - id: 1, - icon: '/static/images/wave/AsideIcon.png', - title: '搴旂敤鍦烘櫙', - routerName: 'AllScenario', - }, - { - id: 2, - icon: '/static/images/wave/AsideIcon.png', - title: '甯姪涓績', - // routerName:'Scenario', - }, - { - id: 3, - icon: '/static/images/wave/AsideIcon.png', - title: '涓汉璁剧疆', - }, + // { + // id: 1, + // icon: '/static/images/wave/AsideIcon.png', + // title: '搴旂敤鍦烘櫙', + // routerName: 'AllScenario', + // }, + // { + // id: 2, + // icon: '/static/images/wave/AsideIcon.png', + // title: '甯姪涓績', + // // routerName:'Scenario', + // }, + // { + // id: 3, + // icon: '/static/images/wave/AsideIcon.png', + // title: '涓汉璁剧疆', + // }, { id: 4, icon: '/static/images/wave/AsideIcon.png', @@ -157,10 +157,14 @@ { required: true, message: '璇疯緭鍏ユ墜鏈哄彿鐮�', trigger: 'blur' }, { pattern: /^1\d{10}$/, message: '璇疯緭鍏ユ纭殑鎵嬫満鍙风爜', trigger: 'blur' }, ], + verifyCode: [{ required: true, message: '璇疯緭鍏ラ獙璇佺爜', trigger: 'blur' }], }; const handleClick = (item) => { + if (!item.routerName) return; gotoRoute({ name: item.routerName }); }; +const LOGIN_CLIENT = 'Web绔�'; + //鐧诲綍 const openLoginDlg = async () => { state.isShowLogin = true; @@ -168,16 +172,43 @@ const handleClose = () => { state.isShowLogin = false; }; +const hasSended = computed(() => { + return countdown.value !== null; +}); +const sendCodeMsg = computed(() => { + return !hasSended.value ? '鑾峰彇楠岃瘉鐮�' : `${countdown.value} 绉掑悗閲嶈瘯`; +}); //鐧诲綍 const onSubmit = async () => { - const isValid = await loginFormRef.value.validate().catch(() => {}); - if (!isValid) return; - const res = await PostLogin({ - user: state.loginForm.account, - pass: state.loginForm.pwd, - }); + if (state.activeLoginName === 'accountUser') { + //璐︽埛瀵嗙爜鐧诲綍 + const isValid = await loginFormRef.value.validate().catch(() => {}); + if (!isValid) return; + const res = await PostLogin({ + user: state.loginForm.account, + pass: state.loginForm.pwd, + client: LOGIN_CLIENT, + }); + if (!res.json_ok) { + return ElMessage.error(res.json_msg); + } - LoginInfo.set(res.hswatersession, state.loginForm.account); + LoginInfo.set(res.hswatersession, state.loginForm.account); + } else if (state.activeLoginName === 'phoneUser') { + //鎵嬫満鐧诲綍 + const isValid = await formPhoneRef.value.validate().catch(() => {}); + if (!isValid) return; + const res = await loginMessageUser({ + phone: state.loginPhoneForm.phoneUser, + code: state.loginPhoneForm.verifyCode, + client: LOGIN_CLIENT, + }); + if (!res.json_ok) { + return ElMessage.error(res.json_msg); + } + LoginInfo.set(res.hswatersession, state.loginPhoneForm.phoneUser); + } + state.isShowLogin = false; isLoginStatus.value = true; window.location.reload(); @@ -212,10 +243,20 @@ const handleSendVerifyCode = async () => { formPhoneRef.value.validateField('phoneUser', async (valid: boolean) => { if (valid) { - const res = await loginMessageUser({ + const res = await loginVerifyMessage({ phone: state.loginPhoneForm.phoneUser, }); - console.log('馃殌 ~ res:', res); + if (res.json_ok) { + countdown.value = 60; //寮�鍚�掕鏃� + // 鍊掕鏃堕�昏緫 + const intervalId = setInterval(() => { + if (countdown.value > 0) { + countdown.value--; + } else { + clearInterval(intervalId); + } + }, 1000); + } } }); }; @@ -466,6 +507,9 @@ background-color: #fff; border-radius: 5px; } + :deep(.el-form-item--large .el-form-item__error) { + padding: unset !important; + } } .set-pwd { text-align: right; -- Gitblit v1.9.3