Files
simple-memo-wx/utils/constants.js
T

287 lines
11 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { getDomain } from './env'
// 头像基础路径(远端)
const AVATAR_BASE_URL = getDomain() + '/static/avatar/'
// 图片基础路径(远端)
const IMAGE_BASE_URL = getDomain() + '/static/images/'
// ========== 记账分类常量 start ==========
export const DEFAULT_CATE_LIST = [
// 支出类(type: 1
{ value: 'food', label: '餐饮', icon: '🍚', color: '#ff6b6b', type: 1 },
{ value: 'transport', label: '交通', icon: '🚇', color: '#4ecdc4', type: 1 },
{ value: 'shopping', label: '购物', icon: '🛍️', color: '#ffe66d', type: 1 },
{ value: 'entertainment', label: '娱乐', icon: '🎮', color: '#a855f7', type: 1 },
{ value: 'home', label: '居家', icon: '🏠', color: '#84b3d9', type: 1 },
{ value: 'medical', label: '医疗', icon: '🏥', color: '#ef4444', type: 1 },
{ value: 'education', label: '教育', icon: '📚', color: '#22c55e', type: 1 },
{ value: 'social', label: '社交', icon: '👥', color: '#f97316', type: 1 },
{ value: 'digital', label: '数码', icon: '📱', color: '#3b82f6', type: 1 },
{ value: 'clothing', label: '服饰', icon: '👔', color: '#ec4899', type: 1 },
{ value: 'beauty', label: '美容', icon: '💄', color: '#d946ef', type: 1 },
{ value: 'sports', label: '运动', icon: '⚽', color: '#10b981', type: 1 },
{ value: 'pet', label: '宠物', icon: '🐶', color: '#fbbf24', type: 1 },
{ value: 'baby', label: '育儿', icon: '🍼', color: '#fb7185', type: 1 },
{ value: 'travel', label: '旅游', icon: '✈️', color: '#06b6d4', type: 1 },
{ value: 'other_expense', label: '其他', icon: '📦', color: '#9ca3af', type: 1 },
// 收入类(type: 2
{ value: 'salary', label: '工资', icon: '💼', color: '#22c55e', type: 2 },
{ value: 'bonus', label: '奖金', icon: '🎁', color: '#fbbf24', type: 2 },
{ value: 'side_hustle', label: '副业', icon: '💻', color: '#3b82f6', type: 2 },
{ value: 'investment', label: '理财', icon: '📈', color: '#a855f7', type: 2 },
{ value: 'transfer', label: '转账', icon: '💳', color: '#84b3d9', type: 2 },
{ value: 'red_packet', label: '红包', icon: '🧧', color: '#ef4444', type: 2 },
{ value: 'other_income', label: '其他', icon: '🎯', color: '#6b7280', type: 2 }
]
// 例如:账单类型常量
export const BILL_TYPE = {
DEFAULT: 0, // 全部
EXPEND: 1, // 支出
INCOME: 2, // 收入
}
// ========== 我的页面菜单图标 ==========
export const MINE_MENU_ICONS = {
GROWTH: '/static/icon/growth.png',
BUDGET: '/static/icon/monthly_budget.png',
THEME: '/static/icon/theme.png',
ABOUT: '/static/icon/about.png',
EMAIL: '/static/icon/email.png',
WECHAT: '/static/icon/wechat.png'
}
//
// 分类颜色选项
export const COLOR_OPTIONS = [
'#84b3d9', '#a0d0e0', '#b8d8e6', '#d0e0e8', '#e8e8e8',
'#f0f0f0', '#f8f0f0', '#f0f8f0', '#f0f0f8', '#e0f0f8'
]
// 滑动按钮宽度(rpx
export const SLIDE_BTN_WIDTH = 240
// 筛选Tab 常量
export const BILL_FILTER_TYPE = {
ALL: 'all',
EXPEND: 'expend',
INCOME: 'income'
}
// 账单类型筛选选项(用于循环渲染)
export const BILL_TYPE_FILTER_OPTIONS = [
{ label: '全部', value: BILL_FILTER_TYPE.ALL },
{ label: '支出', value: BILL_FILTER_TYPE.EXPEND },
{ label: '收入', value: BILL_FILTER_TYPE.INCOME }
]
// 时间筛选标签
export const TIME_TAG = {
ALL: 'all',
TODAY: 'today',
WEEK: 'week',
MONTH: 'month',
LAST_MONTH: 'lastMonth',
THIS_YEAR: 'thisYear',
CUSTOM: 'custom'
}
// 账单时间筛选选项(用于循环渲染)
export const BILL_TIME_FILTER_OPTIONS = [
{ label: '今日', value: TIME_TAG.TODAY },
{ label: '本周', value: TIME_TAG.WEEK },
{ label: '本月', value: TIME_TAG.MONTH },
{ label: '上月', value: TIME_TAG.LAST_MONTH },
{ label: '本年', value: TIME_TAG.THIS_YEAR },
{ label: '自定义', value: TIME_TAG.CUSTOM }
]
// 4. 金额快捷按钮数值
export const QUICK_MONEY_AMOUNTS = [10, 20, 50, 100, 200, 500];
// 5. 备注快捷标签
export const QUICK_NOTE_TAGS = ['午餐', '打车', '地铁', '工资', '购物', '娱乐'];
// 6. 预算进度颜色阈值
export const BUDGET_PROGRESS_COLOR = {
OVER: 100, // 超支(红色)
WARNING: 80, // 警告(橙色)
NORMAL: 0 // 正常(蓝色)
}
// 7. 预算进度颜色值
export const PROGRESS_COLORS = {
OVER: '#F53F3F',
WARNING: '#FFAA33',
NORMAL: '#E8F3FF'
}
// 8. 最近选择分类最大数量
export const RECENT_CATE_MAX_COUNT = 3
// 9. 滑动阈值(触发显示按钮的最小滑动距离)
export const SLIDE_THRESHOLD = 50
// ========== 记账分类常量 end ==========
// ========== 待办(TODO)相关常量 start ==========
// 待办基础分类(对应你原有的 BASE_CATE)
export const TODO_BASE_CATE = Object.freeze([
{
value: 'work',
label: '工作',
color: '#84b3d9'
},
{
value: 'life',
label: '生活',
color: '#a0d0e0'
},
{
value: 'study',
label: '学习',
color: '#b8d8e6'
}
])
// 星期名称映射(从周一开始,对应你原有的 WEEK_DAYS)
export const WEEK_DAYS = Object.freeze(['一', '二', '三', '四', '五', '六', '日'])
// 结构化的筛选常量(替代硬编码)
export const TIME_FILTER_OPTIONS = [
{ label: '今日', value: 'today' },
{ label: '本周', value: 'week' },
{ label: '本月', value: 'month' },
{ label: '自定义', value: 'custom' }
]
export const STATUS_FILTER_OPTIONS = [
{ label: '全部', value: 'all' },
{ label: '待办', value: 'undone' },
{ label: '已完成', value: 'done' }
]
// 优先级常量(结构化)
export const TODO_PRIORITY_LIST = [
{ label: '高', value: 1, icon: '🔴' },
{ label: '中', value: 2, icon: '🟡' },
{ label: '低', value: 3, icon: '🟢' }
]
// ========== 待办(TODO)相关常量 end ==========
// ========== 收支渠道常量 ==========
export const PAY_CHANNELS = [
// 通用渠道(支持收入和支出)
{ value: 'wechat', label: '微信', types: [1, 2] }, // 1=支出, 2=收入
{ value: 'alipay', label: '支付宝', types: [1, 2] },
{ value: 'unionpay', label: '云闪付', types: [1, 2] }, // 新增
{ value: 'bank', label: '银行卡', types: [1, 2] },
{ value: 'cash', label: '现金', types: [1, 2] },
{ value: 'online_banking', label: '网银', types: [1, 2] }, // 新增
{ value: 'pos', label: 'POS机', types: [1, 2] }, // 新增
{ value: 'other', label: '其他', types: [1, 2] }, // 新增
// 仅收入渠道
{ value: 'salary', label: '工资', types: [2] },
{ value: 'red_packet', label: '红包', types: [2] },
{ value: 'transfer_in', label: '转账', types: [2] },
{ value: 'corporate', label: '对公转账', types: [2] }, // 新增
// 仅支出渠道
{ value: 'credit', label: '信用卡', types: [1] },
{ value: 'huawei', label: '花呗', types: [1] },
{ value: 'white', label: '白条', types: [1] },
{ value: 'jd_pay', label: '京东支付', types: [1] }, // 新增
{ value: 'meituan_pay', label: '美团支付', types: [1] }, // 新增
{ value: 'gift_card', label: '储值卡', types: [1] } // 新增
]
// 获取指定类型的渠道列表
export const getChannelsByType = (type) => {
return PAY_CHANNELS.filter(channel => channel.types.includes(type))
}
// 根据渠道值获取渠道名称
export const getChannelLabel = (value) => {
const channel = PAY_CHANNELS.find(c => c.value === value)
return channel ? channel.label : value
}
// 根据分类值获取分类名称
export const getCateLabel = (value) => {
const cate = DEFAULT_CATE_LIST.find(c => c.value === value)
return cate ? cate.label : value
}
// ========== 可扩展:其他全局常量 ==========
// 远端头像资源配置(根据当前环境动态获取域名)
export const DEFAULT_AVATARS = [
AVATAR_BASE_URL + 'ginger_cat.jpg', // 橘猫
AVATAR_BASE_URL + 'ragdoll.jpg', // 布偶猫
AVATAR_BASE_URL + 'hamster.jpg', // 小仓鼠
AVATAR_BASE_URL + 'dragon.jpg', // 龙
AVATAR_BASE_URL + 'pony.jpg', // 小马
AVATAR_BASE_URL + 'lamb.jpg', // 小羊
AVATAR_BASE_URL + 'corgi.jpg', // 柯基
AVATAR_BASE_URL + 'piglet.jpg', // 小猪
]
// 例如:请求状态码常量
export const HTTP_CODE = {
SUCCESS: 200,
TOKEN_EXPIRE: 401,
SERVER_ERROR: 500
}
// ========== 心情相关常量 ==========
export const MOOD_LIST = [
{ emoji: '😊', label: '开心', phrases: ['今天心情真好', '阳光灿烂的一天', '嘴角不自觉上扬', '满心欢喜'] },
{ emoji: '😌', label: '平静', phrases: ['岁月静好', '内心一片安宁', '享受这份宁静', '平和自在'] },
{ emoji: '😔', label: '低落', phrases: ['有点小忧伤', '心情沉沉的', '需要一点温暖', '静待花开'] },
{ emoji: '😤', label: '生气', phrases: ['有点烦躁呢', '深呼吸冷静一下', '需要冷静片刻', '平复一下心情'] },
{ emoji: '😴', label: '疲惫', phrases: ['有点累了', '好好休息一下', '给自己放个假', '累并快乐着'] },
{ emoji: '😰', label: '焦虑', phrases: ['有点担心', '相信一切会好', '慢慢来不着急', '放宽心'] },
{ emoji: '😄', label: '兴奋', phrases: ['超级开心!', '激动人心的时刻', '迫不及待了', '满心期待'] },
{ emoji: '🤔', label: '思考', phrases: ['正在思考中', '让我想想', '深思熟虑', '思绪万千'] },
{ emoji: '😢', label: '难过', phrases: ['有点难过', '需要一个拥抱', '一切都会过去', '明天会更好'] },
{ emoji: '😎', label: '酷', phrases: ['今天超酷的', '自信满满', '做自己就好', '洒脱自在'] },
{ emoji: '🥰', label: '幸福', phrases: ['被幸福包围', '甜蜜的感觉', '幸福感爆棚', '满心欢喜'] },
{ emoji: '😠', label: '愤怒', phrases: ['真的生气了', '需要冷静一下', '平复一下情绪', '深呼吸'] },
{ emoji: '🥳', label: '庆祝', phrases: ['值得庆祝!', '太棒了!', '举杯庆祝', '喜笑颜开'] },
{ emoji: '😱', label: '惊讶', phrases: ['哇!好惊喜', '太意外了', '不可思议', '令人震惊'] },
{ emoji: '😇', label: '感恩', phrases: ['心怀感恩', '感谢生活', '感恩遇见', '心存感激'] },
{ emoji: '💪', label: '加油', phrases: ['加油加油!', '相信自己', '勇往直前', '全力以赴'] },
{ emoji: '😘', label: '害羞', phrases: ['有点害羞', '不好意思啦', '脸红心跳', '羞涩一笑'] },
{ emoji: '🤩', label: '崇拜', phrases: ['超级崇拜!', '偶像光芒', '闪闪发光', '心生敬意'] },
{ emoji: '😪', label: '困倦', phrases: ['好困呀', '眼皮打架了', '需要小憩', '睡个好觉'] },
{ emoji: '😋', label: '满足', phrases: ['心满意足', '幸福感满满', '知足常乐', '十分满足'] }
]
// ========== Logo 与品牌信息常量 ==========
export const LOGO_CONFIG = {
path: IMAGE_BASE_URL + 'logo.png',
name: '简记memo',
subtitle: '让记录更简单',
slogan: '记录,是对抗遗忘的方式。\n生活的美好藏在点滴细节里,\n用简记memo,写下时光的足迹。',
version: 'v1.0.0',
copyright: ${new Date().getFullYear()} 简记memo. All rights reserved.`,
email: 'memo@miaoall.cn',
wechat: {
name: '孙三苗',
account: 'sunsanmiao'
},
brand: {
primaryColor: '#84b3d9',
secondaryColor: '#6a99c2',
gradient: 'linear-gradient(135deg, #84b3d9 0%, #6a99c2 100%)'
}
}