第一次上传
This commit is contained in:
@@ -0,0 +1 @@
|
||||
"use strict";const e=require("../../common/vendor.js"),t=require("../../utils/store.js"),a=require("../../utils/date.js"),u=require("../../utils/money.js");Math||(o+n+r)();const o=()=>"../../components/SectionCard.js",n=()=>"../../components/AppTabBar.js",r=()=>"../../components/BillEditorPopup.js",l={__name:"index",setup(o){const n=t.useAppStore(),r=e.ref(!1),l=e.ref(null),c=e.ref(""),i=e.ref("expense"),s=e.computed((()=>a.toDateKey())),d=e.computed((()=>a.toMonthKey())),m=e.computed((()=>"dark"===n.state.settings.theme?"theme-dark":"")),v=e.computed((()=>a.formatDateLabel(s.value))),p=e.computed((()=>[...n.state.bills].sort(((e,t)=>t.createdAt-e.createdAt)))),f=e.computed((()=>p.value.slice(0,5))),x=e.computed((()=>p.value.filter((e=>e.date===s.value)))),h=e.computed((()=>p.value.filter((e=>a.isSameMonth(e.date,d.value))))),y=e.computed((()=>x.value.filter((e=>"expense"===e.type)).reduce(((e,t)=>e+Number(t.amount)),0))),b=e.computed((()=>h.value.filter((e=>"expense"===e.type)).reduce(((e,t)=>e+Number(t.amount)),0))),g=e.computed((()=>h.value.filter((e=>"income"===e.type)).reduce(((e,t)=>e+Number(t.amount)),0))),C=e.computed((()=>g.value-b.value)),w=e.computed((()=>Number(n.state.budgets.total)||0)),M=e.computed((()=>w.value-b.value)),j=e.computed((()=>Math.max(M.value,0)/Math.max(1,a.getDaysLeftInMonth(d.value)))),A=e.computed((()=>u.clampPercent(b.value/Math.max(w.value||1,1)))),I=e.computed((()=>w.value?u.formatPercent(b.value/Math.max(w.value,1)):"未设置")),_=e.computed((()=>w.value?M.value<0?`已超支 ${u.formatCurrency(Math.abs(M.value))}`:`日均可用 ${u.formatCurrency(j.value)}`:"设置预算后可查看日均可用额度")),D=e.computed((()=>n.state.categories.expense.slice(0,6)));function L(e){return(n.state.categories[e.type]||[]).find((t=>t.id===e.categoryId))||{}}function P(e){return n.state.accounts.find((t=>t.id===e.accountId))||{}}function S(e="",t="expense"){c.value=e,i.value=t,l.value=null,r.value=!0}function T(){r.value=!1,l.value=null,c.value="",i.value="expense"}function $(t){n.saveBill(t),e.index.showToast({title:t.id?"账单已更新":"账单已保存",icon:"none"})}function q(t){e.index.showActionSheet({itemList:["编辑账单","删除账单"],success:({tapIndex:a})=>{0===a&&(l.value={...t},r.value=!0),1===a&&function(t){e.index.showModal({title:"删除账单",content:`确认删除 ${L(t).name||"这笔账单"} 吗?`,success:({confirm:e})=>{e&&n.deleteBill(t.id)}})}(t)}})}function B(){e.index.redirectTo({url:"/pages/bills/index"})}function k(){e.index.redirectTo({url:"/pages/budget/index"})}e.onPullDownRefresh((()=>{setTimeout((()=>{e.index.stopPullDownRefresh()}),200)}));const N=e.ref(!1);function E(){if(N.value)return;N.value=!0;let t=null;e.wx$1.createInterstitialAd&&(t=e.wx$1.createInterstitialAd({adUnitId:"adunit-0abc32053b19a4e9"}),t.onLoad((()=>{})),t.onError((e=>{console.error("插屏广告加载失败",e)})),t.onClose((()=>{}))),setTimeout((()=>{t&&(t.show().catch((e=>{console.error("插屏广告显示失败",e)})),N.value=!1)}),5480)}return e.onLoad((()=>{E()})),e.onShow((()=>{E()})),e.onShareAppMessage((e=>({title:"账单助手",desc:"本地单机极简记账,支持收支记录、预算管控、消费报表,数据安全私密,轻便好用的个人账单管家。",path:"/pages/home/index"}))),(t,o)=>e.e({a:e.t(v.value),b:e.t(e.unref(u.formatCurrency)(y.value)),c:e.t(e.unref(u.formatCurrency)(b.value)),d:e.t(e.unref(u.formatCurrency)(g.value)),e:e.t(e.unref(u.formatCurrency)(C.value)),f:e.t(e.unref(u.formatCurrency)(M.value)),g:e.t(I.value),h:A.value,i:e.t(w.value?`总预算 ${e.unref(u.formatCurrency)(w.value)}`:"当前尚未设置月预算"),j:e.t(_.value),k:!w.value},w.value?{}:{l:e.o(k)},{m:e.p({title:"预算概览",subtitle:"实时查看预算执行情况与剩余额度"}),n:e.o((e=>S("","expense"))),o:e.o((e=>S("","income"))),p:e.f(D.value,((t,a,u)=>({a:t.color,b:e.t(t.name),c:t.id,d:e.o((e=>S(t.id,"expense")),t.id)}))),q:e.p({title:"快捷记账",subtitle:"常用场景一步录入,提高日常记录效率"}),r:e.o(B),s:f.value.length},f.value.length?{t:e.f(f.value,((t,o,n)=>({a:L(t).color||"#7b8794",b:e.t(L(t).name||"未分类"),c:e.t(P(t).name||"账户"),d:e.t(e.unref(a.formatDateLabel)(t.date)),e:e.t("income"===t.type?"+":"-"),f:e.t(e.unref(u.formatCurrency)(t.amount).replace("¥","")),g:e.n("income"===t.type?"positive":"negative"),h:e.t(t.note||"无备注"),i:t.id,j:e.o((e=>q(t)),t.id)})))}:{v:e.o((e=>S("","expense")))},{w:e.p({title:"最近记录",subtitle:"保留最近 5 笔账单,长按可编辑或删除"}),x:e.o((e=>S("","expense"))),y:e.p({current:"home"}),z:e.o(T),A:e.o($),B:e.p({visible:r.value,entry:l.value,categories:e.unref(n).state.categories,accounts:e.unref(n).state.accounts,"default-type":i.value,"initial-category-id":c.value}),C:e.n(m.value)})}},c=e._export_sfc(l,[["__scopeId","data-v-a0f5ea5d"]]);l.__runtimeHooks=2,wx.createPage(c);
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"navigationBarTitleText": "首页",
|
||||
"enablePullDownRefresh": true,
|
||||
"usingComponents": {
|
||||
"section-card": "../../components/SectionCard",
|
||||
"app-tab-bar": "../../components/AppTabBar",
|
||||
"bill-editor-popup": "../../components/BillEditorPopup"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<view class="{{['app-page', 'data-v-a0f5ea5d', C]}}"><view class="surface-card hero-card data-v-a0f5ea5d"><text class="hero-date data-v-a0f5ea5d">{{a}}</text><text class="hero-title data-v-a0f5ea5d">账单小管家</text><view class="hero-metrics data-v-a0f5ea5d"><view class="metric-block data-v-a0f5ea5d"><text class="tiny-text data-v-a0f5ea5d">今日支出</text><text class="metric-value negative data-v-a0f5ea5d">{{b}}</text></view><view class="metric-block data-v-a0f5ea5d"><text class="tiny-text data-v-a0f5ea5d">本月支出</text><text class="metric-value negative data-v-a0f5ea5d">{{c}}</text></view><view class="metric-block data-v-a0f5ea5d"><text class="tiny-text data-v-a0f5ea5d">本月收入</text><text class="metric-value positive data-v-a0f5ea5d">{{d}}</text></view><view class="metric-block data-v-a0f5ea5d"><text class="tiny-text data-v-a0f5ea5d">本月结余</text><text class="metric-value data-v-a0f5ea5d">{{e}}</text></view></view></view><ad-custom class="data-v-a0f5ea5d" unit-id="adunit-74730c6c27c95a37"></ad-custom><section-card wx:if="{{m}}" class="data-v-a0f5ea5d" u-s="{{['d']}}" u-i="a0f5ea5d-0" bind:__l="__l" u-p="{{m}}"><view class="budget-head data-v-a0f5ea5d"><view class="data-v-a0f5ea5d"><text class="budget-value data-v-a0f5ea5d">{{f}}</text><text class="data-v-a0f5ea5d" style="margin-left:16rpx"></text><text class="tiny-text data-v-a0f5ea5d">剩余预算</text></view><view class="budget-side data-v-a0f5ea5d"><text class="tiny-text data-v-a0f5ea5d">预算使用</text><text class="data-v-a0f5ea5d" style="margin-left:16rpx"></text><text class="budget-percent data-v-a0f5ea5d">{{g}}</text></view></view><view class="progress-track data-v-a0f5ea5d"><view class="progress-fill data-v-a0f5ea5d" style="{{'width:' + h}}"></view></view><view class="budget-note-row data-v-a0f5ea5d"><text class="tiny-text data-v-a0f5ea5d">{{i}}</text><text class="tiny-text data-v-a0f5ea5d">{{j}}</text></view><view wx:if="{{k}}" class="budget-action-row data-v-a0f5ea5d"><view class="ghost-button data-v-a0f5ea5d" bindtap="{{l}}">去设置预算</view></view></section-card><section-card wx:if="{{q}}" class="data-v-a0f5ea5d" u-s="{{['d']}}" u-i="a0f5ea5d-1" bind:__l="__l" u-p="{{q}}"><view class="quick-action-row data-v-a0f5ea5d"><view class="primary-button quick-main data-v-a0f5ea5d" bindtap="{{n}}">记录支出</view><view class="ghost-button quick-main data-v-a0f5ea5d" bindtap="{{o}}">记录收入</view></view><view class="quick-grid data-v-a0f5ea5d"><view wx:for="{{p}}" wx:for-item="item" wx:key="c" class="quick-chip data-v-a0f5ea5d" bindtap="{{item.d}}"><view class="quick-dot data-v-a0f5ea5d" style="{{'background:' + item.a}}"></view><text class="data-v-a0f5ea5d">{{item.b}}</text></view></view></section-card><section-card wx:if="{{w}}" class="data-v-a0f5ea5d" u-s="{{['action','d']}}" u-i="a0f5ea5d-2" bind:__l="__l" u-p="{{w}}"><text class="section-link data-v-a0f5ea5d" bindtap="{{r}}" slot="action">查看全部</text><view wx:if="{{s}}" class="bill-list data-v-a0f5ea5d"><view wx:for="{{t}}" wx:for-item="bill" wx:key="i" class="bill-item data-v-a0f5ea5d" bindlongpress="{{bill.j}}"><view class="bill-leading data-v-a0f5ea5d"><view class="bill-dot data-v-a0f5ea5d" style="{{'background:' + bill.a}}"></view><view class="data-v-a0f5ea5d"><text class="bill-title data-v-a0f5ea5d">{{bill.b}}</text><text class="bill-meta data-v-a0f5ea5d">{{bill.c}} · {{bill.d}}</text></view></view><view class="bill-right data-v-a0f5ea5d"><text class="{{['bill-amount', 'data-v-a0f5ea5d', bill.g]}}">{{bill.e}}{{bill.f}}</text><text class="tiny-text data-v-a0f5ea5d">{{bill.h}}</text></view></view></view><view wx:else class="empty-card data-v-a0f5ea5d"><text class="section-subtitle data-v-a0f5ea5d">还没有账单记录,先记下第一笔收支。</text><view class="ghost-button empty-action data-v-a0f5ea5d" bindtap="{{v}}">立即记账</view></view></section-card><view class="fab-button data-v-a0f5ea5d" bindtap="{{x}}">+ 记一笔</view><app-tab-bar wx:if="{{y}}" class="data-v-a0f5ea5d" u-i="a0f5ea5d-3" bind:__l="__l" u-p="{{y}}"/><bill-editor-popup wx:if="{{B}}" class="data-v-a0f5ea5d" bindclose="{{z}}" bindsave="{{A}}" u-i="a0f5ea5d-4" bind:__l="__l" u-p="{{B}}"/></view>
|
||||
@@ -0,0 +1 @@
|
||||
.hero-card.data-v-a0f5ea5d{display:flex;flex-direction:column;gap:18rpx;padding:32rpx;background:var(--bg-accent);color:#fff}.hero-date.data-v-a0f5ea5d,.hero-subtitle.data-v-a0f5ea5d,.hero-card .tiny-text.data-v-a0f5ea5d{color:rgba(255,255,255,.76)}.hero-title.data-v-a0f5ea5d{font-size:46rpx;font-weight:700}.hero-subtitle.data-v-a0f5ea5d{font-size:24rpx;line-height:1.7}.hero-metrics.data-v-a0f5ea5d{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18rpx;margin-top:10rpx}.metric-block.data-v-a0f5ea5d{padding:20rpx;border-radius:24rpx;background:rgba(255,255,255,.12)}.metric-value.data-v-a0f5ea5d{display:block;margin-top:10rpx;font-size:32rpx;font-weight:700;color:#fff}.budget-head.data-v-a0f5ea5d,.budget-note-row.data-v-a0f5ea5d,.quick-action-row.data-v-a0f5ea5d{display:flex;align-items:center;justify-content:space-between;gap:18rpx}.budget-side.data-v-a0f5ea5d{text-align:right}.budget-value.data-v-a0f5ea5d,.budget-percent.data-v-a0f5ea5d{font-size:36rpx;font-weight:700;color:var(--text-primary)}.progress-track.data-v-a0f5ea5d{overflow:hidden;height:18rpx;margin:24rpx 0 16rpx;border-radius:999rpx;background:var(--surface-muted)}.progress-fill.data-v-a0f5ea5d{height:100%;border-radius:inherit;background:linear-gradient(90deg,#d36c43,#1f6f5f)}.budget-action-row.data-v-a0f5ea5d{margin-top:18rpx}.quick-action-row .quick-main.data-v-a0f5ea5d{flex:1}.quick-grid.data-v-a0f5ea5d{display:flex;flex-wrap:wrap;gap:16rpx;margin-top:18rpx}.quick-chip.data-v-a0f5ea5d{display:flex;align-items:center;gap:12rpx;padding:16rpx 18rpx;border-radius:22rpx;background:var(--surface-muted);font-size:24rpx;color:var(--text-secondary)}.quick-dot.data-v-a0f5ea5d,.bill-dot.data-v-a0f5ea5d{width:16rpx;height:16rpx;border-radius:50%}.section-link.data-v-a0f5ea5d{font-size:24rpx;color:var(--brand)}.bill-list.data-v-a0f5ea5d{display:flex;flex-direction:column;gap:18rpx}.bill-item.data-v-a0f5ea5d{display:flex;align-items:center;justify-content:space-between;gap:16rpx;padding:22rpx;border-radius:24rpx;background:var(--surface-muted)}.bill-leading.data-v-a0f5ea5d{display:flex;align-items:center;gap:16rpx;flex:1}.bill-right.data-v-a0f5ea5d{display:flex;flex-direction:column;align-items:flex-end;gap:8rpx}.bill-title.data-v-a0f5ea5d,.bill-amount.data-v-a0f5ea5d{font-size:28rpx;font-weight:600;color:var(--text-primary)}.bill-meta.data-v-a0f5ea5d{margin-top:8rpx;font-size:22rpx;color:var(--text-secondary)}.empty-card.data-v-a0f5ea5d{padding:28rpx 0 8rpx;text-align:center}.empty-action.data-v-a0f5ea5d{margin-top:18rpx}.fab-button.data-v-a0f5ea5d{position:fixed;right:32rpx;bottom:348rpx;padding:24rpx 30rpx;border-radius:999rpx;background:var(--bg-accent);color:#fff;font-size:28rpx;font-weight:700;box-shadow:0 20rpx 42rpx rgba(16,42,67,.24);z-index:18}
|
||||
Reference in New Issue
Block a user