Browse Source

字数限制提醒

Xiao_123 8 hours ago
parent
commit
b74f503bfa
3 changed files with 27 additions and 15 deletions
  1. 26 12
      pages/drawLots/index.vue
  2. 1 0
      pages/drawLots/journal.vue
  3. 0 3
      store/user.js

+ 26 - 12
pages/drawLots/index.vue

@@ -12,7 +12,7 @@
 
 			<view class="journal" v-if="journalData && Object.keys(journalData).length > 0">
 				<view class="title">手账</view>
-				<uni-card @click.stop="handleAddJournal(journalData.id, journalData.description)">
+				<uni-card @tap="handleUpdateJournal(journalData.id, journalData.description)">
 					<view class="d-flex align-center">
 						<view class="line"></view>
 						<view class="date">{{ journalData.date }}</view>
@@ -21,7 +21,7 @@
 				</uni-card>
 			</view>
 
-			<view class="add-btn" @click.stop="handleAddJournal">
+			<view class="add-btn" @tap="handleAddJournal">
 				<uni-icons type="plusempty" size="30" color="#fff"></uni-icons>
 			</view>
 
@@ -33,7 +33,12 @@
 							<view class="yinli">{{ calendarInfo.yinli }}</view>
 							<view class="d-flex align-center justify-center">
 								<span style="color: #7f7f7f;">幸运色</span>
-								<view class="luckyColor ss-m-l-20" :style="{ 'background-color': `${currentColor || '#2979ff'}` }"></view>
+								<span v-if="calendarInfo.color === '白'" class="ss-m-l-20" style="color: #7f7f7f;">白色</span>
+								<view
+									v-else
+									class="luckyColor ss-m-l-20"
+									:style="{ 'background-color': `${colorDict[calendarInfo.color] || '#2979ff'}` }"
+								></view>
 							</view>
 						</view>
 						<view class="center-box ss-p-y-30 ss-p-x-30">
@@ -95,6 +100,14 @@ import { getDrawLots } from '@/api/drawLots.js'
 import layoutPage from '@/layout'
 import { showAuthModal, closeAuthModal } from '@/hooks/useModal'
 
+const colorDict = {
+	'白': '#FAFAFA',
+	'黑': '#212121',
+	'绿': '#43A047',
+	'红': '#F44336',
+	'黄': '#FDD835'
+}
+
 const journalData = ref({
 	id: 1,
 	date: '2025-08-27',
@@ -162,7 +175,7 @@ const journalData = ref({
 
 	onLoad(() => {
 		// showAuthModal()
-		closeAuthModal()
+		// closeAuthModal()
 
 		// 设置选中项
 		setTimeout(() => {
@@ -172,7 +185,6 @@ const journalData = ref({
 
 
 	const popupRef = ref()
-	const currentColor = ref(null)
 
 	const calendarInfo = ref({})
 	const handleChange = async (e) => {
@@ -181,11 +193,9 @@ const journalData = ref({
 		try {
 			const { result } = await getDrawLots({ date: e.fulldate })
 			if (!result) return uni.showToast({ title: '黄历信息获取失败', icon: 'none' })
-			console.log(result, '成功信息')
 			calendarInfo.value = result || {}
 
 			popupRef.value.open()
-			currentColor.value = result?.color || e.extraInfo?.color
 		} catch (error) {
 			console.log(error, '错误信息')
 		}
@@ -193,16 +203,20 @@ const journalData = ref({
 
 	const handleClose = () => {
 		popupRef.value.close()
-		currentColor.value = null
 		calendarInfo.value = {}
 	}
 
 	// 添加手账
-	const handleAddJournal = (id, text) => {
-		let url = `/pages/drawLots/journal`
-		if (id) url += `?id=${id}&text=${text}`
+	const handleAddJournal = () => {
+		uni.navigateTo({
+			url: '/pages/drawLots/journal'
+		})
+	}
+
+	// 更新手账
+	const handleUpdateJournal = (id, text) => {
 		uni.navigateTo({
-			url
+			url: `/pages/drawLots/journal?id=${id}&text=${text}`
 		})
 	}
 </script>

+ 1 - 0
pages/drawLots/journal.vue

@@ -1,6 +1,7 @@
 <template>
   <view class="ss-p-x-30 ss-p-y-30">
 		<uni-easyinput type="textarea" v-model="journal" clearable maxlength="500" autoHeight placeholder="请输入要记录的内容" />
+    <view style="text-align: end;" class="ss-m-t-10 color-999">{{ journal?.length || 0 }}/500</view>
 		<view class="f-horizon-center">
       <button
 				v-if="editId"

+ 0 - 3
store/user.js

@@ -16,13 +16,11 @@ export const userStore = defineStore('user', {
     const userInfo = userLocal ? JSON.parse(userLocal) : {}
     return {
       phone: null,
-      baseInfo: userInfo.baseInfo ?? {}, // 用户信息
       userInfo: userInfo.userInfo ?? {},
       isLogin: !!uni.getStorageSync('token'), // 登录状态
       refreshToken: uni.getStorageSync('refresh-token'), // 用户切换
       lastUpdateTime: 0, // 上次更新时间
       accountInfo: { ...defaultAccountInfo }, // 账号信息
-      userAccountInfo: userInfo.userAccountInfo ?? {}, // 账户信息
     }
   },
 
@@ -81,7 +79,6 @@ export const userStore = defineStore('user', {
       // 清空用户相关的缓存
       this.userInfo = {}
       this.phone = ''
-      this.userAccountInfo = {}
       this.accountInfo = { ...defaultAccountInfo };
     },