From e1b028d486713eaf55aaf35fbf334aa568059c0d Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期二, 14 四月 2026 15:46:54 +0800
Subject: [PATCH] 项目复制

---
 src/views/h5/login/index.vue |  141 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 141 insertions(+), 0 deletions(-)

diff --git a/src/views/h5/login/index.vue b/src/views/h5/login/index.vue
new file mode 100644
index 0000000..86af36f
--- /dev/null
+++ b/src/views/h5/login/index.vue
@@ -0,0 +1,141 @@
+<template>
+  <div class="login" v-if="loginType == 'mobilePhone'">
+    <el-form ref="form" :model="form">
+      <el-form-item :rules="[$rules.required('璇疯緭鍏ユ墜鏈哄彿') , $rules.phone()]" prop="mobile">
+        <el-input v-model="form.mobile" placeholder="璇疯緭鍏ユ墜鏈哄彿" style="width: 100%" size="large" />
+      </el-form-item>
+      <el-form-item prop="code" :rules="[$rules.required('璇疯緭鍏ラ獙璇佺爜'), $rules.code()]">
+        <el-input 
+          v-model="form.code" 
+          placeholder="璇疯緭鍏ラ獙璇佺爜" 
+          style="width: 100%" size="large"
+        >
+          <template #append>
+            <el-row style="width: 70px;justify-content: center;">
+              <el-button 
+                v-if="countdown == 180"
+                style="color: var(--el-color-primary);"
+                class="cursor-p" 
+                :loading="sendCodeLoading"
+                @click="sendCode()"
+              >
+                鑾峰彇楠岃瘉鐮�
+              </el-button>
+              <el-text v-else>{{ countdown }}s</el-text>
+            </el-row>
+          </template>
+        </el-input>
+      </el-form-item>
+    </el-form>
+    <el-button @click="login()" :loading="loginLoading" type="primary" size="large" class="mt-2" style="width: 100%">鐧诲綍</el-button>
+  </div>
+</template>
+<script>
+import { tokenUtils } from '@/utils/axios.js';
+import { useLoginStore } from '@/stores/login.js'
+import { storeToRefs } from 'pinia';
+import { isWeixin } from '@/utils/UA.js'
+export default {
+  setup() {
+    const { lastRouteInfo } = storeToRefs(useLoginStore())
+    return { lastRouteInfo }
+  },
+  data() {
+    return {
+      loginType: '', //mobilePhone銆亀eixin
+      form: {
+        mobile: '',
+        code: '',
+      },
+      countdown: 180,
+      sendCodeLoading: false,
+      loginLoading: false,
+      countdownInterval: null
+    }
+  },
+  created() {
+    
+    tokenUtils.clearTokens()
+    this.loginType = isWeixin ? 'weixin' : 'mobilePhone'
+    if (isWeixin) {
+      this.loginType = 'weixin'
+      localStorage.removeItem('weChatRedirectCount')
+      this.$router.replace({ path: '/h5/redirect' })
+    }
+  },
+  computed: {
+    appId() {
+      return this.$route.query.appId
+    }
+  },
+  mounted() {
+    document.title = this.$route.name
+  },
+  methods: {
+    startCountdownInterval() {
+      this.clearCountdownInterval()
+      this.countdown--
+      this.countdownInterval = setInterval(() => {
+        if (this.countdown > 0) {
+          this.countdown--
+        } else {
+          this.countdown = 180
+          this.clearCountdownInterval()
+        }
+      }, 1000)
+    },
+    clearCountdownInterval() {
+      clearInterval(this.countdownInterval)
+      this.countdownInterval = null
+    },
+    async sendCode() {
+      const validate = await this.$refs.form.validateField('mobile')
+      if (validate) {
+        const data = {
+          captchaVerification: '',
+          mobile: this.form.mobile,
+          scene: 31,
+        }
+        this.sendCodeLoading = true
+        this.$axios.post('/system/auth/send-sms-code', data).then(res => {
+          if (res.data.code == 0) {
+            this.startCountdownInterval()
+            this.$message.success('宸插彂閫侀獙璇佺爜锛岃娉ㄦ剰鏌ユ敹')
+          } else {
+            this.$message.error(res.data.msg || '鑾峰彇楠岃瘉鐮佸け璐�')
+          }
+        }).finally(() => {
+          this.sendCodeLoading = false
+        })
+      }
+    },
+    login() {
+      const data = {
+        mobile: this.form.mobile,
+        code: this.form.code,
+      }
+      this.loginLoading = true
+      this.$axios.post('/system/auth/staff/checkin/sms-login', data).then(async res => {
+        if (res.data.code == 0) {
+          const resData = res.data.data
+          tokenUtils.setTokens(resData.accessToken, resData.refreshToken)
+          this.$message.success('鐧诲綍鎴愬姛')
+          const path = localStorage.getItem('verify_url')
+          if (path) {
+            this.$router.replace(path)
+          }
+        } else {
+          this.$message.error(res.data.msg || '鐧诲綍澶辫触')
+        }
+      }).finally(() => {
+        this.loginLoading = false
+      })
+    },
+  }
+}
+</script>
+<style scoped>
+.login {
+  padding: 40px 20px 20px;
+}
+</style>
\ No newline at end of file

--
Gitblit v1.8.0