|
|
@@ -62,9 +62,9 @@
|
|
|
<script setup lang="ts">
|
|
|
import { ref, reactive, onMounted } from 'vue'
|
|
|
import { useRouter } from 'vue-router'
|
|
|
-import { showFailToast, showToast } from 'vant'
|
|
|
-import { loginEtssmsApi } from '@/services/modules/login'
|
|
|
-import type { LoginEtssmsRequest } from '@/services/modules/login/type.d'
|
|
|
+import { showFailToast, showSuccessToast, showToast } from 'vant'
|
|
|
+import { sendEtsSmsApi, loginEtssmsApi } from '@/services/modules/login'
|
|
|
+import type { SendTtsSmsRequest, LoginEtssmsRequest } from '@/services/modules/login/type.d'
|
|
|
import { useUserStore } from '@/stores/modules/user'
|
|
|
|
|
|
const userStore = useUserStore()
|
|
|
@@ -77,6 +77,11 @@ const formData = reactive<LoginEtssmsRequest>({
|
|
|
code: '5657',
|
|
|
})
|
|
|
|
|
|
+const sendEtsSms = reactive<SendTtsSmsRequest>({
|
|
|
+ mobile: '',
|
|
|
+ pushRecordId: '2',
|
|
|
+})
|
|
|
+
|
|
|
/* 限制手机号只能输入数字,最多 30 位 */
|
|
|
const onInputMobile = (val: string) => {
|
|
|
formData.mobile = val.replace(/\D/g, '').slice(0, 30)
|
|
|
@@ -96,14 +101,17 @@ const countDown = ref(60)
|
|
|
let timer: number | undefined
|
|
|
|
|
|
/* 发送验证码 */
|
|
|
-const sendCode = () => {
|
|
|
+const sendCode = async () => {
|
|
|
if (!/^1\d{10}$/.test(formData.mobile)) {
|
|
|
showToast('请输入正确的手机号')
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- showToast('验证码已发送')
|
|
|
- startCountDown()
|
|
|
+ sendEtsSms.mobile = formData.mobile
|
|
|
+ const res = await sendEtsSmsApi(sendEtsSms)
|
|
|
+ if (res.code === 0 && res.data) {
|
|
|
+ showSuccessToast('发送成功')
|
|
|
+ startCountDown()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/* 倒计时逻辑 */
|
|
|
@@ -121,10 +129,14 @@ const startCountDown = () => {
|
|
|
|
|
|
/* 登录逻辑 */
|
|
|
const login = async () => {
|
|
|
- if (!formData.mobile || !formData.code) {
|
|
|
+ if (!formData.mobile) {
|
|
|
showFailToast('请输入手机号和验证码')
|
|
|
return
|
|
|
}
|
|
|
+ if (!formData.code) {
|
|
|
+ showFailToast('验证码不能为空')
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
if (!agree.value) {
|
|
|
showFailToast('请勾选阅读并同意')
|
|
|
@@ -252,7 +264,7 @@ onMounted(() => {
|
|
|
line-height: 5vw;
|
|
|
margin: 4vw 0;
|
|
|
color: #666;
|
|
|
- padding-left: 50px;
|
|
|
+ padding-left: 36px;
|
|
|
label {
|
|
|
display: flex;
|
|
|
align-items: center;
|