mo 1 jaar geleden
bovenliggende
commit
b5e41d94d9

File diff suppressed because it is too large
+ 0 - 0
dist/assets/index-beaf72a0.js


File diff suppressed because it is too large
+ 0 - 0
dist/assets/index-legacy-fd3d6099.js


+ 1 - 1
src/api/user.ts

@@ -5,7 +5,7 @@ import request from '@/utils/request';
  * @param prams 登录参数
  */
 export const userLogin = (params: any) => {
-  return request.post('/edu-oauth/userlogin', {
+  return request.post('/edu-app/userlogin', {
     requestType: 'form',
     data: params
   });

+ 1 - 0
src/views/classList/api.ts

@@ -0,0 +1 @@
+import request from '@/utils/request';

+ 21 - 0
src/views/login/api.ts

@@ -0,0 +1,21 @@
+import request from '@/utils/request';
+
+/**
+ * 登录 - 发送短信获取二维码
+ */
+export const sendSms = (params: any) => {
+  return request.post('/edu-app/open/sendSms', {
+    data: params,
+    requestType: 'form'
+  });
+};
+
+/**
+ * 修改密码-
+ */
+export const updatePassword = (params: any) => {
+  return request.post('/edu-app/user/updatePassword', {
+    data: params,
+    requestType: 'form'
+  });
+};

+ 21 - 8
src/views/login/components/codeLogin.tsx

@@ -14,6 +14,7 @@ import { useRoute, useRouter } from 'vue-router';
 import { PageEnum } from '/src/enums/pageEnum';
 import { storage } from '@/utils/storage';
 import { useUserStore } from '/src/store/modules/users';
+import { sendSms } from '../api';
 interface FormState {
   username: string;
   password: string;
@@ -33,7 +34,6 @@ export default defineComponent({
     const loading = ref(false);
     const autoLogin = ref(true);
     const LOGIN_NAME = PageEnum.BASE_LOGIN_NAME;
-    const showPwd = ref(false);
     const userStore = useUserStore();
     const formInline = reactive({
       username: '',
@@ -41,7 +41,7 @@ export default defineComponent({
       isCaptcha: true
     });
     const isDisabledCode = ref(false);
-    const starTimer = ref(10);
+    const starTimer = ref(60);
     const codeName = '发送短信';
     const handleSubmit = async () => {
       formRef.value.validate(async (errors: any) => {
@@ -53,10 +53,10 @@ export default defineComponent({
           const params: FormState = {
             username,
             password,
-            loginType: 'password',
+            loginType: 'SMS',
             grant_type: 'password',
-            client_id: 'jmedu-backend',
-            client_secret: 'jmedu-backend'
+            client_id: 'cooleshow-teacher',
+            client_secret: 'cooleshow-teacher'
           };
 
           try {
@@ -93,8 +93,21 @@ export default defineComponent({
       });
     };
 
-    const sendMessage = () => {
-      checkTimeOut();
+    const sendMessage = async () => {
+      if (!formInline.username) {
+        message.error('请输入手机号');
+        return;
+      }
+      try {
+        const res = await sendSms({
+          clientId: 'cooleshow-teacher',
+          mobile: formInline.username,
+          type: 'LOGIN'
+        });
+        checkTimeOut();
+      } catch (e) {
+        console.log(e);
+      }
     };
 
     const checkTimeOut = () => {
@@ -147,7 +160,7 @@ export default defineComponent({
                 v-model:value={formInline.password}
                 type="text"
                 showPasswordOn="click"
-                placeholder="请输入码"
+                placeholder="请输入验证码"
                 inputProps={{ autocomplete: 'off' }}
                 class={styles.sendInput}
                 onKeydown={(e: KeyboardEvent) => {

+ 278 - 0
src/views/login/components/forgotPassword.tsx

@@ -0,0 +1,278 @@
+import { defineComponent, reactive, ref } from 'vue';
+import styles from '../index.module.less';
+import pwdIcon from '../images/lock-icon.png';
+import lockIcon from '../images/pwdIcon.png';
+import useIcon from '../images/phoneIcon.png';
+import openEye from '../images/openEye.png';
+import closeEye from '../images/closeEye.png';
+import {
+  useMessage,
+  NForm,
+  NFormItem,
+  NInput,
+  NButton,
+  NInputGroup
+} from 'naive-ui';
+import { useRoute, useRouter } from 'vue-router';
+import { PageEnum } from '/src/enums/pageEnum';
+import { storage } from '@/utils/storage';
+import { useUserStore } from '/src/store/modules/users';
+import { sendSms, updatePassword } from '../api';
+interface FormState {
+  username: string;
+  password: string;
+  grant_type: string;
+  loginType: string;
+  client_id: string;
+  client_secret: string;
+}
+
+export default defineComponent({
+  name: 'forgotPassword',
+  emits: ['changType'],
+  setup(props, { emit }) {
+    const router = useRouter();
+    const route = useRoute();
+    const formRef = ref();
+    const message = useMessage();
+    const loading = ref(false);
+    const autoLogin = ref(true);
+    const LOGIN_NAME = PageEnum.BASE_LOGIN_NAME;
+    const showPwd = ref(false);
+    const showPwd2 = ref(false);
+    const userStore = useUserStore();
+    const formInline = reactive({
+      username: '',
+      password: '',
+      password1: '',
+      code: '',
+      isCaptcha: true
+    });
+    const isDisabledCode = ref(false);
+    const starTimer = ref(60);
+    const codeName = '发送短信';
+
+    const validatePass2 = (rule: any, value: any, callback: any) => {
+      const reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/;
+      if (value === '') {
+        callback(new Error('请再次输入密码'));
+      } else if (value !== formInline.password) {
+        callback(new Error('两次输入密码不一致!'));
+      } else if (!reg.test(value)) {
+        callback(new Error('密码为6-20位数字和字母组合'));
+      } else {
+        callback();
+      }
+    };
+
+    const handleSubmit = async () => {
+      formRef.value.validate(async (errors: any) => {
+        if (!errors) {
+          message.loading('修改中...');
+          loading.value = true;
+          try {
+            await updatePassword({
+              ...formInline
+            });
+            message.success('修改成功');
+            loading.value = false;
+            return false;
+            // emit('changType');
+          } catch (e: any) {
+            loading.value = false;
+            message.error(e.msg);
+            return false;
+            console.log(e);
+          }
+        }
+      });
+      return false;
+    };
+
+    const sendMessage = async () => {
+      if (!formInline.username) {
+        message.error('请输入手机号');
+        return;
+      }
+      try {
+        const res = await sendSms({
+          clientId: 'cooleshow-teacher',
+          mobile: formInline.username,
+          type: 'PASSWORD'
+        });
+        checkTimeOut();
+      } catch (e) {
+        console.log(e);
+      }
+    };
+
+    const checkTimeOut = () => {
+      if (isDisabledCode.value) {
+        return;
+      }
+      isDisabledCode.value = true;
+      const tiemr = setInterval(() => {
+        starTimer.value--;
+        console.log(starTimer.value);
+        if (starTimer.value <= 0) {
+          isDisabledCode.value = false;
+          clearInterval(tiemr);
+        }
+      }, 1000);
+    };
+    return () => (
+      <div class={styles['view-account-form-wrap']}>
+        {/* <div class={styles.formTitle}>
+      <div class={styles.dot}></div>
+      酷乐秀课堂乐器
+    </div> */}
+        <NForm
+          ref={formRef}
+          label-placement="left"
+          size="large"
+          model={formInline}>
+          <NFormItem
+            path="username"
+            rule={[
+              { required: true, message: '请输入手机号', trigger: 'blur' }
+            ]}>
+            <NInput
+              maxlength={11}
+              v-model:value={formInline.username}
+              placeholder="请输入手机号">
+              {{
+                prefix: () => (
+                  <img src={useIcon} class={styles.prefixIcon} alt="" />
+                )
+              }}
+            </NInput>
+          </NFormItem>
+          <NFormItem
+            path="password"
+            rule={[
+              {
+                pattern: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/,
+                message: '密码为6-20位数字和字母组合',
+                trigger: 'blur'
+              }
+            ]}>
+            <NInput
+              v-model:value={formInline.password}
+              type="text"
+              showPasswordOn="click"
+              placeholder="请输入密码"
+              inputProps={{ autocomplete: 'off' }}
+              class={[showPwd.value ? '' : styles['no-pwd']]}>
+              {{
+                prefix: () => (
+                  <img src={pwdIcon} class={styles.prefixIcon} alt="" />
+                ),
+                suffix: () => (
+                  <img
+                    src={showPwd.value ? openEye : closeEye}
+                    class={styles.pwdIcon}
+                    alt=""
+                    onClick={() => {
+                      showPwd.value = !showPwd.value;
+                    }}
+                  />
+                )
+              }}
+            </NInput>
+          </NFormItem>
+          <NFormItem
+            path="password1"
+            rule={[
+              {
+                validator: validatePass2 as any,
+                trigger: 'blur',
+                required: true
+              }
+            ]}>
+            <NInput
+              v-model:value={formInline.password1}
+              type="text"
+              showPasswordOn="click"
+              placeholder="请确认密码"
+              inputProps={{ autocomplete: 'off' }}
+              class={[showPwd2.value ? '' : styles['no-pwd']]}>
+              {{
+                prefix: () => (
+                  <img src={pwdIcon} class={styles.prefixIcon} alt="" />
+                ),
+                suffix: () => (
+                  <img
+                    src={showPwd2.value ? openEye : closeEye}
+                    class={styles.pwdIcon}
+                    alt=""
+                    onClick={() => {
+                      showPwd2.value = !showPwd2.value;
+                    }}
+                  />
+                )
+              }}
+            </NInput>
+          </NFormItem>
+          <NFormItem
+            path="code"
+            rule={[
+              { required: true, message: '请输入验证码', trigger: 'blur' }
+            ]}>
+            <NInputGroup>
+              <NInput
+                v-model:value={formInline.code}
+                type="text"
+                showPasswordOn="click"
+                placeholder="请输入验证码"
+                inputProps={{ autocomplete: 'off' }}
+                class={styles.sendInput}
+                onKeydown={(e: KeyboardEvent) => {
+                  if (e.code === 'Enter') {
+                    handleSubmit();
+                  }
+                }}>
+                {{
+                  prefix: () => (
+                    <img src={lockIcon} class={styles.prefixIcon} alt="" />
+                  ),
+                  suffix: () => (
+                    <NButton
+                      class={styles.sendMsg}
+                      disabled={isDisabledCode.value}
+                      onClick={() => sendMessage()}>
+                      {isDisabledCode.value ? starTimer.value : codeName}
+                    </NButton>
+                  )
+                }}
+              </NInput>
+            </NInputGroup>
+          </NFormItem>
+
+          <NFormItem>
+            <NButton
+              class={[styles.submitBtm, styles.submitForgoBtm]}
+              type="primary"
+              onClick={handleSubmit}
+              size="large"
+              disabled={loading.value}
+              block>
+              确认
+            </NButton>
+          </NFormItem>
+          <NFormItem>
+            <NButton
+              text
+              class={styles.forgetBtm}
+              onClick={() => {
+                emit('changType');
+              }}
+              size="large"
+              block>
+              返回登录
+            </NButton>
+          </NFormItem>
+        </NForm>
+      </div>
+    );
+  }
+});

+ 9 - 4
src/views/login/components/pwdLogin.tsx

@@ -30,7 +30,8 @@ interface FormState {
 
 export default defineComponent({
   name: 'codeLogin',
-  setup() {
+  emits: ['changType'],
+  setup(props, { emit }) {
     const router = useRouter();
     const route = useRoute();
     const formRef = ref();
@@ -39,10 +40,11 @@ export default defineComponent({
     const autoLogin = ref(true);
     const LOGIN_NAME = PageEnum.BASE_LOGIN_NAME;
     const showPwd = ref(false);
+
     const userStore = useUserStore();
     const formInline = reactive({
-      username: '15907121013',
-      password: 'ktyq1013',
+      username: '',
+      password: '',
       isCaptcha: true
     });
 
@@ -104,6 +106,7 @@ export default defineComponent({
               { required: true, message: '请输入用户名', trigger: 'blur' }
             ]}>
             <NInput
+              maxlength={11}
               v-model:value={formInline.username}
               placeholder="请输入用户名">
               {{
@@ -170,7 +173,9 @@ export default defineComponent({
             <NButton
               text
               class={styles.forgetBtm}
-              onClick={handleSubmit}
+              onClick={() => {
+                emit('changType');
+              }}
               size="large"
               block>
               忘记密码

+ 7 - 3
src/views/login/index.module.less

@@ -25,7 +25,7 @@
     align-items: center;
     height: 100%;
     .stylesWrap {
-      margin-top: 174px;
+      margin-top: 64px;
       width: 955px;
       img {
         width: 955px;
@@ -56,10 +56,10 @@
     .colLogo {
       width: 232px;
       height: 79px;
-      margin-bottom: 110px;
+      // margin-bottom: 110px;
     }
     .view-account-form-wrap {
-      margin-top: 100px;
+      margin-top: 60px;
       position: relative;
       background: #ffffff;
       border-radius: 16px;
@@ -157,7 +157,11 @@
         color: #515a6e;
       }
     }
+    .loginTabs.loginForgot {
+      margin-top: 40px;
+    }
     .loginTabs {
+      margin-top: 80px;
       :global {
         .n-tabs-tab-pad {
           width: 80px;

+ 41 - 12
src/views/login/index.tsx

@@ -7,10 +7,14 @@ import CodeLogin from './components/codeLogin';
 import PwdLogin from './components/pwdLogin';
 import { NTabs, NTabPane } from 'naive-ui';
 import styles from './index.module.less';
-
+import ForgotPassword from './components/forgotPassword';
 export default defineComponent({
   name: 'login-page',
   setup() {
+    const isForgot = ref(false);
+    const NavsValue = ref('pwdLogin');
+    const pwdLoginRef = ref();
+    const forgotPasswordRef = ref();
     return () => (
       <div class={styles['view-account']}>
         <div class={styles['view-account-container']}>
@@ -22,17 +26,42 @@ export default defineComponent({
         </div>
         <div class={styles['view-account-form']}>
           <img class={styles.colLogo} src={colLogo}></img>
-          <NTabs
-            default-value="pwdLogin"
-            class={styles.loginTabs}
-            justify-content="center">
-            <NTabPane name="pwdLogin" tab="密码登录">
-              <PwdLogin></PwdLogin>
-            </NTabPane>
-            <NTabPane name="codeLogin" tab="短信验证">
-              <CodeLogin></CodeLogin>
-            </NTabPane>
-          </NTabs>
+          {isForgot.value ? (
+            <NTabs
+              key="forgotPassword"
+              default-value={NavsValue.value}
+              class={[styles.loginTabs, styles.loginForgot]}
+              ref={forgotPasswordRef}
+              justify-content="center">
+              <NTabPane name="forgotPassword" tab="重置密码">
+                <ForgotPassword
+                  onChangType={() => {
+                    isForgot.value = false;
+                    NavsValue.value = 'pwdLogin';
+                    // pwdLoginRef.value.syncBarPosition();
+                  }}></ForgotPassword>
+              </NTabPane>
+            </NTabs>
+          ) : (
+            <NTabs
+              key="pwdLogin"
+              ref={pwdLoginRef}
+              default-value={NavsValue.value}
+              class={[styles.loginTabs]}
+              justify-content="center">
+              <NTabPane name="pwdLogin" tab="密码登录">
+                <PwdLogin
+                  onChangType={() => {
+                    isForgot.value = true;
+                    NavsValue.value = 'forgotPassword';
+                    // forgotPasswordRef.value.syncBarPosition();
+                  }}></PwdLogin>
+              </NTabPane>
+              <NTabPane name="codeLogin" tab="短信验证">
+                <CodeLogin></CodeLogin>
+              </NTabPane>
+            </NTabs>
+          )}
         </div>
       </div>
     );

+ 2 - 5
vite.config.ts

@@ -70,14 +70,11 @@ export default defineConfig({
     cors: true,
     https: false,
     proxy: {
-      '/edu-oauth': {
-        target: proxyUrl,
-        changeOrigin: true
-      },
       '/edu-app': {
         target: proxyUrl,
         changeOrigin: true
-      }
+      },
+
     }
   }
 });

Some files were not shown because too many files changed in this diff