Pārlūkot izejas kodu

feat 新增学生忘记密码功能

sys5923812@126.com 1 mēnesi atpakaļ
vecāks
revīzija
1b34d515b6

+ 55 - 0
src/api/xjc-platform/xjc_index.js

@@ -0,0 +1,55 @@
+import request from '@/utils/request'
+//获取用户基本信息,用来判断是否登录
+export function getBaseInfo() {
+    return request({
+        url: '/platform/BaseController/getBaseUserInfo',
+        method: 'post'
+    })
+}
+
+export function getUserInfo(userName) {
+    return request({
+        url: '/platform/BaseController/getUserInfo',
+        method: 'post',
+        data : userName
+    })
+}
+
+export function sendCheckCode(data) {
+    return request({
+        url: '/platform/BaseController/sendCheckCode',
+        method: 'post',
+        data : data
+    })
+}
+
+export function validCheckCodeAndRegister(data) {
+    return request({
+        url: '/platform/BaseController/validCheckCode',
+        method: 'post',
+        data : data
+    })
+}
+
+export function regist(data) {
+    return request({
+        url: '/platform/BaseController/regist',
+        method: 'post',
+        data : data
+    })
+}
+export function getSecretByUser(userName) {
+    return request({
+        url: '/platform/BaseController/getSecretByUser',
+        method: 'post',
+        data : userName
+    })
+}
+
+export function changPasswordBySecret(userName) {
+    return request({
+        url: '/platform/BaseController/changPasswordBySecret',
+        method: 'post',
+        data : userName
+    })
+}

+ 20 - 4
src/layout/index.vue

@@ -19,14 +19,30 @@
 </template>
 
 <script setup>
+
+    import {getBaseInfo} from '@/api/xjc-platform/xjc_index'
+
     const router = useRouter()
 
     function indexJump(path) {
-        console.log("path:",path)
-        router.push({
-            path: path,
-            query: {name: 123}
+
+        getBaseInfo().then(resp => {
+            if (resp.loginUser.userName == 'xjc_customer') {
+                //访客身份,直接去登录
+                router.push({
+                    path: '/xjc-integratedmachine/login/login_index',
+                    query:{
+                        modulePath : path
+                    }
+                })
+            } else {
+                router.push({
+                    path: path,
+                })
+            }
         })
+
+
     }
 </script>
 

+ 2 - 1
src/permission.js

@@ -25,7 +25,8 @@ const whiteList = ['/login', '/register', '/xjc_index',
     '/xjc-integratedmachine/wakeup/career_cinema/index',
     '/xjc-integratedmachine/login/login_index',
     '/xjc-integratedmachine/login/student_login',
-    '/xjc-integratedmachine/login/visitor_login'
+    '/xjc-integratedmachine/login/visitor_login',
+    '/xjc-integratedmachine/login/student_forgetpass'
 
 ]
 

+ 10 - 0
src/router/index.js

@@ -10,6 +10,11 @@ import router_plan from '@/router/router_plan.js'
 // 公共路由
 export const constantRoutes = [
     {
+        name: '/xjc_login',
+        path: '/xjc_login',
+        component: () => import('@/views/login'),
+    },
+    {
         path: '/xjc_index',
         component: () => import('@/layout/index'),
     },
@@ -28,6 +33,11 @@ export const constantRoutes = [
         path: '/xjc-integratedmachine/login/visitor_login',
         component: () => import('@/views/xjc-integratedmachine/login/visitor_login'),
     },
+    //学生忘记密码
+    {
+        path: '/xjc-integratedmachine/login/student_forgetpass',
+        component: () => import('@/views/xjc-integratedmachine/login/student_forgetpass.vue'),
+    },
 
     {
         path: '/redirect',

+ 1 - 1
src/router/router_cognize.js

@@ -1,6 +1,6 @@
 const router = [
     {
-        path: '/integratedmachine/cognize/index',
+        path: '/xjc-integratedmachine/cognize/index',
         component: () => import('@/views/xjc-integratedmachine/cognize/index'),
     }
 ]

+ 1 - 1
src/router/router_decision.js

@@ -1,6 +1,6 @@
 const router=[
     {
-        path: '/integratedmachine/decision/index',
+        path: '/xjc-integratedmachine/decision/index',
         component: () => import('@/views/xjc-integratedmachine/decision/index'),
     }
 ]

+ 1 - 1
src/router/router_environment.js

@@ -1,6 +1,6 @@
 const router = [
     {
-        path: '/integratedmachine/environment/index',
+        path: '/xjc-integratedmachine/environment/index',
         component: () => import('@/views/xjc-integratedmachine/environment/index'),
     }
 ]

+ 1 - 1
src/router/router_plan.js

@@ -1,6 +1,6 @@
 const router = [
     {
-        path: '/integratedmachine/plan/index',
+        path: '/xjc-integratedmachine/plan/index',
         component: () => import('@/views/xjc-integratedmachine/plan/index'),
     }
 ]

+ 29 - 4
src/views/login.vue

@@ -16,9 +16,11 @@
     const router = useRouter()
     const {proxy} = getCurrentInstance()
 
+    const params = route.query
+
     const loginForm = ref({
-        username: "admin",
-        password: "admin123",
+        username: "xjc_customer",
+        password: "123456",
         loginType: "1",
         rememberMe: false,
         code: "",
@@ -106,6 +108,17 @@
 
 
     function handleLogin2() {
+
+        console.log("*****",params.modulePath)
+
+        if(params.modulePath == undefined || params.redirect=='/index'){
+            //默认来的
+        }else{
+            //注册后来的
+            loginForm.value.username = params.userName
+            loginForm.value.password = params.password
+        }
+
         loading.value = true
         // 调用action的登录方法
         loginForm.value.loginType = "1"
@@ -117,7 +130,18 @@
                 }
                 return acc
             }, {})
-            router.push({path: redirect.value || "/", query: otherQueryParams})
+
+            //-------------孙一石修改
+            if(params.modulePath == undefined || params.redirect=='/index'){
+                router.push({path: redirect.value || "/", query: otherQueryParams})
+            }else{
+                //注册后来的
+                router.push({
+                    path : params.modulePath
+                })
+            }
+
+
         }).catch(() => {
             loading.value = false
             // 重新获取验证码
@@ -127,11 +151,12 @@
         })
 
     }
+
     function handleLogin3() {
         router.push({path: "/xjc_index"})
     }
 
-    handleLogin3()
+    handleLogin2()
 </script>
 
 <style lang='scss' scoped>

+ 25 - 5
src/views/xjc-integratedmachine/components/head_component.vue

@@ -1,19 +1,39 @@
 <template>
     <div class="contenter">
-        <el-button>返回</el-button>
+        <el-button @click="backTo">返回</el-button>
         <div>{{headinfo.title}}</div>
         <div>头像</div>
-        <el-button>退出</el-button>
+        <el-button @click="exit">退出</el-button>
         <el-button>使用说明</el-button>
     </div>
 </template>
 
 <script setup>
-    defineProps({
-        headinfo: {
 
-        }
+    const {proxy} = getCurrentInstance()
+    const router = useRouter()
+    const props = defineProps({
+        headinfo: {}
     })
+
+    function backTo() {
+        router.push({
+            path: props.headinfo.backUrl
+        })
+    }
+
+    function exit() {
+        proxy.$modal.confirm('您确认退出吗').then(function () {
+            router.push({
+                path: '/xjc_login'
+            })
+        }).then(() => {
+        }).catch(() => {
+        })
+
+    }
+
+
 </script>
 
 <style scoped>

+ 7 - 1
src/views/xjc-integratedmachine/login/index.vue

@@ -13,10 +13,16 @@
 
 <script setup>
     const router = useRouter()
+    const route = useRoute()
+
+    const params = route.query
+
     function jumpTo(path) {
-        console.log("path:", path)
         router.push({
             path: path,
+            query : {
+                modulePath : params.modulePath
+            }
         })
     }
 </script>

+ 62 - 0
src/views/xjc-integratedmachine/login/student_forgetpass.vue

@@ -0,0 +1,62 @@
+<template>
+    身份证号
+    <el-input v-model="form.userName" @input="getSecret"></el-input>
+    新密码
+    <el-input type="password" v-model="form.password"></el-input>
+    确认新密码
+    <el-input type="password" v-model="form.reppassword"></el-input>
+    通过您的密保问题验证身份
+    保密问题
+    <el-input v-model="form.secretQuestion"></el-input>
+    保密答案
+    <el-input v-model="form.secretAnswer"></el-input>
+    <el-button @click="changePass">确认修改</el-button>
+</template>
+
+<script setup>
+    import {getSecretByUser,changPasswordBySecret} from '@/api/xjc-platform/xjc_index.js'
+
+    const loading = ref(false)
+    const router = useRouter()
+    const route = useRoute()
+    const {proxy} = getCurrentInstance()
+
+    const params = route.query
+
+    const form = ref({
+        userName: '',
+        password: '',
+        reppassowrd: '',
+        secretQuestion: '',
+        secretAnswer: ''
+    })
+
+    function getSecret() {
+        if (form.value.userName.length == 15 || form.value.userName.length == 18) {
+            getSecretByUser(form.value.userName).then(resp => {
+                form.value.secretQuestion = resp.question
+            })
+        }
+    }
+    function  changePass() {
+        changPasswordBySecret(form.value).then(resp =>{
+            proxy.$modal.msgSuccess("修改密码成功")
+            //跳转到主页
+            router.push({
+                path : '/xjc_login',
+                query :{
+                    userName : form.value.userName,
+                    password : form.value.password,
+                    modulePath : params.modulePath
+                }
+            })
+        })
+    }
+
+
+</script>
+
+<style scoped>
+
+
+</style>

+ 98 - 5
src/views/xjc-integratedmachine/login/student_login.vue

@@ -1,15 +1,108 @@
 <template>
 
     <div>
-        身份证号 <el-input></el-input>
-        <br>
-        密码 <el-input type="password"></el-input>
-        <el-button>登录</el-button>
-        <el-button>忘记密码</el-button>
+        <el-form ref="loginRef" :model="loginForm" :rules="loginRules" class="login-form">
+            <h3 class="title">{{ title }}</h3>
+            <el-form-item prop="username">
+                <el-input
+                        v-model="loginForm.username"
+                        type="text"
+                        size="large"
+                        auto-complete="off"
+                        placeholder="身份证号"
+                >
+                    <template #prefix>
+                        <svg-icon icon-class="user" class="el-input__icon input-icon"/>
+                    </template>
+                </el-input>
+            </el-form-item>
+            <el-form-item prop="password">
+                <el-input
+                        v-model="loginForm.password"
+                        type="password"
+                        size="large"
+                        auto-complete="off"
+                        placeholder="密码"
+                        @keyup.enter="handleLogin"
+                >
+                    <template #prefix>
+                        <svg-icon icon-class="password" class="el-input__icon input-icon"/>
+                    </template>
+                </el-input>
+            </el-form-item>
+
+            <el-form-item style="width:100%;">
+                <el-button
+                        :loading="loading"
+                        size="large"
+                        type="primary"
+                        style="width:100%;"
+                        @click.prevent="handleLogin"
+                >
+                    <span v-if="!loading">登 录</span>
+
+                    <span v-else>登 录 中...</span>
+                </el-button>
+                <el-button @click="forgetPass">忘记密码</el-button>
+                <div style="float: right;" v-if="register">
+                    <router-link class="link-type" :to="'/register'">立即注册</router-link>
+                </div>
+            </el-form-item>
+        </el-form>
     </div>
 </template>
 
 <script setup>
+    import {login} from '@/api/login'
+    import useUserStore from '@/store/modules/user'
+    import { setToken } from '@/utils/auth'
+    const userStore = useUserStore()
+
+    const {proxy} = getCurrentInstance()
+
+    const router = useRouter()
+    const route = useRoute()
+
+    const params = route.query
+
+    const loading = ref(false)
+    const loginForm = ref({
+        username: "",
+        password: "",
+        loginType: "1",
+        rememberMe: false,
+        code: "",
+        uuid: ""
+    })
+    const loginRules = {
+        username: [{required: true, trigger: "blur", message: "请输入您的身份证号"}],
+        password: [{required: true, trigger: "blur", message: "请输入您的密码"}],
+    }
+
+    function handleLogin() {
+        proxy.$refs.loginRef.validate(valid => {
+            if (valid) {
+                loading.value = true
+                // 调用action的登录方法
+                loginForm.value.loginType = "1"
+                login(loginForm.value.username, loginForm.value.password, null, null, loginForm.value.loginType).then(resp => {
+                    setToken(resp.data.access_token)
+                    router.push({
+                        path: params.modulePath
+                    })
+                })
+            }
+        })
+    }
+
+    function forgetPass() {
+        router.push({
+            path : '/xjc-integratedmachine/login/student_forgetpass',
+            query:{
+                modulePath : params.modulePath
+            }
+        })
+    }
 
 </script>
 

+ 134 - 1
src/views/xjc-integratedmachine/login/visitor_login.vue

@@ -1,9 +1,142 @@
 <template>
-游客登录
+    <div>
+        游客登录
+    </div>
+    <div v-show="step == 1">
+        手机号
+        <el-input v-model="loginForm.userName"></el-input>
+        <el-button @click="phoneLogin">登录</el-button>
+    </div>
+    <div v-show="step == 2">
+        手机号
+        <el-input v-model="loginForm.userName"></el-input>
+        <el-button @click="getCheckCode">
+            <div v-show="seconds == 60">发送验证码</div>
+            <div v-show="seconds < 60 && seconds >=0">剩余{{seconds}}秒</div>
+        </el-button>
+        验证码
+        <el-input v-model="loginForm.checkCode"></el-input>
+        <el-button @click="validCheckCode">注册</el-button>
+    </div>
+    <div v-show="step == 3">
+        密码
+        <el-input type="password" v-model="loginForm.password"></el-input>
+        再次确认密码
+        <el-input type="password" v-model="loginForm.reppassword"></el-input>
+        高考省份:{{loginForm.areaId}}:{{loginForm.areaName}}
+        <div>
+            <span v-for="dict in gk_province" :key="dict.value" @click="chooseArea(dict.value,dict.label)">{{dict.label}}&nbsp;&nbsp;&nbsp;&nbsp;</span>
+        </div>
+        <el-button @click="registHandler">注册</el-button>
+    </div>
+    <div v-show="step == 4">
+        手机号
+        <el-input v-model="loginForm.userName"></el-input>
+        密码
+        <el-input v-model="loginForm.password" type="password"></el-input>
+        <el-button @click="visitor_login">登录</el-button>
+    </div>
+
 </template>
 
 <script setup>
 
+    import {getUserInfo, sendCheckCode, validCheckCodeAndRegister,regist} from '@/api/xjc-platform/xjc_index.js'
+    import {login} from '@/api/login'
+    import { setToken } from '@/utils/auth'
+    const loading = ref(false)
+    const router = useRouter()
+    const route = useRoute()
+    const {proxy} = getCurrentInstance()
+    const {rank, gk_province} = proxy.useDict('rank', 'gk_province')
+    const params = route.query
+    //1手机号 2-验证码注册 3-设置密码和省份
+
+    const step = ref(1)
+    const seconds = ref(60)
+
+
+
+    const loginForm = ref({
+        userName: '',
+        //一体机用户手机注册
+        businessType: '1',
+        checkCode: '',
+        areaId:null,
+        areaName: null,
+        password : '',
+        reppassword :''
+    })
+
+    function phoneLogin() {
+        getUserInfo(loginForm.value.userName).then(resp => {
+            if (resp.sysUser == null) {
+                //没有此人,需要注册
+                step.value = 2
+            } else {
+                step.value = 4
+            }
+        })
+    }
+
+    function getCheckCode() {
+        sendCheckCode(loginForm.value).then(resp => {
+            console.log("一体机注册,验证码:", resp.checkCode)
+            //开始倒计数
+            secondsBegin()
+        })
+    }
+
+    function secondsBegin() {
+        seconds.value--;
+        if (seconds.value > 0) {
+            window.setTimeout(secondsBegin, 1000)
+        } else {
+            seconds.value = 60
+        }
+    }
+
+    function validCheckCode() {
+        validCheckCodeAndRegister(loginForm.value).then(resp => {
+            if (resp.codeValidResult == true) {
+                step.value = 3
+            }
+        })
+    }
+    function chooseArea(areaId,areaName) {
+        loginForm.value.areaId = areaId
+        loginForm.value.areaName = areaName
+    }
+    function registHandler() {
+        if(loginForm.value.password != loginForm.value.reppassword){
+            proxy.$modal.msgError("密码不一致")
+        }else{
+            regist(loginForm.value).then(resp =>{
+                proxy.$modal.msgSuccess("注册成功")
+                //跳转到主页
+                router.push({
+                    path : '/xjc_login',
+                    query :{
+                        userName : loginForm.value.userName,
+                        password : loginForm.value.password,
+                        modulePath : params.modulePath
+                    }
+                })
+            })
+        }
+    }
+    function visitor_login(){
+        loading.value = true
+        // 调用action的登录方法
+        loginForm.value.loginType = "1"
+        login(loginForm.value.userName, loginForm.value.password, null, null, loginForm.value.loginType).then(resp => {
+            setToken(resp.data.access_token)
+            router.push({
+                path: params.modulePath
+            })
+        })
+    }
+
 </script>
 
 <style scoped>

+ 2 - 1
src/views/xjc-integratedmachine/wakeup/index.vue

@@ -33,7 +33,8 @@
             user: {
                 avatar: '头像路径',
                 nickName: '张三'
-            }
+            },
+            backUrl : '/index'
         }
     }