需要开发 IM

This commit is contained in:
cbb
2025-12-30 17:52:19 +08:00
parent 8fe2079446
commit d0cf491201
23 changed files with 515 additions and 61 deletions

View File

@@ -1,18 +1,34 @@
<script setup></script>
<script setup>
import { getArticleDetail } from '@/api'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
const formData = ref({})
const getData = async () => {
const res = await getArticleDetail('company_info')
formData.value = res.data
}
onLoad(() => {
getData()
})
</script>
<template>
<view class="company">
<view class="top-log">
<image
src="https://qcloud.dpfile.com/pc/TrdZpLN1zkXDV4oN2FH98LdVnvHj694NKQu0_KA3ul4eYxZWRPQ7CJuw-PqyZBS4.jpg"
:src="formData.articleImg"
mode="aspectFill"
class="img"
></image>
<text>名字</text>
<text>{{ formData.articleTitle }}</text>
</view>
<view class="consten">
<view class="item">富文本</view>
<view class="item">
<mp-html :content="formData.articleDetails"></mp-html>
</view>
</view>
</view>
</template>

View File

@@ -23,7 +23,9 @@ text-transform: none;`
<view class="release-box">
<nav-bar isPlaceholder>
<template #right>
<text class="right-btn" @click="onUpData">发布</text>
<text class="public-navbar__right-btn" @click="onUpData">
发布
</text>
</template>
</nav-bar>
@@ -46,18 +48,6 @@ text-transform: none;`
</template>
<style lang="scss" scoped>
.right-btn {
font-family: PingFang SC, PingFang SC;
font-weight: 500;
font-size: 28rpx;
color: #ffffff;
font-style: normal;
text-transform: none;
background: linear-gradient(0deg, #00d993 0%, #00d9c5 100%);
padding: 12rpx 36rpx;
border-radius: 8rpx;
}
.content {
padding: 32rpx 58rpx;
.textarea {

View File

@@ -1,16 +1,164 @@
<script setup>
import { ref } from 'vue'
import { formatMonthDay, formatDate } from '@/utils/dateUtils'
import { onLoad } from '@dcloudio/uni-app'
import { getSignList, signIn } from '@/api'
import { useUI } from '@/utils/use-ui'
import { useAuthUser } from '@/composables/useAuthUser'
import { useUserStore } from '@/stores/user'
const weekList = ['一', '二', '三', '四', '五', '六', '日']
const { showToast } = useUI()
const { userInfo } = useAuthUser()
const { refreshUserInfo } = useUserStore()
const indexData = ref([1, 2, 3, 4])
const weekList = [
{ name: '一', value: 1 },
{ name: '二', value: 2 },
{ name: '三', value: 3 },
{ name: '四', value: 4 },
{ name: '五', value: 5 },
{ name: '六', value: 6 },
{ name: '日', value: 7 }
]
const indexData = ref([])
const onItem = item => {
if (indexData.value.includes(item)) {
return
const currentYear = ref(2025)
const currentMonth = ref(12)
/** 日期列表 */
const dateList = ref([])
/** 连续天数 */
const continuousDays = ref(0)
const getData = async msg => {
const res = await getSignList({
signMonth: `${currentYear.value}-${currentMonth.value}`
})
dateList.value = generateCalendar(
currentYear.value,
currentMonth.value
)
if (msg) {
await refreshUserInfo()
showToast(msg)
}
indexData.value.push(item)
continuousDays.value = res.data.continuousDays
indexData.value = res.data.list.map(v => v.signDate)
}
/**
* 生成一个 5x7 的日历数组(从周一到周日)
* @param {number} year - 当前年份
* @param {number} month - 当前月份1-12
* @returns {Array<{ date: Date, type: 'prev' | 'current' | 'next' }>}
*/
const generateCalendar = (year, month) => {
const today = new Date()
const todayYear = today.getFullYear()
const todayMonth = today.getMonth()
const todayDate = today.getDate()
// 辅助函数:判断两个 Date 是否是同一天(忽略时分秒)
const isSameDay = (d1, d2) => {
return (
d1.getFullYear() === d2.getFullYear() &&
d1.getMonth() === d2.getMonth() &&
d1.getDate() === d2.getDate()
)
}
// 创建当前月的第一天
const firstDay = new Date(year, month - 1, 1)
// 创建当前月的最后一天
const lastDay = new Date(year, month, 0)
// 获取当前月第一天是星期几
let startDayOfWeek = firstDay.getDay()
// 转换为以周一为 0如果 getDay() 是 0周日则视为 6即一周最后一天
if (startDayOfWeek === 0) startDayOfWeek = 7
const offsetFromMonday = startDayOfWeek - 1 // 周一为0
// 上个月的最后一天
const prevMonthLastDay = new Date(year, month - 1, 0).getDate()
// 当前月总天数
const currentMonthDays = lastDay.getDate()
const calendar = []
// 仅用于比较
const todayRef = new Date(todayYear, todayMonth, todayDate)
// 填充上个月的尾几天
for (let i = 0; i < offsetFromMonday; i++) {
const day = prevMonthLastDay - offsetFromMonday + 1 + i
const date = new Date(year, month - 2, day) // month - 2 表示上个月
calendar.push({
date: formatMonthDay(date),
signDate: formatDate(date),
type: 'prev',
isToday: isSameDay(date, todayRef)
})
}
// 填充当前月
for (let i = 0; i < currentMonthDays; i++) {
const date = new Date(year, month - 1, i + 1)
calendar.push({
date: formatMonthDay(date),
signDate: formatDate(date),
type: 'current',
isToday: isSameDay(date, todayRef)
})
}
// 填充下个月的前几天,使总数达到 355*7
const remaining = 35 - calendar.length
for (let i = 1; i <= remaining; i++) {
const date = new Date(year, month, i) // month 是下个月(因为 JS 月份从 0 开始)
calendar.push({
date: formatMonthDay(date),
signDate: formatDate(date),
type: 'next',
isToday: isSameDay(date, todayRef)
})
}
return calendar
}
/** 点击签到 */
const onItem = async item => {
if (!item.isToday) return
const res = await signIn()
await getData(res.data.message)
}
/** 日期切换 */
const dateChange = e => {
if (e === 0) {
if (currentMonth.value === 1) {
currentYear.value--
currentMonth.value = 12
} else {
currentMonth.value--
}
} else {
if (currentMonth.value === 12) {
currentYear.value++
currentMonth.value = 1
} else {
currentMonth.value++
}
}
getData()
}
onLoad(() => {
getData()
})
</script>
<template>
@@ -27,7 +175,7 @@
<view class="public-header—box">
<view class="integral-box">
<text>我的积分</text>
<text>410</text>
<text>{{ userInfo.totalPoints }}</text>
</view>
<image
src="/static/images/discover/calendar.png"
@@ -41,28 +189,40 @@
<text class="title">每日签到领积分</text>
<view class="right-box">
<text>已连续签到</text>
<text>05</text>
<text>{{ continuousDays }}</text>
<text></text>
</view>
</view>
<!-- 切换 -->
<view class="switch-box">
<text class="date">2025年12</text>
<text class="date">{{ currentYear }}{{ currentMonth }}</text>
<view class="btn">
<uni-icons type="left" size="22" color="#666666"></uni-icons>
<uni-icons type="right" size="22" color="#666666"></uni-icons>
<uni-icons
type="left"
size="22"
color="#666666"
@click="dateChange(0)"
></uni-icons>
<uni-icons
type="right"
size="22"
color="#666666"
@click="dateChange(1)"
></uni-icons>
</view>
</view>
<!-- 签到列表 -->
<view class="list-box">
<!-- 星期列表 -->
<view v-for="(item, index) in weekList" :key="index" class="item">
<text class="bottom-name">{{ item }}</text>
<text class="bottom-name">{{ item.name }}</text>
</view>
<!-- 签到 -->
<view
v-for="item in 30"
:key="item"
:class="{ active: indexData.includes(item) }"
v-for="(item, index) in dateList"
:key="index"
:class="{ active: indexData.includes(item.signDate) }"
class="item"
@click="onItem(item)"
>
@@ -72,9 +232,14 @@
mode="heightFix"
class="icon"
></image>
<text>+10</text>
<!-- <text>+10</text> -->
</view>
<text class="bottom-name">今天</text>
<text
:style="{ color: item.isToday ? '#00d993' : '#999999' }"
class="bottom-name"
>
{{ item.isToday ? '今日' : item.date }}
</text>
</view>
</view>
</view>