From 3529fb5b644a50e883c197a921fbc5021f5308a0 Mon Sep 17 00:00:00 2001 From: Phoenix <64720302+Concur-max@users.noreply.github.com> Date: Wed, 31 Jan 2024 16:18:27 +0800 Subject: [PATCH] submit --- src/components/operateTitle/index.vue | 15 ++++++++-- src/main.js | 1 + src/router/index.js | 4 +++ src/util/storage.js | 43 +++++++++++++++++++++++++++ src/views/logon/index.vue | 25 +++++++++++++++- src/views/signup/index.vue | 9 +++++- src/views/upload-id-card/index.vue | 11 +++++++ 7 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 src/util/storage.js create mode 100644 src/views/upload-id-card/index.vue diff --git a/src/components/operateTitle/index.vue b/src/components/operateTitle/index.vue index 7c9773a..347f938 100644 --- a/src/components/operateTitle/index.vue +++ b/src/components/operateTitle/index.vue @@ -1,5 +1,14 @@ diff --git a/src/main.js b/src/main.js index 6b7287d..1f555b2 100644 --- a/src/main.js +++ b/src/main.js @@ -3,6 +3,7 @@ import { createApp } from 'vue'; import App from './App.vue'; import router from './router'; import 'normalize.css'; +import 'vant/lib/index.css'; const app = createApp(App); diff --git a/src/router/index.js b/src/router/index.js index b37f884..2cfe5a7 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -14,6 +14,10 @@ const routes = [ { path: 'logon', component: () => import('@/views/logon/index.vue') + }, + { + path: 'upload-id-card', + component: () => import('@/views/upload-id-card/index.vue') } ] } diff --git a/src/util/storage.js b/src/util/storage.js new file mode 100644 index 0000000..241a62f --- /dev/null +++ b/src/util/storage.js @@ -0,0 +1,43 @@ +// storage.js + +class StorageService { + constructor(storage) { + this.storage = storage; + } + + setItem(key, value, expire = null) { + const obj = { + data: value, + }; + if (expire) { + const expireTime = new Date().getTime() + expire * 1000; + obj.expire = expireTime; + } + this.storage.setItem(key, JSON.stringify(obj)); + } + + getItem(key) { + const itemStr = this.storage.getItem(key); + if (!itemStr) { + return null; + } + const item = JSON.parse(itemStr); + if (item.expire && new Date().getTime() > item.expire) { + this.storage.removeItem(key); + return null; + } + return item.data; + } + + removeItem(key) { + this.storage.removeItem(key); + } + + clear() { + this.storage.clear(); + } +} + +const localStorageService = new StorageService(window.localStorage); + +export default localStorageService; diff --git a/src/views/logon/index.vue b/src/views/logon/index.vue index bd872d5..ddfe292 100644 --- a/src/views/logon/index.vue +++ b/src/views/logon/index.vue @@ -3,6 +3,27 @@ const router = useRouter(); router.go(-1);*/ +import {ref,onBeforeUnmount} from "vue"; +const isCountingDown = ref(false); +const timeLeft = ref(60); +const countdownInterval = ref(null); + +const sendCode = async () => { + isCountingDown.value = true; + countdownInterval.value = setInterval(() => { + if (timeLeft.value > 0) { + timeLeft.value--; + } else { + clearInterval(countdownInterval.value); + isCountingDown.value = false; + timeLeft.value = 60; + } + }, 1000); +}; + +onBeforeUnmount(() => { + clearInterval(countdownInterval.value); +});