|
@@ -1,30 +1,41 @@
|
|
|
<template>
|
|
|
<layout-page>
|
|
|
<view style="position: relative;">
|
|
|
+ <!-- 日历 -->
|
|
|
<Calendar
|
|
|
+ :date="date"
|
|
|
class="uni-calendar--hook"
|
|
|
:selected="selected"
|
|
|
:lunar="true"
|
|
|
:range="false"
|
|
|
:showMonth="true"
|
|
|
@change="handleChange"
|
|
|
+ @monthSwitch="handleMonthSwitch"
|
|
|
/>
|
|
|
|
|
|
- <view class="journal" v-if="journalData && Object.keys(journalData).length > 0">
|
|
|
+ <button
|
|
|
+ size="default"
|
|
|
+ class="send-button"
|
|
|
+ @click="handleClear"
|
|
|
+ >
|
|
|
+ 清除缓存
|
|
|
+ </button>
|
|
|
+
|
|
|
+ <!-- 手账 -->
|
|
|
+ <view class="journal" v-if="calendarRecord && calendarRecord.length > 0">
|
|
|
<view class="title">手账</view>
|
|
|
- <uni-card @tap="handleUpdateJournal(journalData.id, journalData.description)">
|
|
|
- <view class="d-flex align-center">
|
|
|
- <view class="line"></view>
|
|
|
- <view class="date">{{ journalData.date }}</view>
|
|
|
- </view>
|
|
|
- <view class="description ss-m-t-15">{{ journalData.description }}</view>
|
|
|
+ <uni-card v-for="(val, index) in calendarRecord" :key="index" @tap="handleUpdateJournal(val)">
|
|
|
+ <uni-section :title="val.date" type="line"></uni-section>
|
|
|
+ <view class="description ss-m-t-15">{{ val.notes }}</view>
|
|
|
</uni-card>
|
|
|
</view>
|
|
|
|
|
|
+ <!-- 添加手账 -->
|
|
|
<view class="add-btn" @tap="handleAddJournal">
|
|
|
<uni-icons type="plusempty" size="30" color="#fff"></uni-icons>
|
|
|
</view>
|
|
|
|
|
|
+ <!-- 黄历弹窗 -->
|
|
|
<uni-popup ref="popupRef" type="dialog">
|
|
|
<view class="popupContent">
|
|
|
<view class="content-box">
|
|
@@ -57,7 +68,7 @@
|
|
|
<view class="label">五行</view>
|
|
|
<view class="value">{{ calendarInfo.wuxing }}</view>
|
|
|
</view>
|
|
|
- <view style="border-top: 1px solid #c2a08c; height: 1px; width: 100%;"></view>
|
|
|
+ <view class="border"></view>
|
|
|
<view class="padding">
|
|
|
<view class="label">吉神</view>
|
|
|
<view class="value">{{ calendarInfo.jishen }}</view>
|
|
@@ -74,7 +85,7 @@
|
|
|
<view class="label">冲煞</view>
|
|
|
<view class="value">{{ calendarInfo.chongsha }}</view>
|
|
|
</view>
|
|
|
- <view style="border-top: 1px solid #c2a08c; height: 1px; width: 100%;"></view>
|
|
|
+ <view class="border"></view>
|
|
|
<view class="padding">
|
|
|
<view class="label">凶神</view>
|
|
|
<view class="value">{{ calendarInfo.xiongshen }}</view>
|
|
@@ -93,26 +104,21 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { onLoad } from '@dcloudio/uni-app'
|
|
|
-import { ref } from 'vue'
|
|
|
-import Calendar from '@/components/uni-calendar/components/uni-calendar/uni-calendar.vue'
|
|
|
-import { getDrawLots } from '@/api/drawLots.js'
|
|
|
-import layoutPage from '@/layout'
|
|
|
-import { showAuthModal, closeAuthModal } from '@/hooks/useModal'
|
|
|
-
|
|
|
-const colorDict = {
|
|
|
- '白': '#FAFAFA',
|
|
|
- '黑': '#212121',
|
|
|
- '绿': '#43A047',
|
|
|
- '红': '#F44336',
|
|
|
- '黄': '#FDD835'
|
|
|
-}
|
|
|
+ import { onLoad, onShow } from '@dcloudio/uni-app'
|
|
|
+ import { ref } from 'vue'
|
|
|
+ import Calendar from '@/components/uni-calendar/components/uni-calendar/uni-calendar.vue'
|
|
|
+ import { getDrawLots } from '@/api/drawLots.js'
|
|
|
+ import layoutPage from '@/layout'
|
|
|
+ import { showAuthModal } from '@/hooks/useModal'
|
|
|
+ import { getCalendarRecord } from '@/api/drawLots.js'
|
|
|
|
|
|
-const journalData = ref({
|
|
|
- id: 1,
|
|
|
- date: '2025-08-27',
|
|
|
- description: '南京金陵酒店管理有限公司隶属于金陵饭店集团酒店业务板块,成立于2004年,已成为品牌化、连锁化、规模化发展的酒店管理专业机构。着力打造多层级品牌体系,构建涵盖高中端精品商务酒店、休闲度假酒店、主题文化酒店、智能公寓酒店等多样化产品线。公司秉承金陵饭店“细意浓情”服务理念,融合国际标准、传承中国文化、深耕本土特色,依托总部强大的支撑体系,为在管运营酒店赋能,为业主提供超值服务。“金陵”相继摘取中国质量奖——“全国质量工作先进单位标兵”,荣膺中国质量领域政府性荣誉——首届“中国质量奖”提名奖,十度蝉联世界品牌实验室评定的全球服务业奖项——“五星钻石奖”,位列中国饭店集团前30强,保持全国国有高星级酒店集团前三甲。国家旅游局在《饭店星评标准访查示范》中,将金陵饭店的管理模式和服务标准作为五星级酒店示范样板并拍摄成教学片,向全国酒店业推广。'
|
|
|
-})
|
|
|
+ const colorDict = {
|
|
|
+ '白': '#FAFAFA',
|
|
|
+ '黑': '#212121',
|
|
|
+ '绿': '#43A047',
|
|
|
+ '红': '#F44336',
|
|
|
+ '黄': '#FDD835'
|
|
|
+ }
|
|
|
|
|
|
function getDate(date, AddDayCount = 0) {
|
|
|
if (!date) {
|
|
@@ -122,9 +128,9 @@ const journalData = ref({
|
|
|
date = date.replace(/-/g, '/')
|
|
|
}
|
|
|
const dd = new Date(date)
|
|
|
-
|
|
|
+
|
|
|
dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
|
|
|
-
|
|
|
+
|
|
|
const y = dd.getFullYear()
|
|
|
const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
|
|
|
const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
|
|
@@ -136,58 +142,49 @@ const journalData = ref({
|
|
|
day: dd.getDay()
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ const date = ref(getDate(new Date()).fullDate)
|
|
|
+ // 设置日期选中内容
|
|
|
const selected = ref([])
|
|
|
- const setSelectedDates = () => {
|
|
|
- selected.value = [
|
|
|
- {
|
|
|
- date: getDate(new Date(),-20).fullDate,
|
|
|
- color: '#d3e3fd',
|
|
|
- url: 'https://menduner.citupro.com:3443/dev/2dbc20a5db2122e399b491638889ba9f8aea4e1c7a44463ee0df40b25f85b8cc.png'
|
|
|
- },
|
|
|
- {
|
|
|
- date: getDate(new Date(),-16).fullDate,
|
|
|
- color: '#f8bbd0',
|
|
|
- url: 'https://menduner.citupro.com:3443/dev/2dbc20a5db2122e399b491638889ba9f8aea4e1c7a44463ee0df40b25f85b8cc.png'
|
|
|
- },
|
|
|
- {
|
|
|
- date: getDate(new Date(),-12).fullDate,
|
|
|
- color: '#3bb19b',
|
|
|
- url: 'https://menduner.citupro.com:3443/dev/2dbc20a5db2122e399b491638889ba9f8aea4e1c7a44463ee0df40b25f85b8cc.png'
|
|
|
- },
|
|
|
- {
|
|
|
- date: getDate(new Date(),-7).fullDate,
|
|
|
- color: '#facd89',
|
|
|
- url: 'https://menduner.citupro.com:3443/dev/2dbc20a5db2122e399b491638889ba9f8aea4e1c7a44463ee0df40b25f85b8cc.png'
|
|
|
- },
|
|
|
- {
|
|
|
- date: getDate(new Date(),-3).fullDate,
|
|
|
- color: '#d7ccc8',
|
|
|
- url: 'https://menduner.citupro.com:3443/dev/2dbc20a5db2122e399b491638889ba9f8aea4e1c7a44463ee0df40b25f85b8cc.png'
|
|
|
- },
|
|
|
- {
|
|
|
- date: getDate(new Date(),-2).fullDate,
|
|
|
- color: '#c5cae9',
|
|
|
- url: 'https://menduner.citupro.com:3443/dev/2dbc20a5db2122e399b491638889ba9f8aea4e1c7a44463ee0df40b25f85b8cc.png'
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
|
|
|
+ // 登录信息
|
|
|
+ const userInfo = ref(uni.getStorageSync('wechat_user') || {})
|
|
|
onLoad(() => {
|
|
|
- // showAuthModal()
|
|
|
- // closeAuthModal()
|
|
|
+ if (!userInfo.value || !userInfo.value?.openid) return showAuthModal()
|
|
|
+ getCalendarData(date.value.slice(0, 7), 'onLoad')
|
|
|
+ })
|
|
|
|
|
|
- // 设置选中项
|
|
|
- setTimeout(() => {
|
|
|
- setSelectedDates()
|
|
|
- }, 2000)
|
|
|
+ onShow(() => {
|
|
|
+ // 刷新一次本地登录信息,防止 onLoad 时未拿到最新登录态
|
|
|
+ const latestUser = uni.getStorageSync('wechat_user')
|
|
|
+ if (latestUser?.openid && latestUser?.openid !== userInfo.value?.openid) {
|
|
|
+ userInfo.value = latestUser
|
|
|
+ }
|
|
|
+ if (userInfo.value?.openid) getCalendarData(date.value.slice(0, 7), 'onShow')
|
|
|
})
|
|
|
|
|
|
+ // 监听登录成功事件,立刻刷新数据
|
|
|
+ uni.$off && uni.$off('auth:login')
|
|
|
+ uni.$on && uni.$on('auth:login', (user) => {
|
|
|
+ userInfo.value = user || uni.getStorageSync('wechat_user')
|
|
|
+ if (userInfo.value?.openid) {
|
|
|
+ getCalendarData(date.value.slice(0, 7), 'event:auth:login')
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
+ const handleClear = () => {
|
|
|
+ selected.value = []
|
|
|
+ calendarRecord.value = []
|
|
|
+ userInfo.value = {}
|
|
|
+ uni.clearStorageSync()
|
|
|
+ showAuthModal()
|
|
|
+ }
|
|
|
+
|
|
|
+ // 点击日期查看黄历信息
|
|
|
const popupRef = ref()
|
|
|
-
|
|
|
const calendarInfo = ref({})
|
|
|
const handleChange = async (e) => {
|
|
|
+ date.value = e.fulldate
|
|
|
if (e.isBackToday) return // 点击左上角“今日”按钮不弹窗
|
|
|
|
|
|
try {
|
|
@@ -201,6 +198,25 @@ const journalData = ref({
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 获取手账记录
|
|
|
+ const calendarRecord = ref([])
|
|
|
+ const getCalendarData = async (month_key, type) => {
|
|
|
+ console.log(type, '获取手账记录类型')
|
|
|
+ try {
|
|
|
+ const { result } = await getCalendarRecord({ month_key, openid: userInfo.value.openid })
|
|
|
+ calendarRecord.value = result?.calendar_content || []
|
|
|
+ selected.value = calendarRecord.value?.length ? calendarRecord.value.map((item) => {
|
|
|
+ return { date: item.date, color: '#f8bbd0' }
|
|
|
+ }) : []
|
|
|
+ } catch {}
|
|
|
+ }
|
|
|
+
|
|
|
+ // 切换月份
|
|
|
+ const handleMonthSwitch = (e) => {
|
|
|
+ console.log(e, '切换月份')
|
|
|
+ getCalendarData(`${e.year}-${e.month < 10 ? '0' + e.month : e.month}`, 'monthSwitch')
|
|
|
+ }
|
|
|
+
|
|
|
const handleClose = () => {
|
|
|
popupRef.value.close()
|
|
|
calendarInfo.value = {}
|
|
@@ -208,15 +224,21 @@ const journalData = ref({
|
|
|
|
|
|
// 添加手账
|
|
|
const handleAddJournal = () => {
|
|
|
+ let url = `/pages/drawLots/journal?date=${date.value}`
|
|
|
+ const index = calendarRecord.value.findIndex((item) => item.date === date.value)
|
|
|
+ if (index > -1) {
|
|
|
+ uni.showToast({ title: '手账已存在,可进行编辑', icon: 'none' })
|
|
|
+ url += `¬es=${calendarRecord.value[index].notes}`
|
|
|
+ }
|
|
|
uni.navigateTo({
|
|
|
- url: '/pages/drawLots/journal'
|
|
|
+ url
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// 更新手账
|
|
|
- const handleUpdateJournal = (id, text) => {
|
|
|
+ const handleUpdateJournal = (val) => {
|
|
|
uni.navigateTo({
|
|
|
- url: `/pages/drawLots/journal?id=${id}&text=${text}`
|
|
|
+ url: `/pages/drawLots/journal?date=${val.date}¬es=${val.notes}`
|
|
|
})
|
|
|
}
|
|
|
</script>
|
|
@@ -234,25 +256,13 @@ $size: 25px;
|
|
|
margin-top: 30rpx;
|
|
|
padding-bottom: 100px;
|
|
|
.title {
|
|
|
- // color: #2979ff;
|
|
|
color: #999;
|
|
|
margin: 0 30px;
|
|
|
}
|
|
|
- .date {
|
|
|
- font-size: 17px;
|
|
|
- font-weight: bold;
|
|
|
- }
|
|
|
- .line {
|
|
|
- width: 5px;
|
|
|
- height: 15px;
|
|
|
- border-radius: 4px;
|
|
|
- background-color: #2979ff;
|
|
|
- margin-right: 10px;
|
|
|
- }
|
|
|
.description {
|
|
|
display: -webkit-box;
|
|
|
-webkit-box-orient: vertical;
|
|
|
- -webkit-line-clamp: 6;
|
|
|
+ -webkit-line-clamp: 2;
|
|
|
overflow: hidden;
|
|
|
}
|
|
|
}
|
|
@@ -331,6 +341,11 @@ $size: 25px;
|
|
|
.padding {
|
|
|
padding: 10px;
|
|
|
}
|
|
|
+ .border {
|
|
|
+ border-top: 1px solid #c2a08c;
|
|
|
+ height: 1px;
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
.luckyColor {
|