Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(information): 新增校园资讯 #56

Merged
merged 13 commits into from
Aug 12, 2023
15 changes: 13 additions & 2 deletions project.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,19 @@
"minifyWXSS": true,
"disableUseStrict": false,
"showES6CompileOption": false,
"useCompilerPlugins": false
"useCompilerPlugins": false,
"condition": false
},
"compileType": "miniprogram",
"condition": {}
"condition": {},
"libVersion": "2.25.3",
"srcMiniprogramRoot": "dist/",
"packOptions": {
"ignore": [],
"include": []
},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}
20 changes: 20 additions & 0 deletions project.private.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "WeJH-Taro",
"setting": {
"compileHotReLoad": true
},
"condition": {
"miniprogram": {
"list": [
{
"name": "",
"pathName": "pages/announcement/index",
"query": "",
"launchMode": "default",
"scene": null
}
]
}
}
}
30 changes: 30 additions & 0 deletions src/components/FixedQuickView/InformationQuickView/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,34 @@ const currentPost = ref<{ type: string; content: string }>({
serviceStore.announcement.announcements.length - 1 || 0
].content.replace(/\\n/g, "\n"),
});

const updateCurrentPost = () => {
const information = serviceStore.information.informationList;
const announcement = serviceStore.announcement.announcements;
const infoTime = new Date(information[information.length - 1].publish_time).getTime();
const announcementTime = new Date(announcement[announcement.length - 1].publishTime).getTime();

if (information.length !== 0) {
if (infoTime > announcementTime) {
currentPost.value = {
type: "information",
content: information[information.length - 1].content.replace(
/\\n/g,
"\n"
),
};
} else {
currentPost.value = {
type: "announcement",
content: announcement[announcement.length - 1].content.replace(
/\\n/g,
"\n"
),
};
}
}
};

updateCurrentPost();

</script>
46 changes: 45 additions & 1 deletion src/pages/announcement/InformationCard/index.module.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
@import "@/style/theme";

.container{
background-image: url("https://api.cnpatrickstar.com/img/e3dd45da-f2ea-4f72-85d9-bdfbfa3c42a4.jpg");
background-size: 100% 100%;
}

.title {
font-size: 1.2rem;
word-break: break-word;
font-weight: var(--wjh-font-weight-medium);
justify-content: center;
text-align: center;
padding: 12Px 0;
border-bottom: 1Px solid var(--wjh-color-border);
}

.publisher {
margin-top: 6Px;
text-align: center;
font-size: 0.75rem;
color: var(--wjh-color-week);
}

.content {
white-space: break-spaces;
font-size: 0.875rem;
color: var(--wjh-color-week);
color: var(--wjh-color-text);
line-height: 125%;
margin: 16Px auto;
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
text-overflow: ellipsis;
-webkit-line-clamp: 8;
min-height: 7rem; // 设置最小高度,减小背景形变
}

.link {
padding-top: 16Px;
margin-top: 16Px;
Expand All @@ -23,3 +49,21 @@
font-size: 0.75rem;
color: var(--wjh-color-week);
}

.img_container{
width: 60%;
height: 60%;
display: flex;
justify-content: center;
align-items: center;
margin: 16Px auto;
}

.logo_container{
display: flex;
justify-content: center;
align-items: center;
transform: scale(0.25);
height: calc(40Px);
}

32 changes: 27 additions & 5 deletions src/pages/announcement/InformationCard/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Information } from "@/types/Information";
import styles from "./index.module.scss";
import { Card } from "@/components";
import store from "@/store";
import dayjs from "dayjs";

const props = defineProps<{
source: Information;
Expand All @@ -17,17 +18,38 @@ const handleClickLink = () => {

};

const timeFormat = (time: string) => {
return dayjs(time).format("YYYY年MM月DD日");
};

const Author = "\"For You\"工程";

</script>

<template>
<card :class="styles.container">
<card :class="{ [styles.container]: props.source.publisher === Author }">
j10ccc marked this conversation as resolved.
Show resolved Hide resolved
<view :class="styles.header">
<view :class="styles.title">{{ props.source.content }}</view>
<view :class="styles.title">{{ props.source.title }}</view>
</view>
<view :class="styles.content">{{ props.source.content.replace(/\\n/g, '\n') }}</view>
<view :class="styles.img_container" v-if="props.source.img1">
<image :src="props.source.img1" alt="Card Image" :class="styles.image" mode="aspectFit"></image>
</view>
<view :class="styles.img_container" v-if="props.source.img2">
<image :src="props.source.img2" alt="Card Image" :class="styles.image" mode="aspectFit"></image>
</view>
<view :class="styles.img_container" v-if="props.source.img3">
<image :src="props.source.img3" alt="Card Image" :class="styles.image" mode="aspectFit"></image>
</view>
<view :class="styles.publisher">By: {{ props.source.publisher }}</view>
<view :class="styles.link" @tap="handleClickLink">点击跳转相关规定</view>
<view :class="styles.link" @tap="handleClickLink" v-if="props.source.link">点击跳转相关规定</view>
<template #footer>
<view :class="styles['publish-time']">发布时间: {{ props.source.publish_time }}</view>
<view :class="styles.logo_container">
<image src="https://img.cnpatrickstar.com/5eb88a00-1d66-49af-8c75-ff651a077503.png" alt="logo_fy" :class="styles.logo_fy" mode="aspectFit"></image>
<view :class="styles.x">X</view>
<image src="https://img.cnpatrickstar.com/2633992f-415a-4b6b-b54e-f24adaca7d42.png" alt="logo_jh" :class="styles.logo_jh" mode="aspectFit"></image>
</view>
<view :class="styles.publisher">信息来源: {{ props.source.publisher }}</view>
<view :class="styles['publish-time']">发布时间: {{ timeFormat(props.source.publish_time) }}</view>
</template>
</card>
</template>
1 change: 1 addition & 0 deletions src/pages/announcement/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@
font-size: 0.75rem;
text-align: end;
}

}
1 change: 1 addition & 0 deletions src/services/api/apiList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const api = {
},
applist: "/api/applist",
info: "/api/info",
information: "/api/information",
announcement: "/api/announcement"
};

Expand Down
6 changes: 6 additions & 0 deletions src/services/services/systemService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { api } from "../api/apiList";
import { updateDateState } from "../utils/updateDateState";
import { AppListItem } from "@/types/AppList";
import { Announcement } from "@/types/Announcement";
import { Information } from "@/types/Information";

// comment: 这里的所有请求无需 session
export default class SystemService {
Expand All @@ -18,6 +19,11 @@ export default class SystemService {
);
}

// comment: 校园资讯
static async getInformation(): Promise<Information> {
return updateDateState(api.information, null, "setInformation", null);
}

// comment: 首页应用列表
static async getAppList(): Promise<AppListItem[]> {
// comment: 缓存 applist
Expand Down
4 changes: 4 additions & 0 deletions src/types/Information.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
export interface Information {
id: number;
title: string;
content: string;
publisher: string;
/** 发布时间 */
publish_time: string;
/** 截止时间 用于控制是否显示在首页卡片上 */
end_time: string;
link: string;
img1: string;
img2: string;
img3: string;
}