返回列表 发布新帖

纯离线html:积分小管家:用积分带娃

3170 1
小K网牛逼 发表于 2026-6-17 00:00:11 | 查看全部 阅读模式 <

马上注册,结交更多好友,享用更多功能,让你轻松玩转小K网。

您需要 登录 才可以下载或查看,没有账号?立即注册 微信登录

×
现在学校、小饭桌,都采取积分奖励式带娃,之前dy也看到有大神做了app,不过是私用的。
前两天在公众号看到一个网页版的积分小管家,便用这个模板,用AI优化了一下,纯离线运行,历史数据可以保存,可以清控,设置可以重置、自定义,非常轻便,发到手机上,点开就能用,不到100kb。

纯离线html:积分小管家:用积分带娃

纯离线html:积分小管家:用积分带娃

纯离线html:积分小管家:用积分带娃

纯离线html:积分小管家:用积分带娃

纯离线html:积分小管家:用积分带娃

纯离线html:积分小管家:用积分带娃

纯离线html:积分小管家:用积分带娃

纯离线html:积分小管家:用积分带娃

txt改成html就行,要是有大神能封装成一个app就好了,不过估计app安装包可能就不止100km了
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head><meta name="robots" content="noindex,nofollow"><meta name="generator" content="ShipPage"><link rel="canonical" href="https://shippage.ai/p/jifen">
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  6.     <title>积分小管家</title>
  7.     <style>
  8.         * {
  9.             margin: 0;
  10.             padding: 0;
  11.             box-sizing: border-box;
  12.         }
  13.         
  14.         body {
  15.             font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  16.             background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
  17.             min-height: 100vh;
  18.             color: #333;
  19.             padding-bottom: 80px;
  20.         }
  21.         
  22.         /* 顶部导航 */
  23.         .header {
  24.             background: rgba(255, 255, 255, 0.95);
  25.             padding: 15px 20px;
  26.             position: sticky;
  27.             top: 0;
  28.             z-index: 100;
  29.             box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  30.         }
  31.         
  32.         /* 周积分网格样式 */
  33.         .day-item {
  34.             cursor: pointer;
  35.             transition: all 0.2s ease;
  36.             background: #f8f9fa;
  37.             border-radius: 10px;
  38.             padding: 10px 5px;
  39.             text-align: center;
  40.         }
  41.         
  42.         .day-item:hover {
  43.             transform: translateY(-2px);
  44.         }
  45.         
  46.         .day-item:active {
  47.             transform: scale(0.95);
  48.         }
  49.         
  50.         .day-item.selected {
  51.             background: rgba(34, 197, 94, 0.1);
  52.         }
  53.         
  54.         .day-points.today-points {
  55.             font-weight: 800;
  56.             font-size: 18px;
  57.         }
  58.         
  59.         .day-points.selected-points {
  60.             font-weight: 600;
  61.             font-size: 16px;
  62.             opacity: 0.8;
  63.         }
  64.         
  65.         .header h1 {
  66.             font-size: 20px;
  67.             font-weight: 700;
  68.             color: #22c55e;
  69.             text-align: center;
  70.         }
  71.         
  72.         /* 积分卡片 */
  73.         .points-card {
  74.             background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  75.             margin: 20px;
  76.             padding: 24px 20px;
  77.             border-radius: 20px;
  78.             color: white;
  79.             box-shadow: 0 8px 20px rgba(34, 197, 94, 0.4);
  80.             text-align: center;
  81.         }
  82.         
  83.         .points-header {
  84.             display: flex;
  85.             align-items: baseline;
  86.             justify-content: center;
  87.             gap: 12px;
  88.             margin-bottom: 8px;
  89.         }
  90.         
  91.         .points-title {
  92.             font-size: 16px;
  93.             font-weight: 600;
  94.             opacity: 0.85;
  95.             letter-spacing: 2px;
  96.         }
  97.         
  98.         .points-amount {
  99.             font-size: 56px;
  100.             font-weight: 900;
  101.             text-shadow: 0 2px 8px rgba(0,0,0,0.2);
  102.             letter-spacing: 2px;
  103.         }
  104.         
  105.         .points-today {
  106.             display: flex;
  107.             align-items: center;
  108.             justify-content: center;
  109.             gap: 10px;
  110.             font-size: 14px;
  111.             background: rgba(255,255,255,0.15);
  112.             border-radius: 12px;
  113.             padding: 8px 16px;
  114.             margin: 0 auto;
  115.             width: fit-content;
  116.         }
  117.         
  118.         .today-divider {
  119.             width: 1px;
  120.             height: 18px;
  121.             background: rgba(255, 255, 255, 0.5);
  122.         }
  123.         
  124.         .today-value {
  125.             font-weight: 800;
  126.             font-size: 15px;
  127.         }
  128.         
  129.         .points-actions {
  130.             display: flex;
  131.             gap: 8px;
  132.             margin-top: 12px;
  133.         }
  134.         
  135.         .points-btn {
  136.             flex: 1;
  137.             padding: 10px;
  138.             border: none;
  139.             border-radius: 12px;
  140.             font-size: 14px;
  141.             font-weight: 600;
  142.             cursor: pointer;
  143.             transition: all 0.3s;
  144.         }
  145.         
  146.         .points-btn.primary {
  147.             background: white;
  148.             color: #22c55e;
  149.         }
  150.         
  151.         .points-btn.danger {
  152.             background: rgba(239, 68, 68, 0.9);
  153.             color: white;
  154.         }
  155.         
  156.         .points-btn:active {
  157.             transform: scale(0.95);
  158.         }
  159.         
  160.         /* 功能入口 */
  161.         .features {
  162.             display: grid;
  163.             grid-template-columns: repeat(3, 1fr);
  164.             gap: 10px;
  165.             padding: 0 20px;
  166.             margin-bottom: 15px;
  167.         }
  168.         
  169.         .feature-item {
  170.             background: rgba(255, 255, 255, 0.95);
  171.             border-radius: 14px;
  172.             padding: 12px 8px;
  173.             text-align: center;
  174.             cursor: pointer;
  175.             box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  176.             transition: all 0.3s;
  177.         }
  178.         
  179.         .feature-item:active {
  180.             transform: scale(0.95);
  181.         }
  182.         
  183.         .feature-icon {
  184.             font-size: 24px;
  185.             margin-bottom: 6px;
  186.         }
  187.         
  188.         .feature-name {
  189.             font-size: 11px;
  190.             color: #333;
  191.             font-weight: 600;
  192.         }
  193.         
  194.         /* 内容区域 */
  195.         .content-section {
  196.             background: white;
  197.             margin: 0 20px 15px;
  198.             border-radius: 16px;
  199.             padding: 15px;
  200.             box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  201.         }
  202.         
  203.         .section-title {
  204.             display: flex;
  205.             flex-direction: row;
  206.             align-items: center;
  207.             justify-content: space-between;
  208.             gap: 8px;
  209.             margin-bottom: 15px;
  210.         }
  211.         
  212.         .section-title > span {
  213.             font-size: 18px;
  214.             font-weight: 700;
  215.             color: #333;
  216.         }
  217.         
  218.         .section-actions {
  219.             display: flex;
  220.             gap: 8px;
  221.         }
  222.         
  223.         .action-btn {
  224.             padding: 6px 12px;
  225.             border: none;
  226.             border-radius: 8px;
  227.             font-size: 12px;
  228.             font-weight: 600;
  229.             cursor: pointer;
  230.             transition: all 0.3s;
  231.         }
  232.         
  233.         /* 手机端兼容性优化 */
  234.         @media (max-width: 480px) {
  235.             .action-btn {
  236.                 font-size: 11px;
  237.                 padding: 5px 10px;
  238.             }
  239.             
  240.             .list-item {
  241.                 flex-wrap: wrap;
  242.                 gap: 10px;
  243.             }
  244.             
  245.             .list-item .section-actions {
  246.                 width: 100%;
  247.                 justify-content: flex-end;
  248.                 margin-top: 5px;
  249.             }
  250.         }
  251.         
  252.         .action-btn.add {
  253.             background: #22c55e;
  254.             color: white;
  255.         }
  256.         
  257.         .action-btn.edit {
  258.             background: #f59e0b;
  259.             color: white;
  260.         }
  261.         
  262.         .action-btn.delete {
  263.             background: #ef4444;
  264.             color: white;
  265.         }
  266.         
  267.         /* 列表项 */
  268.         .list-item {
  269.             display: flex;
  270.             justify-content: space-between;
  271.             align-items: center;
  272.             padding: 15px;
  273.             background: #f8f9fa;
  274.             border-radius: 12px;
  275.             margin-bottom: 10px;
  276.         }
  277.         
  278.         .list-item:last-child {
  279.             margin-bottom: 0;
  280.         }
  281.         
  282.         .item-info {
  283.             flex: 1;
  284.         }
  285.         
  286.         .item-name {
  287.             font-size: 14px;
  288.             font-weight: 600;
  289.             margin-bottom: 4px;
  290.         }
  291.         
  292.         .item-points {
  293.             font-size: 16px;
  294.             font-weight: 700;
  295.         }
  296.         
  297.         .item-points.income {
  298.             color: #10b981;
  299.         }
  300.         
  301.         .item-points.expense {
  302.             color: #ef4444;
  303.         }
  304.         
  305.         .item-actions {
  306.             display: flex;
  307.             gap: 8px;
  308.         }
  309.         
  310.         .item-btn {
  311.             padding: 6px 12px;
  312.             border: none;
  313.             border-radius: 8px;
  314.             font-size: 12px;
  315.             font-weight: 600;
  316.             cursor: pointer;
  317.         }
  318.         
  319.         .item-btn.earn {
  320.             background: #10b981;
  321.             color: white;
  322.         }
  323.         
  324.         .item-btn.deduct {
  325.             background: #ef4444;
  326.             color: white;
  327.         }
  328.         
  329.         .item-btn.exchange {
  330.             background: #667eea;
  331.             color: white;
  332.         }
  333.         
  334.         /* 快速添加行 */
  335.         .quick-add {
  336.             display: flex;
  337.             align-items: center;
  338.             gap: 8px;
  339.             padding: 10px;
  340.             background: #f0fdf4;
  341.             border: 1px dashed #22c55e;
  342.             border-radius: 12px;
  343.             margin-bottom: 12px;
  344.         }
  345.         
  346.         .quick-add input {
  347.             border: 1px solid #e5e7eb;
  348.             border-radius: 8px;
  349.             padding: 8px 10px;
  350.             font-size: 13px;
  351.             outline: none;
  352.         }
  353.         
  354.         .quick-add input:focus {
  355.             border-color: #22c55e;
  356.         }
  357.         
  358.         .quick-add .qa-name {
  359.             flex: 1;
  360.             max-width: 50%;
  361.         }
  362.         
  363.         .quick-add .qa-points {
  364.             width: 80px;
  365.             text-align: center;
  366.         }
  367.         
  368.         .quick-add .qa-btn {
  369.             padding: 8px 16px;
  370.             background: #22c55e;
  371.             color: white;
  372.             border: none;
  373.             border-radius: 8px;
  374.             font-size: 13px;
  375.             font-weight: 600;
  376.             cursor: pointer;
  377.             white-space: nowrap;
  378.             margin-left: auto;
  379.         }
  380.         
  381.         .quick-add .qa-btn:active {
  382.             background: #16a34a;
  383.         }
  384.         
  385.         .quick-add.deduct {
  386.             background: #fef2f2;
  387.             border-color: #fca5a5;
  388.         }
  389.         
  390.         .quick-add.deduct input:focus {
  391.             border-color: #ef4444;
  392.         }
  393.         
  394.         .quick-add.deduct .qa-btn {
  395.             background: #ef4444;
  396.         }
  397.         
  398.         .quick-add.deduct .qa-btn:active {
  399.             background: #dc2626;
  400.         }
  401.         
  402.         .quick-add.exchange {
  403.             background: #f5f3ff;
  404.             border-color: #c4b5fd;
  405.         }
  406.         
  407.         .quick-add.exchange input:focus {
  408.             border-color: #667eea;
  409.         }
  410.         
  411.         .quick-add.exchange .qa-btn {
  412.             background: #667eea;
  413.         }
  414.         
  415.         .quick-add.exchange .qa-btn:active {
  416.             background: #4f46e5;
  417.         }
  418.         
  419.         /* 周积分统计 */
  420.         .week-stats {
  421.             margin-bottom: 20px;
  422.         }
  423.         
  424.         .week-grid {
  425.             display: grid;
  426.             grid-template-columns: repeat(7, 1fr);
  427.             gap: 8px;
  428.         }
  429.         
  430.         .day-item.today {
  431.             background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  432.             color: white;
  433.         }
  434.         
  435.         .day-name {
  436.             font-size: 10px;
  437.             margin-bottom: 4px;
  438.             color: #666;
  439.         }
  440.         
  441.         .day-item.today .day-name {
  442.             color: rgba(255, 255, 255, 0.9);
  443.         }
  444.         
  445.         .day-points {
  446.             font-size: 14px;
  447.             font-weight: 700;
  448.         }
  449.         
  450.         .day-item.today .day-points {
  451.             color: white;
  452.         }
  453.         
  454.         /* 历史积分月日历 */
  455.         .month-calendar {
  456.             background: #f8f9fa;
  457.             border-radius: 12px;
  458.             padding: 12px;
  459.             margin-bottom: 12px;
  460.         }
  461.         
  462.         .month-header {
  463.             display: flex;
  464.             align-items: center;
  465.             margin-bottom: 10px;
  466.         }
  467.         
  468.         .month-title {
  469.             font-size: 14px;
  470.             font-weight: 700;
  471.         }
  472.         
  473.         .month-weekdays {
  474.             display: grid;
  475.             grid-template-columns: repeat(7, 1fr);
  476.             gap: 4px;
  477.             margin-bottom: 4px;
  478.         }
  479.         
  480.         .month-weekday {
  481.             text-align: center;
  482.             font-size: 10px;
  483.             color: #999;
  484.             padding: 2px 0;
  485.         }
  486.         
  487.         .month-days {
  488.             display: grid;
  489.             grid-template-columns: repeat(7, 1fr);
  490.             gap: 4px;
  491.         }
  492.         
  493.         .month-day {
  494.             text-align: center;
  495.             padding: 6px 2px;
  496.             background: white;
  497.             border-radius: 6px;
  498.             min-height: 38px;
  499.             display: flex;
  500.             flex-direction: column;
  501.             justify-content: center;
  502.             align-items: center;
  503.         }
  504.         
  505.         .month-day.empty {
  506.             background: transparent;
  507.         }
  508.         
  509.         .month-day.today {
  510.             background: rgba(34, 197, 94, 0.15);
  511.         }
  512.         
  513.         .month-day.today .month-day-num {
  514.             font-weight: 700;
  515.             color: #22c55e;
  516.         }
  517.         
  518.         .month-day-num {
  519.             font-size: 11px;
  520.             color: #333;
  521.             line-height: 1;
  522.         }
  523.         
  524.         .month-day-pts {
  525.             font-size: 10px;
  526.             font-weight: 600;
  527.             color: #22c55e;
  528.             line-height: 1;
  529.             margin-top: 1px;
  530.         }
  531.         
  532.         /* 年历卡片 */
  533.         .year-calendar {
  534.             display: grid;
  535.             grid-template-columns: repeat(6, 1fr);
  536.             gap: 8px;
  537.         }
  538.         
  539.         .year-month-card {
  540.             background: #f8f9fa;
  541.             border-radius: 10px;
  542.             padding: 10px 6px;
  543.             text-align: center;
  544.         }
  545.         
  546.         .year-month-card.current {
  547.             background: rgba(34, 197, 94, 0.1);
  548.             border: 1.5px solid #22c55e;
  549.         }
  550.         
  551.         .year-month-name {
  552.             font-size: 11px;
  553.             color: #666;
  554.             margin-bottom: 4px;
  555.         }
  556.         
  557.         .year-month-total {
  558.             font-size: 16px;
  559.             font-weight: 700;
  560.             color: #22c55e;
  561.         }
  562.         
  563.         /* 积分记录列表 */
  564.         .record-list {
  565.             max-height: 400px;
  566.             overflow-y: auto;
  567.         }
  568.         
  569.         .record-item {
  570.             display: flex;
  571.             justify-content: space-between;
  572.             align-items: center;
  573.             padding: 15px 0;
  574.             border-bottom: 1px solid #f0f0f0;
  575.         }
  576.         
  577.         .record-item:last-child {
  578.             border-bottom: none;
  579.         }
  580.         
  581.         .record-info {
  582.             flex: 1;
  583.         }
  584.         
  585.         .record-title {
  586.             font-size: 14px;
  587.             font-weight: 600;
  588.             margin-bottom: 4px;
  589.         }
  590.         
  591.         .record-time {
  592.             font-size: 12px;
  593.             color: #999;
  594.         }
  595.         
  596.         .record-amount {
  597.             font-size: 16px;
  598.             font-weight: 700;
  599.             padding-left: 10px;
  600.             padding-right: 15px;
  601.             margin: 5px 0;
  602.         }
  603.         
  604.         .record-amount.income {
  605.             color: #10b981;
  606.         }
  607.         
  608.         .record-amount.expense {
  609.             color: #ef4444;
  610.         }
  611.         
  612.         /* 底部导航菜单 */
  613.         .bottom-nav {
  614.             position: fixed;
  615.             bottom: 0;
  616.             left: 0;
  617.             right: 0;
  618.             background: white;
  619.             display: flex;
  620.             justify-content: space-around;
  621.             padding: 10px 0;
  622.             padding-bottom: calc(10px + env(safe-area-inset-bottom));
  623.             box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  624.             z-index: 100;
  625.         }
  626.         
  627.         .nav-item {
  628.             text-align: center;
  629.             cursor: pointer;
  630.             flex: 1;
  631.         }
  632.         
  633.         .nav-icon {
  634.             font-size: 22px;
  635.             margin-bottom: 2px;
  636.         }
  637.         
  638.         .nav-text {
  639.             font-size: 11px;
  640.             color: #999;
  641.         }
  642.         
  643.         .nav-item.active .nav-text {
  644.             color: #22c55e;
  645.         }
  646.         
  647.         .nav-item.active .nav-icon {
  648.             color: #22c55e;
  649.         }
  650.         
  651.         /* 弹窗样式 */
  652.         .modal {
  653.             display: none;
  654.             position: fixed;
  655.             top: 0;
  656.             left: 0;
  657.             right: 0;
  658.             bottom: 0;
  659.             background: rgba(0, 0, 0, 0.5);
  660.             z-index: 1000;
  661.             align-items: center;
  662.             justify-content: center;
  663.         }
  664.         
  665.         .modal.show {
  666.             display: flex;
  667.         }
  668.         
  669.         .modal-content {
  670.             background: white;
  671.             border-radius: 20px;
  672.             padding: 25px;
  673.             width: 90%;
  674.             max-width: 400px;
  675.             animation: modalSlide 0.3s ease;
  676.         }
  677.         
  678.         @keyframes modalSlide {
  679.             from {
  680.                 transform: translateY(20px);
  681.                 opacity: 0;
  682.             }
  683.             to {
  684.                 transform: translateY(0);
  685.                 opacity: 1;
  686.             }
  687.         }
  688.         
  689.         .modal-title {
  690.             font-size: 18px;
  691.             font-weight: 700;
  692.             margin-bottom: 20px;
  693.             text-align: center;
  694.         }
  695.         
  696.         .modal-body {
  697.             margin-bottom: 20px;
  698.         }
  699.         
  700.         .form-group {
  701.             margin-bottom: 15px;
  702.         }
  703.         
  704.         .form-label {
  705.             display: block;
  706.             font-size: 14px;
  707.             font-weight: 600;
  708.             margin-bottom: 8px;
  709.             color: #333;
  710.         }
  711.         
  712.         .form-input {
  713.             width: 100%;
  714.             padding: 12px;
  715.             border: 2px solid #e0e0e0;
  716.             border-radius: 10px;
  717.             font-size: 14px;
  718.             transition: all 0.3s;
  719.         }
  720.         
  721.         .form-input:focus {
  722.             outline: none;
  723.             border-color: #22c55e;
  724.         }
  725.         
  726.         .form-input[type="number"] {
  727.             -moz-appearance: textfield;
  728.         }
  729.         
  730.         .form-input[type="number"]::-webkit-outer-spin-button,
  731.         .form-input[type="number"]::-webkit-inner-spin-button {
  732.             -webkit-appearance: none;
  733.             margin: 0;
  734.         }
  735.         
  736.         .modal-footer {
  737.             display: flex;
  738.             gap: 10px;
  739.         }
  740.         
  741.         .modal-btn {
  742.             flex: 1;
  743.             padding: 12px;
  744.             border: none;
  745.             border-radius: 10px;
  746.             font-size: 14px;
  747.             font-weight: 600;
  748.             cursor: pointer;
  749.         }
  750.         
  751.         .modal-btn.confirm {
  752.             background: #22c55e;
  753.             color: white;
  754.         }
  755.         
  756.         .modal-btn.cancel {
  757.             background: #f0f0f0;
  758.             color: #666;
  759.         }
  760.         
  761.         .modal-btn.danger {
  762.             background: #ef4444;
  763.             color: white;
  764.         }
  765.         
  766.         /* 页面切换 */
  767.         .page {
  768.             display: none;
  769.         }
  770.         
  771.         .page.active {
  772.             display: block;
  773.         }
  774.         
  775.         /* 空状态 */
  776.         .empty-state {
  777.             text-align: center;
  778.             padding: 40px 20px;
  779.             color: #999;
  780.         }
  781.         
  782.         .empty-icon {
  783.             font-size: 48px;
  784.             margin-bottom: 12px;
  785.         }
  786.         
  787.         .empty-text {
  788.             font-size: 14px;
  789.         }
  790.         
  791.         /* 响应式适配 */
  792.         @media (max-width: 420px) {
  793.             .points-amount {
  794.                 font-size: 48px;
  795.             }
  796.             
  797.             .features {
  798.                 gap: 8px;
  799.             }
  800.             
  801.             .week-grid {
  802.                 gap: 4px;
  803.             }
  804.             
  805.             .day-item {
  806.                 padding: 8px 3px;
  807.             }
  808.         }
  809.     </style>
  810. </head>
  811. <body>
  812.     <!-- 顶部导航 -->
  813.     <div class="header">
  814.         <h1>积分小管家</h1>
  815.     </div>
  816.    
  817.     <!-- 底部导航菜单 -->
  818.     <div class="bottom-nav">
  819.         <div class="nav-item active" onclick="switchPage('home')">
  820.             <div class="nav-icon">🏠</div>
  821.             <div class="nav-text">首页</div>
  822.         </div>
  823.     </div>
  824.    
  825.     <!-- 首页 -->
  826.     <div class="page active" id="home-page">
  827.         <!-- 积分卡片(总积分 + 今日积分合并) -->
  828.         <div class="points-card">
  829.             <div class="points-header">
  830.                 <div class="points-title">总积分</div>
  831.                 <div class="points-amount" id="total-points">0</div>
  832.             </div>
  833.             <div class="points-today">
  834.                 <span>📅 今日积分</span>
  835.                 <span class="today-divider"></span>
  836.                 <span class="today-value" id="daily-challenge">赚0分 - 扣0分 = 0分</span>
  837.             </div>
  838.         </div>
  839.         
  840.         <!-- 功能入口 -->
  841.         <div class="features">
  842.             <div class="feature-item" onclick="switchPage('earn')">
  843.                 <div class="feature-icon">➕</div>
  844.                 <div class="feature-name">赚取积分</div>
  845.             </div>
  846.             <div class="feature-item" onclick="switchPage('deduct')">
  847.                 <div class="feature-icon">➖</div>
  848.                 <div class="feature-name">扣取积分</div>
  849.             </div>
  850.             <div class="feature-item" onclick="switchPage('exchange')">
  851.                 <div class="feature-icon">🏪</div>
  852.                 <div class="feature-name">奖励兑换中心</div>
  853.             </div>
  854.             <div class="feature-item" onclick="switchPage('earn-manage')">
  855.                 <div class="feature-icon">💰</div>
  856.                 <div class="feature-name">积分项设置</div>
  857.             </div>
  858.             <div class="feature-item" onclick="switchPage('deduct-manage')">
  859.                 <div class="feature-icon">⚠️</div>
  860.                 <div class="feature-name">扣分项设置</div>
  861.             </div>
  862.             <div class="feature-item" onclick="switchPage('exchange-manage')">
  863.                 <div class="feature-icon">🎁</div>
  864.                 <div class="feature-name">兑换奖励设置</div>
  865.             </div>
  866.         </div>
  867.         
  868.         <!-- 本周积分 -->
  869.         <div class="content-section">
  870.             <div class="section-title">
  871.                 <span id="week-score-text">本周积分</span>
  872.             </div>
  873.             <div class="week-stats">
  874.                 <div class="week-grid" id="current-week-grid">
  875.                     <!-- 动态加载 -->
  876.                 </div>
  877.             </div>
  878.         </div>
  879.         
  880.         <!-- 快捷工具 -->
  881.         <div class="features">
  882.             <div class="feature-item" onclick="switchPage('records')">
  883.                 <div class="feature-icon">📊</div>
  884.                 <div class="feature-name">积分记录</div>
  885.             </div>
  886.             <div class="feature-item" onclick="showClearPointsModal()">
  887.                 <div class="feature-icon">🗑️</div>
  888.                 <div class="feature-name">积分清空</div>
  889.             </div>
  890.             <div class="feature-item" onclick="systemReset()">
  891.                 <div class="feature-icon">🔄</div>
  892.                 <div class="feature-name">系统重置</div>
  893.             </div>
  894.         </div>
  895.     </div>
  896.    
  897.     <!-- 赚取积分页面 -->
  898.     <div class="page" id="earn-page">
  899.         <div class="content-section">
  900.             <div class="section-title">
  901.                 <span>赚取积分</span>
  902.             </div>
  903.             <div id="earn-list">
  904.                 <!-- 动态加载 -->
  905.             </div>
  906.         </div>
  907.     </div>
  908.    
  909.     <!-- 扣取积分页面 -->
  910.     <div class="page" id="deduct-page">
  911.         <div class="content-section">
  912.             <div class="section-title">
  913.                 <span>扣取积分</span>
  914.             </div>
  915.             <div id="deduct-list">
  916.                 <!-- 动态加载 -->
  917.             </div>
  918.         </div>
  919.     </div>
  920.    
  921.     <!-- 兑换中心页面 -->
  922.     <div class="page" id="exchange-page">
  923.         <div class="content-section">
  924.             <div class="section-title">
  925.                 <span>兑换中心</span>
  926.             </div>
  927.             <div id="exchange-list">
  928.                 <!-- 动态加载 -->
  929.             </div>
  930.         </div>
  931.     </div>
  932.    
  933.     <!-- 赚取积分项管理页面 -->
  934.     <div class="page" id="earn-manage-page">
  935.         <div class="content-section">
  936.             <div class="section-title">
  937.                 <span>赚取积分项管理</span>
  938.                 <div class="section-actions">
  939.                     <button class="action-btn add" onclick="showAddEarnItemModal()">+ 添加</button>
  940.                 </div>
  941.             </div>
  942.             <div id="earn-manage-list">
  943.                 <!-- 动态加载 -->
  944.             </div>
  945.         </div>
  946.     </div>
  947.    
  948.     <!-- 扣取积分项管理页面 -->
  949.     <div class="page" id="deduct-manage-page">
  950.         <div class="content-section">
  951.             <div class="section-title">
  952.                 <span>扣取积分项管理</span>
  953.                 <div class="section-actions">
  954.                     <button class="action-btn add" onclick="showAddDeductItemModal()">+ 添加</button>
  955.                 </div>
  956.             </div>
  957.             <div id="deduct-manage-list">
  958.                 <!-- 动态加载 -->
  959.             </div>
  960.         </div>
  961.     </div>
  962.    
  963.     <!-- 兑换奖励管理页面 -->
  964.     <div class="page" id="exchange-manage-page">
  965.         <div class="content-section">
  966.             <div class="section-title">
  967.                 <span>兑换奖励管理</span>
  968.                 <div class="section-actions">
  969.                     <button class="action-btn add" onclick="showAddRewardModal()">+ 添加</button>
  970.                 </div>
  971.             </div>
  972.             <div id="reward-manage-list">
  973.                 <!-- 动态加载 -->
  974.             </div>
  975.         </div>
  976.     </div>
  977.    
  978.     <!-- 积分记录页面 -->
  979.     <div class="page" id="records-page">
  980.         <div class="content-section">
  981.             <div class="section-title">
  982.                 <span id="records-week-score-text">本周积分</span>
  983.                 <div class="section-actions">
  984.                     <button class="action-btn add" onclick="showAddPointsModal()">补积分</button>
  985.                 </div>
  986.             </div>
  987.             <div class="week-stats">
  988.                 <div class="week-grid" id="records-week-grid">
  989.                     <!-- 动态加载 -->
  990.                 </div>
  991.             </div>
  992.         </div>
  993.         
  994.         <div class="content-section">
  995.             <div class="section-title">每日积分记录</div>
  996.             <div class="record-list" id="day-records">
  997.                 <!-- 动态加载 -->
  998.             </div>
  999.         </div>
  1000.         
  1001.         <div class="content-section">
  1002.             <div class="section-title">历史积分</div>
  1003.             <div id="history-weeks">
  1004.                 <!-- 动态加载 -->
  1005.             </div>
  1006.         </div>
  1007.     </div>
  1008.    
  1009.     <!-- 添加赚取积分项弹窗 -->
  1010.     <div class="modal" id="add-earn-item-modal">
  1011.         <div class="modal-content">
  1012.             <div class="modal-title" id="earn-item-modal-title">添加赚取积分项</div>
  1013.             <div class="modal-body">
  1014.                 <div class="form-group">
  1015.                     <label class="form-label">项目名称</label>
  1016.                     <input type="text" class="form-input" id="earn-item-name" placeholder="例如:完成作业">
  1017.                 </div>
  1018.                 <div class="form-group">
  1019.                     <label class="form-label">积分数量</label>
  1020.                     <input type="number" class="form-input" id="earn-item-points" placeholder="例如:10">
  1021.                 </div>
  1022.             </div>
  1023.             <div class="modal-footer">
  1024.                 <button class="modal-btn cancel" onclick="closeModal('add-earn-item-modal')">取消</button>
  1025.                 <button class="modal-btn confirm" onclick="saveEarnItem()">保存</button>
  1026.             </div>
  1027.         </div>
  1028.     </div>
  1029.    
  1030.     <!-- 添加扣取积分项弹窗 -->
  1031.     <div class="modal" id="add-deduct-item-modal">
  1032.         <div class="modal-content">
  1033.             <div class="modal-title" id="deduct-item-modal-title">添加扣取积分项</div>
  1034.             <div class="modal-body">
  1035.                 <div class="form-group">
  1036.                     <label class="form-label">项目名称</label>
  1037.                     <input type="text" class="form-input" id="deduct-item-name" placeholder="例如:未完成作业">
  1038.                 </div>
  1039.                 <div class="form-group">
  1040.                     <label class="form-label">积分数量</label>
  1041.                     <input type="number" class="form-input" id="deduct-item-points" placeholder="例如:10">
  1042.                 </div>
  1043.             </div>
  1044.             <div class="modal-footer">
  1045.                 <button class="modal-btn cancel" onclick="closeModal('add-deduct-item-modal')">取消</button>
  1046.                 <button class="modal-btn confirm" onclick="saveDeductItem()">保存</button>
  1047.             </div>
  1048.         </div>
  1049.     </div>
  1050.    
  1051.     <!-- 添加兑换奖励弹窗 -->
  1052.     <div class="modal" id="add-reward-modal">
  1053.         <div class="modal-content">
  1054.             <div class="modal-title" id="reward-modal-title">添加兑换奖励</div>
  1055.             <div class="modal-body">
  1056.                 <div class="form-group">
  1057.                     <label class="form-label">奖励名称</label>
  1058.                     <input type="text" class="form-input" id="reward-name" placeholder="例如:看电视30分钟">
  1059.                 </div>
  1060.                 <div class="form-group">
  1061.                     <label class="form-label">所需积分</label>
  1062.                     <input type="number" class="form-input" id="reward-points" placeholder="例如:50">
  1063.                 </div>
  1064.             </div>
  1065.             <div class="modal-footer">
  1066.                 <button class="modal-btn cancel" onclick="closeModal('add-reward-modal')">取消</button>
  1067.                 <button class="modal-btn confirm" onclick="saveReward()">保存</button>
  1068.             </div>
  1069.         </div>
  1070.     </div>
  1071.    
  1072.     <!-- 兑换确认弹窗 -->
  1073.     <div class="modal" id="exchange-confirm-modal">
  1074.         <div class="modal-content">
  1075.             <div class="modal-title">确认兑换</div>
  1076.             <div class="modal-body">
  1077.                 <p id="exchange-reward-name">看电视30分钟</p>
  1078.                 <p style="color: #667eea; font-weight: 700; font-size: 20px; margin-top: 10px;" id="exchange-reward-points">50积分</p>
  1079.             </div>
  1080.             <div class="modal-footer">
  1081.                 <button class="modal-btn cancel" onclick="closeModal('exchange-confirm-modal')">取消</button>
  1082.                 <button class="modal-btn confirm" onclick="confirmExchange()">确认兑换</button>
  1083.             </div>
  1084.         </div>
  1085.     </div>
  1086.    
  1087.     <!-- 补积分弹窗 -->
  1088.     <div class="modal" id="add-points-modal">
  1089.         <div class="modal-content">
  1090.             <div class="modal-title">补积分</div>
  1091.             <div class="modal-body">
  1092.                 <div class="form-group">
  1093.                     <label class="form-label">补积分原因</label>
  1094.                     <input type="text" class="form-input" id="add-points-reason" placeholder="例如:忘记记录的作业完成">
  1095.                 </div>
  1096.                 <div class="form-group">
  1097.                     <label class="form-label">积分数值</label>
  1098.                     <input type="number" class="form-input" id="add-points-value" placeholder="例如:10">
  1099.                 </div>
  1100.                 <div class="form-group">
  1101.                     <label class="form-label">选择日期</label>
  1102.                     <input type="date" class="form-input" id="add-points-date">
  1103.                 </div>
  1104.             </div>
  1105.             <div class="modal-footer">
  1106.                 <button class="modal-btn cancel" onclick="closeModal('add-points-modal')">取消</button>
  1107.                 <button class="modal-btn confirm" onclick="addPoints()">确认补积分</button>
  1108.             </div>
  1109.         </div>
  1110.     </div>
  1111.    
  1112.     <!-- 清空积分确认弹窗 -->
  1113.     <div class="modal" id="clear-points-modal">
  1114.         <div class="modal-content">
  1115.             <div class="modal-title">确认清空积分</div>
  1116.             <div class="modal-body">
  1117.                 <p>确定要清空所有积分吗?此操作不可恢复!</p>
  1118.             </div>
  1119.             <div class="modal-footer">
  1120.                 <button class="modal-btn cancel" onclick="closeModal('clear-points-modal')">取消</button>
  1121.                 <button class="modal-btn danger" onclick="confirmClearPoints()">确认清空</button>
  1122.             </div>
  1123.         </div>
  1124.     </div>
  1125.    
  1126.     <!-- 删除确认弹窗 -->
  1127.     <div class="modal" id="delete-confirm-modal">
  1128.         <div class="modal-content">
  1129.             <div class="modal-title">确认删除</div>
  1130.             <div class="modal-body">
  1131.                 <p>确定要删除此项目吗?</p>
  1132.             </div>
  1133.             <div class="modal-footer">
  1134.                 <button class="modal-btn cancel" onclick="closeModal('delete-confirm-modal')">取消</button>
  1135.                 <button class="modal-btn danger" onclick="confirmDelete()">确认删除</button>
  1136.             </div>
  1137.         </div>
  1138.     </div>
  1139.     <script>
  1140.         // 数据存储键
  1141.         const STORAGE_KEYS = {
  1142.             TOTAL_POINTS: 'pointsDriver_totalPoints',
  1143.             EARN_ITEMS: 'pointsDriver_earnItems',
  1144.             DEDUCT_ITEMS: 'pointsDriver_deductItems',
  1145.             REWARDS: 'pointsDriver_rewards',
  1146.             RECORDS: 'pointsDriver_records',
  1147.             RECORD_ID_COUNTER: 'pointsDriver_recordIdCounter'
  1148.         };
  1149.         
  1150.         // 默认数据
  1151.         const DEFAULT_EARN_ITEMS = [
  1152.             { id: 1, name: '完成作业', points: 10 },
  1153.             { id: 2, name: '阅读30分钟', points: 5 },
  1154.             { id: 3, name: '做家务', points: 15 },
  1155.             { id: 4, name: '锻炼身体', points: 8 },
  1156.             { id: 5, name: '早睡早起', points: 5 }
  1157.         ];
  1158.         
  1159.         const DEFAULT_DEDUCT_ITEMS = [
  1160.             { id: 1, name: '未完成作业', points: -10 },
  1161.             { id: 2, name: '迟到', points: -5 },
  1162.             { id: 3, name: '说脏话', points: -8 },
  1163.             { id: 4, name: '不整理房间', points: -5 }
  1164.         ];
  1165.         
  1166.         const DEFAULT_REWARDS = [
  1167.             { id: 1, name: '看电视30分钟', points: 50 },
  1168.             { id: 2, name: '玩游戏1小时', points: 100 },
  1169.             { id: 3, name: '买零食', points: 30 },
  1170.             { id: 4, name: '周末外出', points: 200 }
  1171.         ];
  1172.         
  1173.         // 全局数据
  1174.         let totalPoints = 0;
  1175.         let earnItems = [];
  1176.         let deductItems = [];
  1177.         let rewards = [];
  1178.         let records = [];
  1179.         let recordIdCounter = 0;
  1180.         
  1181.         // 当前操作项
  1182.         let currentEditItem = null;
  1183.         let currentDeleteItem = null;
  1184.         let currentDeleteType = '';
  1185.         let currentExchangeReward = null;
  1186.         let selectedDate = null;
  1187.         let displayYear = null;
  1188.         let displayMonth = null;
  1189.         
  1190.         // 初始化数据
  1191.         function initData() {
  1192.             totalPoints = parseInt(localStorage.getItem(STORAGE_KEYS.TOTAL_POINTS)) || 0;
  1193.             earnItems = JSON.parse(localStorage.getItem(STORAGE_KEYS.EARN_ITEMS)) || JSON.parse(JSON.stringify(DEFAULT_EARN_ITEMS));
  1194.             deductItems = JSON.parse(localStorage.getItem(STORAGE_KEYS.DEDUCT_ITEMS)) || JSON.parse(JSON.stringify(DEFAULT_DEDUCT_ITEMS));
  1195.             rewards = JSON.parse(localStorage.getItem(STORAGE_KEYS.REWARDS)) || JSON.parse(JSON.stringify(DEFAULT_REWARDS));
  1196.             records = JSON.parse(localStorage.getItem(STORAGE_KEYS.RECORDS)) || [];
  1197.             recordIdCounter = parseInt(localStorage.getItem(STORAGE_KEYS.RECORD_ID_COUNTER)) || 0;
  1198.         }
  1199.         
  1200.         // 保存数据
  1201.         function saveData() {
  1202.             localStorage.setItem(STORAGE_KEYS.TOTAL_POINTS, totalPoints);
  1203.             localStorage.setItem(STORAGE_KEYS.EARN_ITEMS, JSON.stringify(earnItems));
  1204.             localStorage.setItem(STORAGE_KEYS.DEDUCT_ITEMS, JSON.stringify(deductItems));
  1205.             localStorage.setItem(STORAGE_KEYS.REWARDS, JSON.stringify(rewards));
  1206.             localStorage.setItem(STORAGE_KEYS.RECORDS, JSON.stringify(records));
  1207.             localStorage.setItem(STORAGE_KEYS.RECORD_ID_COUNTER, recordIdCounter);
  1208.         }
  1209.         
  1210.         // 更新积分显示
  1211.         function updatePointsDisplay() {
  1212.             document.getElementById('total-points').textContent = totalPoints.toLocaleString();
  1213.         }
  1214.         
  1215.         // 页面切换
  1216.         function switchPage(pageName) {
  1217.             // 隐藏所有页面
  1218.             document.querySelectorAll('.page').forEach(page => {
  1219.                 page.classList.remove('active');
  1220.             });
  1221.             
  1222.             // 显示目标页面
  1223.             const targetPage = document.getElementById(pageName + '-page');
  1224.             if (targetPage) {
  1225.                 targetPage.classList.add('active');
  1226.             }
  1227.             
  1228.             // 更新底部导航
  1229.             document.querySelectorAll('.nav-item').forEach(item => {
  1230.                 item.classList.remove('active');
  1231.             });
  1232.             
  1233.             // 根据页面名称激活对应导航
  1234.             const navMap = { 'home': 0 };
  1235.             
  1236.             const navItems = document.querySelectorAll('.nav-item');
  1237.             if (navMap[pageName] !== undefined) {
  1238.                 navItems[navMap[pageName]].classList.add('active');
  1239.             }
  1240.             
  1241.             // 加载页面数据
  1242.             if (pageName === 'home') {
  1243.                 loadHomeData();
  1244.             } else if (pageName === 'earn') {
  1245.                 loadEarnList();
  1246.             } else if (pageName === 'deduct') {
  1247.                 loadDeductList();
  1248.             } else if (pageName === 'exchange') {
  1249.                 loadExchangeList();
  1250.             } else if (pageName === 'earn-manage') {
  1251.                 loadEarnManageList();
  1252.             } else if (pageName === 'deduct-manage') {
  1253.                 loadDeductManageList();
  1254.             } else if (pageName === 'exchange-manage') {
  1255.                 loadRewardManageList();
  1256.             } else if (pageName === 'records') {
  1257.                 loadRecordsData();
  1258.             }
  1259.         }
  1260.         
  1261.         // 更新当天积分显示
  1262.         function updateTodayPointsDisplay() {
  1263.             const today = formatDate(new Date());
  1264.             const dayRecords = records.filter(r => r.date === today);
  1265.             const earnPoints = dayRecords.filter(r => r.type === 'income').reduce((sum, r) => sum + r.amount, 0);
  1266.             const deductPoints = Math.abs(dayRecords.filter(r => r.type === 'expense').reduce((sum, r) => sum + r.amount, 0));
  1267.             const netPoints = earnPoints - deductPoints;
  1268.             
  1269.             document.getElementById('daily-challenge').textContent = `赚${earnPoints}分 - 扣${deductPoints}分 = ${netPoints}分`;
  1270.         }
  1271.         
  1272.         // 加载首页数据
  1273.         function loadHomeData() {
  1274.             updatePointsDisplay();
  1275.             updateTodayPointsDisplay();
  1276.             loadCurrentWeekGrid('current-week-grid', 'week-score-text');
  1277.         }
  1278.         
  1279.         // 加载赚取积分列表
  1280.         function loadEarnList() {
  1281.             const listContainer = document.getElementById('earn-list');
  1282.             let html = `
  1283.                 <div class="quick-add">
  1284.                     <input class="qa-name" id="quick-earn-name" placeholder="名称(留空则用日期)">
  1285.                     <input class="qa-points" id="quick-earn-points" type="number" placeholder="积分">
  1286.                     <button class="qa-btn" onclick="quickEarn()">赚取</button>
  1287.                 </div>
  1288.             `;
  1289.             if (earnItems.length === 0) {
  1290.                 html += `
  1291.                     <div class="empty-state">
  1292.                         <div class="empty-icon">💰</div>
  1293.                         <div class="empty-text">暂无赚取积分项</div>
  1294.                     </div>
  1295.                 `;
  1296.             } else {
  1297.                 html += earnItems.map(item => `
  1298.                     <div class="list-item">
  1299.                         <div class="item-info">
  1300.                             <div class="item-name">${item.name}</div>
  1301.                             <div class="item-points income">+${item.points}积分</div>
  1302.                         </div>
  1303.                         <button class="item-btn earn" onclick="earnPoints(${item.id})">赚取</button>
  1304.                     </div>
  1305.                 `).join('');
  1306.             }
  1307.             listContainer.innerHTML = html;
  1308.         }
  1309.         
  1310.         // 加载扣取积分列表
  1311.         function loadDeductList() {
  1312.             const listContainer = document.getElementById('deduct-list');
  1313.             let html = `
  1314.                 <div class="quick-add deduct">
  1315.                     <input class="qa-name" id="quick-deduct-name" placeholder="名称(留空则用日期)">
  1316.                     <input class="qa-points" id="quick-deduct-points" type="number" placeholder="积分">
  1317.                     <button class="qa-btn" onclick="quickDeduct()">扣取</button>
  1318.                 </div>
  1319.             `;
  1320.             if (deductItems.length === 0) {
  1321.                 html += `
  1322.                     <div class="empty-state">
  1323.                         <div class="empty-icon">⚠️</div>
  1324.                         <div class="empty-text">暂无扣取积分项</div>
  1325.                     </div>
  1326.                 `;
  1327.             } else {
  1328.                 html += deductItems.map(item => `
  1329.                     <div class="list-item">
  1330.                         <div class="item-info">
  1331.                             <div class="item-name">${item.name}</div>
  1332.                             <div class="item-points expense">${item.points}积分</div>
  1333.                         </div>
  1334.                         <button class="item-btn deduct" onclick="deductPoints(${item.id})">扣取</button>
  1335.                     </div>
  1336.                 `).join('');
  1337.             }
  1338.             listContainer.innerHTML = html;
  1339.         }
  1340.         
  1341.         // 加载兑换列表
  1342.         function loadExchangeList() {
  1343.             const listContainer = document.getElementById('exchange-list');
  1344.             let html = `
  1345.                 <div class="quick-add exchange">
  1346.                     <input class="qa-name" id="quick-exchange-name" placeholder="名称(留空则用日期)">
  1347.                     <input class="qa-points" id="quick-exchange-points" type="number" placeholder="积分">
  1348.                     <button class="qa-btn" onclick="quickExchange()">兑换</button>
  1349.                 </div>
  1350.             `;
  1351.             if (rewards.length === 0) {
  1352.                 html += `
  1353.                     <div class="empty-state">
  1354.                         <div class="empty-icon">🎁</div>
  1355.                         <div class="empty-text">暂无兑换奖励</div>
  1356.                     </div>
  1357.                 `;
  1358.             } else {
  1359.                 html += rewards.map(reward => `
  1360.                     <div class="list-item">
  1361.                         <div class="item-info">
  1362.                             <div class="item-name">${reward.name}</div>
  1363.                             <div class="item-points">${reward.points}积分</div>
  1364.                         </div>
  1365.                         <button class="item-btn exchange" onclick="showExchangeModal(${reward.id})">兑换</button>
  1366.                     </div>
  1367.             `).join('');
  1368.             }
  1369.             listContainer.innerHTML = html;
  1370.         }
  1371.         
  1372.         // 加载赚取积分项管理列表
  1373.         function loadEarnManageList() {
  1374.             const listContainer = document.getElementById('earn-manage-list');
  1375.             if (earnItems.length === 0) {
  1376.                 listContainer.innerHTML = `
  1377.                     <div class="empty-state">
  1378.                         <div class="empty-icon">💰</div>
  1379.                         <div class="empty-text">暂无赚取积分项</div>
  1380.                     </div>
  1381.                 `;
  1382.                 return;
  1383.             }
  1384.             
  1385.             listContainer.innerHTML = earnItems.map(item => `
  1386.                 <div class="list-item">
  1387.                     <div class="item-info">
  1388.                         <div class="item-name">${item.name}</div>
  1389.                         <div class="item-points income">+${item.points}积分</div>
  1390.                     </div>
  1391.                     <div class="item-actions">
  1392.                         <button class="action-btn edit" onclick="editEarnItem(${item.id})">编辑</button>
  1393.                         <button class="action-btn delete" onclick="deleteEarnItem(${item.id})">删除</button>
  1394.                     </div>
  1395.                 </div>
  1396.             `).join('');
  1397.         }
  1398.         
  1399.         // 加载扣取积分项管理列表
  1400.         function loadDeductManageList() {
  1401.             const listContainer = document.getElementById('deduct-manage-list');
  1402.             if (deductItems.length === 0) {
  1403.                 listContainer.innerHTML = `
  1404.                     <div class="empty-state">
  1405.                         <div class="empty-icon">⚠️</div>
  1406.                         <div class="empty-text">暂无扣取积分项</div>
  1407.                     </div>
  1408.                 `;
  1409.                 return;
  1410.             }
  1411.             
  1412.             listContainer.innerHTML = deductItems.map(item => `
  1413.                 <div class="list-item">
  1414.                     <div class="item-info">
  1415.                         <div class="item-name">${item.name}</div>
  1416.                         <div class="item-points expense">${item.points}积分</div>
  1417.                     </div>
  1418.                     <div class="item-actions">
  1419.                         <button class="action-btn edit" onclick="editDeductItem(${item.id})">编辑</button>
  1420.                         <button class="action-btn delete" onclick="deleteDeductItem(${item.id})">删除</button>
  1421.                     </div>
  1422.                 </div>
  1423.             `).join('');
  1424.         }
  1425.         
  1426.         // 加载奖励管理列表
  1427.         function loadRewardManageList() {
  1428.             const listContainer = document.getElementById('reward-manage-list');
  1429.             if (rewards.length === 0) {
  1430.                 listContainer.innerHTML = `
  1431.                     <div class="empty-state">
  1432.                         <div class="empty-icon">🎁</div>
  1433.                         <div class="empty-text">暂无兑换奖励</div>
  1434.                     </div>
  1435.                 `;
  1436.                 return;
  1437.             }
  1438.             
  1439.             listContainer.innerHTML = rewards.map(reward => `
  1440.                 <div class="list-item">
  1441.                     <div class="item-info">
  1442.                         <div class="item-name">${reward.name}</div>
  1443.                         <div class="item-points">${reward.points}积分</div>
  1444.                     </div>
  1445.                     <div class="item-actions">
  1446.                         <button class="action-btn edit" onclick="editReward(${reward.id})">编辑</button>
  1447.                         <button class="action-btn delete" onclick="deleteReward(${reward.id})">删除</button>
  1448.                     </div>
  1449.                 </div>
  1450.             `).join('');
  1451.         }
  1452.         
  1453.         // 加载积分记录数据
  1454.         function loadRecordsData() {
  1455.             // 如果没有选中日期,默认选中当天
  1456.             if (!selectedDate) {
  1457.                 selectedDate = formatDate(new Date());
  1458.             }
  1459.             loadCurrentWeekGrid('records-week-grid', 'records-week-score-text');
  1460.             loadDayRecords();
  1461.             loadHistoryWeeks();
  1462.         }
  1463.         
  1464.         // 加载当前周积分网格
  1465.         function loadCurrentWeekGrid(gridId, titleId) {
  1466.             const grid = document.getElementById(gridId);
  1467.             
  1468.             const now = new Date();
  1469.             const currentDay = now.getDay();
  1470.             const weekStart = new Date(now);
  1471.             weekStart.setDate(now.getDate() - (currentDay === 0 ? 6 : currentDay - 1)); // 周一
  1472.             
  1473.             let weekTotal = 0;
  1474.             const dayNames = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
  1475.             
  1476.             let cellsHtml = '';
  1477.             dayNames.forEach((dayName, index) => {
  1478.                 const date = new Date(weekStart);
  1479.                 date.setDate(weekStart.getDate() + index);
  1480.                 const dateStr = formatDate(date);
  1481.                
  1482.                 const dayRecords = records.filter(r => r.date === dateStr);
  1483.                 const dayTotal = dayRecords.reduce((sum, r) => sum + r.amount, 0);
  1484.                 weekTotal += dayTotal;
  1485.                
  1486.                 const isToday = date.toDateString() === now.toDateString();
  1487.                 const isSelected = selectedDate === dateStr;
  1488.                
  1489.                 let pointsClass = '';
  1490.                 if (isToday) {
  1491.                     pointsClass = 'today-points';
  1492.                 } else if (isSelected) {
  1493.                     pointsClass = 'selected-points';
  1494.                 }
  1495.                
  1496.                 cellsHtml += `
  1497.                     <div class="day-item ${isToday ? 'today' : ''} ${isSelected ? 'selected' : ''}" onclick="switchToDayRecords('${dateStr}')">
  1498.                         <div class="day-name">${dayName}</div>
  1499.                         <div class="day-points ${pointsClass}">${dayTotal > 0 ? '+' : ''}${dayTotal}</div>
  1500.                     </div>
  1501.                 `;
  1502.             });
  1503.             grid.innerHTML = cellsHtml;
  1504.             
  1505.             // 更新本周积分标题
  1506.             const scoreEl = document.getElementById(titleId);
  1507.             if (scoreEl) {
  1508.                 const sign = weekTotal >= 0 ? '+' : '';
  1509.                 scoreEl.textContent = `本周积分 (${sign}${weekTotal})`;
  1510.             }
  1511.         }
  1512.         
  1513.         // 切换到记录页面并显示当天详情
  1514.         function switchToDayRecords(dateStr) {
  1515.             selectedDate = dateStr;
  1516.             switchPage('records');
  1517.             loadDayRecords();
  1518.             // 重新加载周积分网格,以更新选中状态
  1519.             loadCurrentWeekGrid('records-week-grid', 'records-week-score-text');
  1520.         }
  1521.         
  1522.         // 加载每日积分记录
  1523.         function loadDayRecords() {
  1524.             const container = document.getElementById('day-records');
  1525.             
  1526.             if (selectedDate) {
  1527.                 const dayRecords = records.filter(r => r.date === selectedDate);
  1528.                 if (dayRecords.length === 0) {
  1529.                     container.innerHTML = `
  1530.                         <div class="empty-state">
  1531.                             <div class="empty-icon">📊</div>
  1532.                             <div class="empty-text">该日期暂无积分记录</div>
  1533.                         </div>
  1534.                     `;
  1535.                 } else {
  1536.                     container.innerHTML = dayRecords.map(record => `
  1537.                         <div class="record-item">
  1538.                             <div class="record-info">
  1539.                                 <div class="record-title">${record.title}</div>
  1540.                                 <div class="record-time">${record.time}</div>
  1541.                             </div>
  1542.                             <div class="record-amount ${record.type}">${record.type === 'income' ? '+' : ''}${record.amount}</div>
  1543.                             <button class="action-btn delete" onclick="undoRecord(${record.id})" style="font-size:10px;padding:3px 8px;flex-shrink:0;">撤销</button>
  1544.                         </div>
  1545.                     `).join('');
  1546.                 }
  1547.             } else {
  1548.                 container.innerHTML = `
  1549.                     <div class="empty-state">
  1550.                         <div class="empty-icon">📅</div>
  1551.                         <div class="empty-text">点击上方某天查看详细记录</div>
  1552.                     </div>
  1553.                 `;
  1554.             }
  1555.         }
  1556.         
  1557.         // 加载历史积分(月日历 + 年历)
  1558.         function loadHistoryWeeks() {
  1559.             const container = document.getElementById('history-weeks');
  1560.             const now = new Date();
  1561.             const curYear = now.getFullYear();
  1562.             const curMonth = now.getMonth();
  1563.             const weekdayNames = ['一', '二', '三', '四', '五', '六', '日'];
  1564.             const monthNames = ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'];
  1565.             
  1566.             // 确定显示的月份
  1567.             if (displayYear === null) displayYear = curYear;
  1568.             if (displayMonth === null) displayMonth = curMonth;
  1569.             const dYear = displayYear;
  1570.             const dMonth = displayMonth;
  1571.             
  1572.             // 年度总积分
  1573.             const yearStart = formatDate(new Date(dYear, 0, 1));
  1574.             const yearEnd = formatDate(new Date(dYear, 11, 31));
  1575.             const yearRecords = records.filter(r => r.date >= yearStart && r.date <= yearEnd);
  1576.             const yearTotal = yearRecords.reduce((sum, r) => sum + r.amount, 0);
  1577.             const ySign = yearTotal > 0 ? '+' : '';
  1578.             
  1579.             // 当月月历
  1580.             const daysInMonth = new Date(dYear, dMonth + 1, 0).getDate();
  1581.             const monthStart = formatDate(new Date(dYear, dMonth, 1));
  1582.             const monthEnd = formatDate(new Date(dYear, dMonth, daysInMonth));
  1583.             const monthRecords = records.filter(r => r.date >= monthStart && r.date <= monthEnd);
  1584.             const monthTotal = monthRecords.reduce((sum, r) => sum + r.amount, 0);
  1585.             const totalSign = monthTotal > 0 ? '+' : '';
  1586.             const firstDay = new Date(dYear, dMonth, 1).getDay();
  1587.             const startPadding = firstDay === 0 ? 6 : firstDay - 1;
  1588.             
  1589.             let html = `<div class="month-calendar">
  1590.                 <div class="month-header">
  1591.                     <div class="month-title">${dYear}年${dMonth + 1}月 (${totalSign}${monthTotal})</div>
  1592.                 </div>
  1593.                 <div class="month-weekdays">${weekdayNames.map(w => `<div class="month-weekday">${w}</div>`).join('')}</div>
  1594.                 <div class="month-days">`;
  1595.             
  1596.             for (let p = 0; p < startPadding; p++) {
  1597.                 html += `<div class="month-day empty"></div>`;
  1598.             }
  1599.             
  1600.             for (let d = 1; d <= daysInMonth; d++) {
  1601.                 const dateStr = formatDate(new Date(dYear, dMonth, d));
  1602.                 const dayRecords = records.filter(r => r.date === dateStr);
  1603.                 const dayTotal = dayRecords.reduce((sum, r) => sum + r.amount, 0);
  1604.                 const ptsStr = dayTotal !== 0 ? ((dayTotal > 0 ? '+' : '') + dayTotal) : '';
  1605.                 const isToday = dateStr === formatDate(now) ? ' today' : '';
  1606.                 html += `<div class="month-day${isToday}">
  1607.                     <div class="month-day-num">${d}</div>
  1608.                     <div class="month-day-pts">${ptsStr}</div>
  1609.                 </div>`;
  1610.             }
  1611.             
  1612.             html += `</div></div>`;
  1613.             
  1614.             // 年历
  1615.             html += `<div class="section-title">${dYear}年总积分 (${ySign}${yearTotal})</div>`;
  1616.             
  1617.             // 年历 6×2 宫格
  1618.             html += `<div class="year-calendar">`;
  1619.             for (let m = 0; m < 12; m++) {
  1620.                 const mStart = formatDate(new Date(dYear, m, 1));
  1621.                 const mEnd = formatDate(new Date(dYear, m, new Date(dYear, m + 1, 0).getDate()));
  1622.                 const mRecords = records.filter(r => r.date >= mStart && r.date <= mEnd);
  1623.                 const mTotal = mRecords.reduce((sum, r) => sum + r.amount, 0);
  1624.                 const mSign = mTotal > 0 ? '+' : '';
  1625.                 const isCur = (dYear === curYear && m === curMonth) ? ' current' : '';
  1626.                 html += `<div class="year-month-card${isCur}" onclick="switchMonthCalendar(${m})">
  1627.                     <div class="year-month-name">${monthNames[m]}</div>
  1628.                     <div class="year-month-total">${mSign}${mTotal}</div>
  1629.                 </div>`;
  1630.             }
  1631.             html += `</div>`;
  1632.             
  1633.             container.innerHTML = html;
  1634.         }
  1635.         
  1636.         // 点击年历卡片切换月日历
  1637.         function switchMonthCalendar(month) {
  1638.             displayYear = displayYear !== null ? displayYear : new Date().getFullYear();
  1639.             displayMonth = month;
  1640.             loadHistoryWeeks();
  1641.         }
  1642.         
  1643.         // 格式化日期
  1644.         function formatDate(date) {
  1645.             const year = date.getFullYear();
  1646.             const month = String(date.getMonth() + 1).padStart(2, '0');
  1647.             const day = String(date.getDate()).padStart(2, '0');
  1648.             return `${year}-${month}-${day}`;
  1649.         }
  1650.         
  1651.         // 赚取积分
  1652.         // 快速赚取积分(自定义填入)
  1653.         function quickEarn() {
  1654.             const nameEl = document.getElementById('quick-earn-name');
  1655.             const pointsEl = document.getElementById('quick-earn-points');
  1656.             const name = nameEl.value.trim() || formatDate(new Date());
  1657.             const points = parseInt(pointsEl.value);
  1658.             if (!points || points <= 0) { showAlert('请输入有效积分'); return; }
  1659.             totalPoints += points;
  1660.             addRecord(name, points, 'income');
  1661.             nameEl.value = '';
  1662.             pointsEl.value = '';
  1663.             updatePointsDisplay();
  1664.             updateTodayPointsDisplay();
  1665.             saveData();
  1666.             showAlert(`赚取 +${points} 积分`);
  1667.         }
  1668.         
  1669.         // 快速扣取积分(自定义填入)
  1670.         function quickDeduct() {
  1671.             const nameEl = document.getElementById('quick-deduct-name');
  1672.             const pointsEl = document.getElementById('quick-deduct-points');
  1673.             const name = nameEl.value.trim() || formatDate(new Date());
  1674.             const points = parseInt(pointsEl.value);
  1675.             if (!points || points <= 0) { showAlert('请输入有效积分'); return; }
  1676.             totalPoints -= points;
  1677.             addRecord(name, -points, 'expense');
  1678.             nameEl.value = '';
  1679.             pointsEl.value = '';
  1680.             updatePointsDisplay();
  1681.             updateTodayPointsDisplay();
  1682.             saveData();
  1683.             showAlert(`扣取 -${points} 积分`);
  1684.         }
  1685.         
  1686.         // 快速兑换(自定义填入)
  1687.         function quickExchange() {
  1688.             const nameEl = document.getElementById('quick-exchange-name');
  1689.             const pointsEl = document.getElementById('quick-exchange-points');
  1690.             const name = nameEl.value.trim() || formatDate(new Date());
  1691.             const points = parseInt(pointsEl.value);
  1692.             if (!points || points <= 0) { showAlert('请输入有效积分'); return; }
  1693.             if (totalPoints < points) { showAlert('积分不足'); return; }
  1694.             totalPoints -= points;
  1695.             addRecord(name, -points, 'expense');
  1696.             nameEl.value = '';
  1697.             pointsEl.value = '';
  1698.             updatePointsDisplay();
  1699.             updateTodayPointsDisplay();
  1700.             saveData();
  1701.             showAlert(`兑换成功!消耗 ${points} 积分`);
  1702.         }
  1703.         
  1704.         function earnPoints(itemId) {
  1705.             const item = earnItems.find(i => i.id === itemId);
  1706.             if (item) {
  1707.                 totalPoints += item.points;
  1708.                 addRecord(item.name, item.points, 'income');
  1709.                 updatePointsDisplay();
  1710.                 updateTodayPointsDisplay();
  1711.                 saveData();
  1712.                 showAlert(`成功赚取${item.points}积分!`);
  1713.             }
  1714.         }
  1715.         
  1716.         // 显示自定义提示弹窗
  1717.         function showAlert(message) {
  1718.             const modal = document.createElement('div');
  1719.             modal.className = 'modal show';
  1720.             modal.innerHTML = `
  1721.                 <div class="modal-content">
  1722.                     <div class="modal-title">提示</div>
  1723.                     <div class="modal-body">
  1724.                         <p>${message}</p>
  1725.                     </div>
  1726.                     <div class="modal-footer">
  1727.                         <button class="modal-btn confirm" onclick="this.closest('.modal').remove()">确定</button>
  1728.                     </div>
  1729.                 </div>
  1730.             `;
  1731.             document.body.appendChild(modal);
  1732.             
  1733.             // 点击弹窗外部关闭
  1734.             modal.addEventListener('click', function(e) {
  1735.                 if (e.target === this) {
  1736.                     this.remove();
  1737.                 }
  1738.             });
  1739.         }
  1740.         
  1741.         // 扣取积分
  1742.         function deductPoints(itemId) {
  1743.             const item = deductItems.find(i => i.id === itemId);
  1744.             if (item) {
  1745.                 totalPoints += item.points;
  1746.                 addRecord(item.name, item.points, 'expense');
  1747.                 updatePointsDisplay();
  1748.                 updateTodayPointsDisplay();
  1749.                 saveData();
  1750.                 showAlert(`成功扣取${Math.abs(item.points)}积分!`);
  1751.             }
  1752.         }
  1753.         
  1754.         // 添加积分记录
  1755.         function addRecord(title, amount, type, date = null, timeStr = null) {
  1756.             const now = new Date();
  1757.             const recordDate = date ? new Date(date) : now;
  1758.             recordIdCounter++;
  1759.             records.unshift({
  1760.                 id: recordIdCounter,
  1761.                 title: title,
  1762.                 amount: amount,
  1763.                 type: type,
  1764.                 date: formatDate(recordDate),
  1765.                 time: timeStr || now.toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' })
  1766.             });
  1767.         }
  1768.         
  1769.         
  1770.         // 显示添加赚取积分项弹窗
  1771.         function showAddEarnItemModal() {
  1772.             currentEditItem = null;
  1773.             document.getElementById('earn-item-modal-title').textContent = '添加赚取积分项';
  1774.             document.getElementById('earn-item-name').value = '';
  1775.             document.getElementById('earn-item-points').value = '';
  1776.             document.getElementById('add-earn-item-modal').classList.add('show');
  1777.         }
  1778.         
  1779.         // 编辑赚取积分项
  1780.         function editEarnItem(itemId) {
  1781.             const item = earnItems.find(i => i.id === itemId);
  1782.             if (item) {
  1783.                 currentEditItem = item;
  1784.                 document.getElementById('earn-item-modal-title').textContent = '编辑赚取积分项';
  1785.                 document.getElementById('earn-item-name').value = item.name;
  1786.                 document.getElementById('earn-item-points').value = item.points;
  1787.                 document.getElementById('add-earn-item-modal').classList.add('show');
  1788.             }
  1789.         }
  1790.         
  1791.         // 保存赚取积分项
  1792.         function saveEarnItem() {
  1793.             const name = document.getElementById('earn-item-name').value.trim();
  1794.             const points = parseInt(document.getElementById('earn-item-points').value);
  1795.             
  1796.             if (!name || isNaN(points)) {
  1797.                 showAlert('请填写完整信息');
  1798.                 return;
  1799.             }
  1800.             
  1801.             if (currentEditItem) {
  1802.                 // 编辑
  1803.                 currentEditItem.name = name;
  1804.                 currentEditItem.points = points;
  1805.             } else {
  1806.                 // 添加
  1807.                 const newId = earnItems.length > 0 ? Math.max(...earnItems.map(i => i.id)) + 1 : 1;
  1808.                 earnItems.push({ id: newId, name: name, points: points });
  1809.             }
  1810.             
  1811.             saveData();
  1812.             loadEarnManageList();
  1813.             closeModal('add-earn-item-modal');
  1814.         }
  1815.         
  1816.         // 删除赚取积分项
  1817.         function deleteEarnItem(itemId) {
  1818.             currentDeleteItem = itemId;
  1819.             currentDeleteType = 'earn';
  1820.             document.getElementById('delete-confirm-modal').classList.add('show');
  1821.         }
  1822.         
  1823.         // 显示添加扣取积分项弹窗
  1824.         function showAddDeductItemModal() {
  1825.             currentEditItem = null;
  1826.             document.getElementById('deduct-item-modal-title').textContent = '添加扣取积分项';
  1827.             document.getElementById('deduct-item-name').value = '';
  1828.             document.getElementById('deduct-item-points').value = '';
  1829.             document.getElementById('add-deduct-item-modal').classList.add('show');
  1830.         }
  1831.         
  1832.         // 编辑扣取积分项
  1833.         function editDeductItem(itemId) {
  1834.             const item = deductItems.find(i => i.id === itemId);
  1835.             if (item) {
  1836.                 currentEditItem = item;
  1837.                 document.getElementById('deduct-item-modal-title').textContent = '编辑扣取积分项';
  1838.                 document.getElementById('deduct-item-name').value = item.name;
  1839.                 document.getElementById('deduct-item-points').value = Math.abs(item.points);
  1840.                 document.getElementById('add-deduct-item-modal').classList.add('show');
  1841.             }
  1842.         }
  1843.         
  1844.         // 保存扣取积分项
  1845.         function saveDeductItem() {
  1846.             const name = document.getElementById('deduct-item-name').value.trim();
  1847.             const points = parseInt(document.getElementById('deduct-item-points').value);
  1848.             
  1849.             if (!name || isNaN(points)) {
  1850.                 showAlert('请填写完整信息');
  1851.                 return;
  1852.             }
  1853.             
  1854.             if (currentEditItem) {
  1855.                 // 编辑
  1856.                 currentEditItem.name = name;
  1857.                 currentEditItem.points = -points;
  1858.             } else {
  1859.                 // 添加
  1860.                 const newId = deductItems.length > 0 ? Math.max(...deductItems.map(i => i.id)) + 1 : 1;
  1861.                 deductItems.push({ id: newId, name: name, points: -points });
  1862.             }
  1863.             
  1864.             saveData();
  1865.             loadDeductManageList();
  1866.             closeModal('add-deduct-item-modal');
  1867.         }
  1868.         
  1869.         // 删除扣取积分项
  1870.         function deleteDeductItem(itemId) {
  1871.             currentDeleteItem = itemId;
  1872.             currentDeleteType = 'deduct';
  1873.             document.getElementById('delete-confirm-modal').classList.add('show');
  1874.         }
  1875.         
  1876.         // 显示添加奖励弹窗
  1877.         function showAddRewardModal() {
  1878.             currentEditItem = null;
  1879.             document.getElementById('reward-modal-title').textContent = '添加兑换奖励';
  1880.             document.getElementById('reward-name').value = '';
  1881.             document.getElementById('reward-points').value = '';
  1882.             document.getElementById('add-reward-modal').classList.add('show');
  1883.         }
  1884.         
  1885.         // 编辑奖励
  1886.         function editReward(rewardId) {
  1887.             const reward = rewards.find(r => r.id === rewardId);
  1888.             if (reward) {
  1889.                 currentEditItem = reward;
  1890.                 document.getElementById('reward-modal-title').textContent = '编辑兑换奖励';
  1891.                 document.getElementById('reward-name').value = reward.name;
  1892.                 document.getElementById('reward-points').value = reward.points;
  1893.                 document.getElementById('add-reward-modal').classList.add('show');
  1894.             }
  1895.         }
  1896.         
  1897.         // 保存奖励
  1898.         function saveReward() {
  1899.             const name = document.getElementById('reward-name').value.trim();
  1900.             const points = parseInt(document.getElementById('reward-points').value);
  1901.             
  1902.             if (!name || isNaN(points)) {
  1903.                 showAlert('请填写完整信息');
  1904.                 return;
  1905.             }
  1906.             
  1907.             if (currentEditItem) {
  1908.                 // 编辑
  1909.                 currentEditItem.name = name;
  1910.                 currentEditItem.points = points;
  1911.             } else {
  1912.                 // 添加
  1913.                 const newId = rewards.length > 0 ? Math.max(...rewards.map(r => r.id)) + 1 : 1;
  1914.                 rewards.push({ id: newId, name: name, points: points });
  1915.             }
  1916.             
  1917.             saveData();
  1918.             loadRewardManageList();
  1919.             closeModal('add-reward-modal');
  1920.         }
  1921.         
  1922.         // 删除奖励
  1923.         function deleteReward(rewardId) {
  1924.             currentDeleteItem = rewardId;
  1925.             currentDeleteType = 'reward';
  1926.             document.getElementById('delete-confirm-modal').classList.add('show');
  1927.         }
  1928.         
  1929.         // 显示兑换弹窗
  1930.         function showExchangeModal(rewardId) {
  1931.             const reward = rewards.find(r => r.id === rewardId);
  1932.             if (reward) {
  1933.                 currentExchangeReward = reward;
  1934.                 document.getElementById('exchange-reward-name').textContent = reward.name;
  1935.                 document.getElementById('exchange-reward-points').textContent = reward.points + '积分';
  1936.                 document.getElementById('exchange-confirm-modal').classList.add('show');
  1937.             }
  1938.         }
  1939.         
  1940.         // 确认兑换
  1941.         function confirmExchange() {
  1942.             if (currentExchangeReward && totalPoints >= currentExchangeReward.points) {
  1943.                 totalPoints -= currentExchangeReward.points;
  1944.                 addRecord('兑换:' + currentExchangeReward.name, -currentExchangeReward.points, 'expense');
  1945.                 updatePointsDisplay();
  1946.                 updateTodayPointsDisplay();
  1947.                 saveData();
  1948.                 closeModal('exchange-confirm-modal');
  1949.                 showAlert('兑换成功!');
  1950.             } else {
  1951.                 closeModal('exchange-confirm-modal');
  1952.                 showAlert('积分不足!');
  1953.             }
  1954.         }
  1955.         
  1956.         // 显示补积分弹窗
  1957.         function showAddPointsModal() {
  1958.             // 设置默认日期为今天
  1959.             const today = new Date();
  1960.             const formattedDate = today.toISOString().split('T')[0];
  1961.             document.getElementById('add-points-date').value = formattedDate;
  1962.             document.getElementById('add-points-reason').value = '';
  1963.             document.getElementById('add-points-value').value = '';
  1964.             document.getElementById('add-points-modal').classList.add('show');
  1965.         }
  1966.         
  1967.         // 补积分
  1968.         function addPoints() {
  1969.             const reason = document.getElementById('add-points-reason').value.trim();
  1970.             const value = parseInt(document.getElementById('add-points-value').value);
  1971.             const dateStr = document.getElementById('add-points-date').value;
  1972.             
  1973.             if (!reason || isNaN(value) || !dateStr) {
  1974.                 showAlert('请填写完整信息');
  1975.                 return;
  1976.             }
  1977.             
  1978.             // 添加积分记录
  1979.             totalPoints += value;
  1980.             const recordTime = new Date(dateStr + 'T12:00:00').toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' });
  1981.             addRecord('补积分:' + reason, value, 'income', dateStr, recordTime);
  1982.             updatePointsDisplay();
  1983.             updateTodayPointsDisplay();
  1984.             saveData();
  1985.             
  1986.             // 关闭弹窗
  1987.             closeModal('add-points-modal');
  1988.             
  1989.             // 重新加载记录数据
  1990.             loadRecordsData();
  1991.             
  1992.             showAlert('补积分成功!');
  1993.         }
  1994.         
  1995.         // 显示清空积分弹窗
  1996.         function showClearPointsModal() {
  1997.             document.getElementById('clear-points-modal').classList.add('show');
  1998.         }
  1999.         
  2000.         // 确认清空积分
  2001.         function confirmClearPoints() {
  2002.             totalPoints = 0;
  2003.             records = [];
  2004.             recordIdCounter = 0;
  2005.             updatePointsDisplay();
  2006.             updateTodayPointsDisplay();
  2007.             saveData();
  2008.             closeModal('clear-points-modal');
  2009.             loadCurrentPageData();
  2010.             showAlert('积分已清空!');
  2011.         }
  2012.         
  2013.         // 系统重置
  2014.         function systemReset() {
  2015.             if (!confirm('确定要系统重置吗?\n\n将清空所有积分、记录,恢复默认设置项。\n此操作不可恢复!')) return;
  2016.             totalPoints = 0;
  2017.             records = [];
  2018.             recordIdCounter = 0;
  2019.             earnItems = JSON.parse(JSON.stringify(DEFAULT_EARN_ITEMS));
  2020.             deductItems = JSON.parse(JSON.stringify(DEFAULT_DEDUCT_ITEMS));
  2021.             rewards = JSON.parse(JSON.stringify(DEFAULT_REWARDS));
  2022.             saveData();
  2023.             updatePointsDisplay();
  2024.             updateTodayPointsDisplay();
  2025.             closeModal('clear-points-modal');
  2026.             loadCurrentPageData();
  2027.             showAlert('系统已重置为默认状态');
  2028.         }
  2029.         
  2030.         // 确认删除
  2031.         function confirmDelete() {
  2032.             if (currentDeleteType === 'earn') {
  2033.                 earnItems = earnItems.filter(i => i.id !== currentDeleteItem);
  2034.                 loadEarnManageList();
  2035.             } else if (currentDeleteType === 'deduct') {
  2036.                 deductItems = deductItems.filter(i => i.id !== currentDeleteItem);
  2037.                 loadDeductManageList();
  2038.             } else if (currentDeleteType === 'reward') {
  2039.                 rewards = rewards.filter(r => r.id !== currentDeleteItem);
  2040.                 loadRewardManageList();
  2041.             }
  2042.             
  2043.             saveData();
  2044.             closeModal('delete-confirm-modal');
  2045.         }
  2046.         
  2047.         // 撤销记录
  2048.         function undoRecord(recordId) {
  2049.             const idx = records.findIndex(r => r.id === recordId);
  2050.             if (idx !== -1) {
  2051.                 totalPoints -= records[idx].amount;
  2052.                 records.splice(idx, 1);
  2053.                 updatePointsDisplay();
  2054.                 updateTodayPointsDisplay();
  2055.                 saveData();
  2056.                 loadDayRecords();
  2057.                 if (document.getElementById('records-page').classList.contains('active')) {
  2058.                     loadCurrentWeekGrid('records-week-grid', 'records-week-score-text');
  2059.                     loadHistoryWeeks();
  2060.                 }
  2061.             }
  2062.         }
  2063.         
  2064.         // 关闭弹窗
  2065.         function closeModal(modalId) {
  2066.             document.getElementById(modalId).classList.remove('show');
  2067.         }
  2068.         
  2069.         // 重载当前活动页面数据
  2070.         function loadCurrentPageData() {
  2071.             if (document.getElementById('home-page').classList.contains('active')) {
  2072.                 loadHomeData();
  2073.             } else if (document.getElementById('records-page').classList.contains('active')) {
  2074.                 loadRecordsData();
  2075.             }
  2076.         }
  2077.         
  2078.         // 点击弹窗外部关闭
  2079.         document.querySelectorAll('.modal').forEach(modal => {
  2080.             modal.addEventListener('click', function(e) {
  2081.                 if (e.target === this) {
  2082.                     this.classList.remove('show');
  2083.                 }
  2084.             });
  2085.         });
  2086.         
  2087.         // 初始化
  2088.         document.addEventListener('DOMContentLoaded', function() {
  2089.             initData();
  2090.             loadHomeData();
  2091.         });
  2092.     </script>
  2093. </body>
  2094. </html>
复制代码


评论1

迪龙娱乐Lv.6 发表于 2026-7-1 07:20:38 来自手机 | 查看全部 <
封装好了
https://www.pgyer.com/Pointssteward
回复

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 立即注册 微信登录

本版积分规则

您需要 登录 后才可以回复,轻松玩转社区,没有帐号?立即注册
快速回复
关灯 在本版发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表