|
@@ -7,14 +7,14 @@ import { setToken } from "/src/utils/auth";
|
|
|
|
|
|
export default defineComponent({
|
|
|
data() {
|
|
|
- const validateUsername = (rule: any, value: any, callback: () => void) => {
|
|
|
- if (!value) {
|
|
|
- // @ts-ignore
|
|
|
- callback(new Error("请输入用户名"));
|
|
|
- } else {
|
|
|
- callback();
|
|
|
- }
|
|
|
- }
|
|
|
+ // const validateUsername = (rule: any, value: any, callback: () => void) => {
|
|
|
+ // if (!value) {
|
|
|
+ // // @ts-ignore
|
|
|
+ // callback(new Error("请输入手机号"));
|
|
|
+ // } else {
|
|
|
+ // callback();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
const validatePassword = (rule: any, value: string | any[], callback: () => void) => {
|
|
|
if (value.length < 6) {
|
|
|
// @ts-ignore
|
|
@@ -30,7 +30,12 @@ export default defineComponent({
|
|
|
} as any,
|
|
|
loginRules: {
|
|
|
username: [
|
|
|
- { required: true, trigger: "blur", validator: validateUsername }
|
|
|
+ { required: true, message: '请输入手机号', trigger: 'blur' },
|
|
|
+ {
|
|
|
+ pattern: /^1[3456789]\d{9}$/,
|
|
|
+ message: '请输入正确的手机号',
|
|
|
+ trigger: 'blur',
|
|
|
+ },
|
|
|
],
|
|
|
password: [
|
|
|
{ required: true, trigger: "blur", validator: validatePassword }
|
|
@@ -73,23 +78,33 @@ export default defineComponent({
|
|
|
if (valid) {
|
|
|
try {
|
|
|
// 根据手机号获取学生信息
|
|
|
-// export const checkStudentPhone = (data) => request2({
|
|
|
-// url: '/api-web/studentManage/queryUserByPhone',
|
|
|
-// method: 'get',
|
|
|
-// params: data,
|
|
|
-// hideLoading: true
|
|
|
-// })
|
|
|
- // const resPhone: any = await request('/api-web/studentManage/queryUserByPhone', {
|
|
|
- // params: {
|
|
|
- // mobile: loginForm.username
|
|
|
- // }
|
|
|
+ // export const checkStudentPhone = (data) => request2({
|
|
|
+ // url: '/api-web/studentManage/queryUserByPhone',
|
|
|
+ // method: 'get',
|
|
|
+ // params: data,
|
|
|
+ // hideLoading: true
|
|
|
// })
|
|
|
+ // /auth-server/user/queryUserByPhone
|
|
|
+ const resPhone: any = await request('/api-auth/user/queryClient', {
|
|
|
+ params: {
|
|
|
+ phone: loginForm.username
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log(resPhone)
|
|
|
+ // "SYSTEM,STUDENT,TEACHER"
|
|
|
+ const authType = resPhone.data
|
|
|
+ let clientType = 'SYSTEM'
|
|
|
+ if (authType.includes('SYSTEM')) {
|
|
|
+ clientType = 'SYSTEM'
|
|
|
+ } else if(authType.includes('TEACHER')) {
|
|
|
+ clientType = 'TEACHER'
|
|
|
+ }
|
|
|
const res: any = await request.post('/api-auth/usernameLogin', {
|
|
|
data: {
|
|
|
username: loginForm.username,
|
|
|
password: loginForm.password,
|
|
|
- clientId: "teacher",
|
|
|
- clientSecret: "teacher"
|
|
|
+ clientId: clientType,
|
|
|
+ clientSecret: clientType
|
|
|
}
|
|
|
})
|
|
|
console.log(res, 'res');
|
|
@@ -97,16 +112,14 @@ export default defineComponent({
|
|
|
console.log(token);
|
|
|
setToken(token)
|
|
|
|
|
|
- // const roomDetail = await request.get('/api-web/imLiveBroadcastRoom/queryRoom', {
|
|
|
- // params: {
|
|
|
- // roomUid: 'w_3fi4PXQcooe5_VUseReA'
|
|
|
- // }
|
|
|
- // })
|
|
|
- // console.log(roomDetail, 'roomDetail');
|
|
|
+ const roomUid = sessionStorage.getItem('roomUid')
|
|
|
+ const roomDetail = await request.get('/api-web/imLiveBroadcastRoom/queryRoom', {
|
|
|
+ params: {
|
|
|
+ roomUid: roomUid
|
|
|
+ }
|
|
|
+ })
|
|
|
ElMessage.success('登录成功')
|
|
|
this.$router.push(this.redirect || '/')
|
|
|
- // this.$router.push({ path: "/home" });
|
|
|
- console.log(res)
|
|
|
} catch (error) {
|
|
|
// console.log(error)
|
|
|
}
|
|
@@ -152,8 +165,9 @@ export default defineComponent({
|
|
|
<ElInput ref="username"
|
|
|
class={styles.loginInput}
|
|
|
v-model={this.loginForm.username}
|
|
|
- placeholder="请输入用户名"
|
|
|
- type="text"
|
|
|
+ placeholder="请输入手机号"
|
|
|
+ maxlength="11"
|
|
|
+ type="tel"
|
|
|
tabindex="1"
|
|
|
auto-complete="off" />
|
|
|
</ElFormItem>
|