Skip to content

Commit

Permalink
Merge branch 'feat/tag' of https://github.com/Hazi7/weilai.team into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Mq0501 committed Nov 29, 2024
2 parents 91e5744 + 53956ee commit d81fe99
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import {
SelectTrigger,
SelectValue,
} from '@/components/ui/select'
import { useAlert } from '@/composables/alert'
const useApplicationStore = applicationStore()
useApplicationStore.isGetCode()
const { showAlert } = useAlert()
interface Data {
data: ApplicationFrom;
Expand All @@ -43,12 +44,12 @@ const { getClass, classListData, getCode, sentStuInfo } = UseApplication()
getClass()
const stuInform = ref<ApplicationFrom>({
clazz: '',
clazz: '计科241',
code: '',
email: '',
name: '',
qqNumber: '',
sex: '',
sex: '',
studentId: '',
file: null as unknown as File
})
Expand Down Expand Up @@ -85,6 +86,39 @@ const applicationGetCode = (email: string) => {
function submitForm() {
console.log(stuInform);
// const infoInput = document.getElementsByTagName("input");
// for (let i = 0; i < infoInput.length; i++) {
// if (infoInput[i].value === "") {
// infoInput[i].className += ' noWrite'
// }
// }
// stuInform.forEach((input) => {
// });
let isValid = true;
// 判断输入框是否为空,并添加 'noWrite' 类
const inputs = document.querySelectorAll('input, select');
inputs.forEach((input) => {
const element = input as HTMLInputElement;
if (!element.value && element.type !== 'file') {
element.classList.add('noWrite');
isValid = false;
element.addEventListener('focusin', function (event) {
element.classList.remove('noWrite');
})
} else {
element.classList.remove('noWrite');
}
});
if (!isValid) {
showAlert('请填写所有必填项', 'waring');
return;
}
if (stuInform.value.file == null) {
showAlert('请上传您的简介', 'waring');
return;
}
const formData = new FormData();
formData.append('clazz', stuInform.value.clazz);
formData.append('code', stuInform.value.code);
Expand All @@ -94,8 +128,7 @@ function submitForm() {
formData.append('sex', stuInform.value.sex);
formData.append('studentId', stuInform.value.studentId);
formData.append('file', stuInform.value.file);
sentStuInfo(formData).then((res) => {
})
sentStuInfo(formData)
}
</script>

Expand Down Expand Up @@ -186,8 +219,36 @@ function submitForm() {
</Card>
</div>
</template>
<style scoped>
<style scoped lang="scss">
.recruitment-form {
margin-top: 50px;
.noWrite {
animation: slideIn 0.4s ease-in-out 1;
border-color: rgb(255, 96, 96);
background-color: #fbeceb;
}
}
@keyframes slideIn {
0% {
transform: translateX(0);
}
25% {
transform: translateX(-10px);
}
50% {
transform: translateX(10px);
}
75% {
transform: translateX(-10px);
}
100% {
transform: translateX(0);
}
}
</style>
File renamed without changes.
15 changes: 0 additions & 15 deletions src/components/community/tag/TagHeader.vue

This file was deleted.

42 changes: 31 additions & 11 deletions src/composables/UseApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ interface ClassList {
data: string[]
}

interface Data {
code: number;
message: string
}

interface EmailResponse {
code: number;
message?: string;
Expand Down Expand Up @@ -38,6 +43,7 @@ export default function () {
const res = data.value as EmailResponse;
if (res.code == 1007) {
showAlert("验证码发送成功!", 'pass');
console.log(error);
useApplicationStore.startCountdown()
} else if (res.code == 1005) {
showAlert("验证码未过期", 'waring')
Expand All @@ -51,25 +57,39 @@ export default function () {
console.log(stuInform);
const email = stuInform.get('email') as string | null;
const studentId = stuInform.get('studentId') as string | null;
const clazz = stuInform.get('clazz') as string | null;
const code = stuInform.get('clazz') as string | null;
const name = stuInform.get('clazz') as string | null;
const qqNumber = stuInform.get('clazz') as string | null;
const sex = stuInform.get('clazz') as string | null;
const file = stuInform.get('clazz') as string | null;
// const clazz = stuInform.get('clazz') as string | null;
// const code = stuInform.get('clazz') as string | null;
// const name = stuInform.get('clazz') as string | null;
// const qqNumber = stuInform.get('clazz') as string | null;
// const sex = stuInform.get('clazz') as string | null;
// const file = stuInform.get('clazz') as string | null;

if (email == '' || studentId == '' || clazz == '' || code == '' || name == '' || qqNumber == '' || sex == '') {
showAlert('请填写完整信息', 'waring')
} else if (file == null) {
showAlert('请上传简历', 'waring')
} else if (!email || !(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/).test(email)) {
// if (email == '' || studentId == '' || clazz == '' || code == '' || name == '' || qqNumber == '' || sex == '') {
// showAlert('请填写完整信息', 'waring')
// } else if (file == null) {
// showAlert('请上传简历', 'waring')
// } else
if (!email || !(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/).test(email)) {
// loginError.value = "请输入正确的邮箱"
showAlert('请输入正确的邮箱', 'waring')
} else if (!studentId || !(/^.{11}$/).test(studentId)) {
showAlert('请输入正确格式的学号', 'waring')
} else {
await executeRequest({ url: '/recruit/user/register', method: 'post', headers: { 'Content-Type': 'multipart/form-data' }, requestData: stuInform })
console.log(data, error);
const res = data.value as Data;
if (error.value != null) {
showAlert('服务器内部错误!', 'error')
}
else {
if (res.code == 200) {
showAlert('注册成功!', 'pass')
} else if (res.code == 1008) {
showAlert('验证码错误', 'error')
} else if (res.code == 3102) {
showAlert('该账户已报过名,请勿重复报名', 'waring')
}
}
}

}
Expand Down
2 changes: 0 additions & 2 deletions src/composables/UseLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ export default function () {
} else {
// loginError.value = ''
await executeRequest({ url: `/index/login?account=${account}&password=${password}`, method: 'post', data: { account, password }, headers: { 'Content-Type': 'multipart/form-data' } }) // 在这里传入请求的 URL 和 method
console.log(data);
const res = data.value as Data;
const resData = res.data;
console.log(res);
if (res.code == 1000) {
if (resData) {
setLocalStorageWithExpire('token', resData.token, 1000 * 60 * 60);
Expand Down
72 changes: 72 additions & 0 deletions src/features/community/components/tag/TagContent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<script setup lang="ts">
import TagRightBar from '@/features/community/components/tag/TagRightBar.vue';
import TagSuggest from '@/features/community/components/tag/TagSuggest.vue';
import NewsContent from '@/features/community/components/NewsContent.vue';
import CommunityTag from '@/features/community/composables/CommunityTag';
import { ref, watch } from 'vue';
import { useRoute } from "vue-router";
const route = useRoute();
const { tagPostList, getPostList } = CommunityTag();
const props = defineProps({
tag: {
type: String,
default: 0,
},
});
const tag = ref('');
function getTag() {
console.log(props.tag);
// if ("tag" in route.params) {
// tag.value = route.params.tag as string;
// } else {
// tag.value = "";
// }
getPostList(props.tag);
}
getTag();
watch(
props,
(newVal) => {
getTag()
}
);
</script>

<template>
<div class="tag-container">
<!-- <div>标签</div> -->
<!-- <tag-word-cloud></tag-word-cloud> -->
<div class="all-article">
<NewsContent :tagPostList="tagPostList" />
</div>
<div class="right-bar">
<tag-suggest style="margin: 0 0 30px 0;"></tag-suggest>
<!-- <HotTag style="width: 350px;"></HotTag> -->
<tag-right-bar style=""></tag-right-bar>
</div>
</div>
</template>

<style scoped lang="scss">
.tag-container {
margin-top: 100px;
display: flex;
.all-article {
width: calc(100% - 350px);
}
.right-bar {
width: 330px;
margin-left: 20px;
}
@media screen and (max-width: 1200px) {
// .right-bar {
// display: none;
// }
}
}
</style>
10 changes: 7 additions & 3 deletions src/features/community/composables/CommunityTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function () {
useTagList.value = res.data
}

async function getRecommendTag(){
async function getRecommendTag() {
await executeRequest({ url: `/community_tag/recommend`, method: 'get' })
const res = data.value as TagData;
likeTagList.value = res.data
Expand All @@ -47,8 +47,12 @@ export default function () {
await executeRequest({ url: `/community_tag/relativePost?tagName=${tag}`, method: 'get' })
const res = data.value as Data;
// postList.splice(0, postList.length)
tagPostList.value = res.data.records
console.log(tagPostList);
if (res.code == 50016) {
tagPostList.value = []
} else {
tagPostList.value = res.data.records
}

}

return {
Expand Down
46 changes: 5 additions & 41 deletions src/features/community/pages/discussion/label/[tag].vue
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
<script setup lang="ts">
import TagRightBar from '@/features/community/components/tag/TagRightBar.vue';
import TagSuggest from '@/features/community/components/tag/TagSuggest.vue';
import NewsContent from '@/features/community/components/NewsContent.vue';
import CommunityTag from '@/features/community/composables/CommunityTag';
import { ref, watch } from 'vue';
import { useRoute } from "vue-router";
const route = useRoute();
import { useRoute } from 'vue-router';
import TagContent from '@/features/community/components/tag/TagContent.vue';
const { tagPostList, getPostList } = CommunityTag();
const route = useRoute();
const tag = ref('');
function getTag() {
if ("tag" in route.params) {
tag.value = route.params.tag as string;
} else {
tag.value = "";
}
getPostList(tag.value);
}
getTag();
Expand All @@ -28,38 +23,7 @@ watch(
</script>

<template>
<div class="tag-container">
<!-- <div>标签</div> -->
<!-- <tag-word-cloud></tag-word-cloud> -->
<div class="all-article">
<NewsContent :tagPostList="tagPostList" />
</div>
<div class="right-bar">
<tag-suggest style="margin: 0 0 30px 0;"></tag-suggest>
<!-- <HotTag style="width: 350px;"></HotTag> -->
<tag-right-bar style=""></tag-right-bar>
</div>
</div>
<TagContent :tag="tag" />
</template>

<style scoped lang="scss">
.tag-container {
margin-top: 100px;
display: flex;
.all-article {
width: calc(100% - 350px);
}
.right-bar {
width: 330px;
margin-left: 20px;
}
@media screen and (max-width: 1200px) {
// .right-bar {
// display: none;
// }
}
}
</style>
<style scoped></style>
2 changes: 1 addition & 1 deletion src/pages/application.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import ApplicationFrom from '../features/community/components/application/ApplicationFrom.vue';
import ApplicationFrom from '../components/application/ApplicationFrom.vue';
</script>

<template>
Expand Down
1 change: 1 addition & 0 deletions src/types/Community.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface Data {
data: ArticleInfo;
code: Number
}
export interface AdminData {
data: AdminPostInfo;
Expand Down

0 comments on commit d81fe99

Please sign in to comment.