This commit is contained in:
吴先生 2023-07-14 13:21:01 +08:00
parent 6ea47ce850
commit 0ac3181dcd
3 changed files with 87 additions and 27 deletions

View File

@ -67,14 +67,13 @@
</template>
</el-menu>
<el-icon
:size="24"
<div
class="icon_switch"
@click="isCollapse = !isCollapse"
>
<img src="../../assets/images/fold.png" alt="" v-if="isCollapse" />
<img src="../../assets/images/expand.png" alt="" v-else />
</el-icon>
</div>
</el-scrollbar>
</el-aside>
<el-main class="content_main">

View File

@ -11,6 +11,7 @@
size="medium"
ref="formRef"
@keyup.enter.native="handleSubmit"
v-if="formPhoneIf"
>
<el-form-item prop="user">
<el-input
@ -43,6 +44,31 @@
<span class="info1">&nbsp;</span>
</el-button>
</el-form>
<el-form
v-else
:model="dataPhone"
size="medium"
ref="formPhoneCodeRef"
:rules="rules"
@keyup.enter.native="handlePhoneSubmit"
>
<el-form-item> 验证码已发送至手机为{{ phone }} </el-form-item>
<el-form-item prop="phoneCode">
<el-input
v-model="dataPhone.phoneCode"
style="width: 100%"
placeholder="验证码"
prefix-icon="Lock"
></el-input>
</el-form-item>
<el-button
class="login-btn-submit"
type="primary"
@click="handlePhoneSubmit(formPhoneCodeRef)"
>
<span class="info1">&nbsp;</span>
</el-button>
</el-form>
</div>
<slideVerify
v-show="slideVerifyShow"
@ -69,6 +95,13 @@ const data = reactive({
password: "",
});
let phone = ref("");
const dataPhone = ref({
phoneCode: "", //
smsAuthCode: "", //
loginAuthCode: "",
});
console.log("paramsData", paramsData);
if (paramsData) {
console.log("存在");
@ -85,33 +118,15 @@ const slideVerifySuccess = () => {
slideVerifyShow.value = false;
loading.value = true;
var params = {
user: encrypt(data.user),
loginName: encrypt(data.user),
password: encrypt(data.password),
};
http.post("/api/auth/login", params).then((resp) => {
if (resp.code == 200) {
var user = {
token: resp.data.token,
name: resp.data.name,
menus: resp.data.menus,
buttons: resp.data.buttons,
accountType: resp.data.accountType,
};
tools.data.set("user", user);
if (remembIf) {
tools.data.set("params", {
user: data.user,
password: data.password,
});
} else {
tools.data.remove("params");
}
ElMessage.success("登录成功");
//loading.value = false;
Router.push("/");
//
console.log(resp.data.loginAuthCode);
phone.value = resp.data.phone;
postPhoneCode(resp.data.loginAuthCode);
} else {
ElMessage.error(resp.message);
loading.value = false;
@ -126,6 +141,52 @@ const handleSubmit = async () => {
}
});
};
const postPhoneCode = (loginAuthCode) => {
var formData = new FormData();
dataPhone.value.loginAuthCode = loginAuthCode;
formData.append("loginAuthCode", loginAuthCode);
http.post("/api/auth/phone_code", formData).then((resp) => {
if (resp.code == 200) {
dataPhone.value.smsAuthCode = resp.data.smsAuthCode;
formPhoneIf.value = false;
}
});
};
const formPhoneIf = ref(true);
const formPhoneCodeRef = ref(null);
const rules = reactive({
phoneCode: [{ required: true, message: "请输入验证码", trigger: "blur" }],
});
const handlePhoneSubmit = (formEl) => {
if (!formEl) return;
formEl.validate((valid, fields) => {
if (valid) {
http.post("/api/auth/token", dataPhone.value).then((resp) => {
if (resp.code == 200) {
var user = {
token: resp.data.token,
name: resp.data.userInfo.userName,
menus: resp.data.menuList,
permissions: resp.data.permissions,
};
tools.data.set("user", user);
ElMessage.success("登录成功");
//loading.value = false;
Router.push("/");
//
} else {
ElMessage.error(resp.message);
}
});
} else {
console.log("error submit!", fields);
}
});
};
</script>
<style lang="scss" scoped>
.login_content {

View File

@ -29,8 +29,8 @@ export default defineConfig({
proxy: {
'/api': {
// target: 'http://10.0.0.29:9999',
target: 'https://fywz.btdit.cn/',
// target: 'http://10.0.0.65:7777/', // 刘进
// target: 'https://fywz.btdit.cn/',
target: 'http://10.0.0.63:7777', // 刘进
changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api/, '')
// ws: true,// 开启webSocket