HaniBlindBox/.kiro/specs/frontend-api-refactor/tasks.md
2026-01-03 17:01:19 +08:00

8.4 KiB

Implementation Plan: Frontend API Refactor

Overview

将前端 API 调用从分散的 this.req()RequestManager.post() 模式重构为集中的 Server Module 模式。改造过程中记录所有 API 地址,生成接口清单用于核对 C# 后端迁移完整性。

Tasks

  • 1. 修改 RequestManager 请求格式

    • 1.1 修改 POST 请求 Content-Type 为 application/json
      • 修改 honey_box/common/request.js 第 166 行
      • 'content-type': 'application/x-www-form-urlencoded' 改为 'content-type': 'application/json'
      • Requirements: 1.1
  • 2. 创建 Server Modules

    • 2.1 创建 auth.js 认证模块
      • 创建 honey_box/common/server/auth.js
      • 实现: wxLogin, mobileLogin, bindMobileByWx, bindMobileByCode, recordLogin, logOff
      • Requirements: 2.1, 2.2, 2.3
    • 2.2 扩展 user.js 用户模块
      • 修改 honey_box/common/server/user.js
      • 新增: updateUserInfo, getVipList, getProfitMoney, getProfitIntegral, getProfitScore, getProfitPay
      • Requirements: 2.1, 2.2, 2.3
    • 2.3 创建 goods.js 商品模块
      • 创建 honey_box/common/server/goods.js
      • 实现: getGoodsList, getGoodsDetail, getGoodsChildren, getGoodsExtend, getGoodsNumList, getGoodsNumDetail, getGoodsPrizeCount, getGoodsPrizeContent, getGoodsPrizeLogs
      • Requirements: 2.1, 2.2, 2.3
    • 2.4 扩展 order.js 订单模块
      • 修改 honey_box/common/server/order.js
      • 新增: calcOrderMoney, createOrder, calcInfiniteOrderMoney, createInfiniteOrder, calcMallOrderMoney, getOrderList, getOrderDetail, getPrizeOrderLog, getInfinitePrizeOrderLog, useItemCard
      • Requirements: 2.1, 2.2, 2.3
    • 2.5 创建 warehouse.js 仓库模块
      • 创建 honey_box/common/server/warehouse.js
      • 实现: getWarehouseIndex, recoveryPrize, sendPrize, confirmSend, getSendRecord, getSendRecordDetail, getRecoveryRecord, getLogistics
      • Requirements: 2.1, 2.2, 2.3
    • 2.6 创建 coupon.js 优惠券模块
      • 创建 honey_box/common/server/coupon.js
      • 实现: getCouponList, getCouponDetail, receiveCoupon, shareCoupon, synthesisCoupon, calcSynthesis
      • Requirements: 2.1, 2.2, 2.3
    • 2.7 创建 welfare.js 福利模块
      • 创建 honey_box/common/server/welfare.js
      • 实现: getWelfareHouseList, getWelfareHouseDetail, buyWelfareHouse, getSignInfo, doSign, getTaskList, receiveTaskReward
      • Requirements: 2.1, 2.2, 2.3
    • 2.8 创建 collection.js 收藏模块
      • 创建 honey_box/common/server/collection.js
      • 实现: getCollectionList, addCollection, cancelCollection, getCollectionStatus
      • Requirements: 2.1, 2.2, 2.3
    • 2.9 创建 rank.js 排行榜模块
      • 创建 honey_box/common/server/rank.js
      • 实现: getRankList
      • Requirements: 2.1, 2.2, 2.3
    • 2.10 创建 invitation.js 邀请模块
      • 创建 honey_box/common/server/invitation.js
      • 实现: getInvitationInfo, getInvitationRecord
      • Requirements: 2.1, 2.2, 2.3
    • 2.11 创建 redeem.js 兑换码模块
      • 创建 honey_box/common/server/redeem.js
      • 实现: useRedeemCode
      • Requirements: 2.1, 2.2, 2.3
    • 2.12 创建 pay.js 支付模块
      • 创建 honey_box/common/server/pay.js
      • 实现: wxPay, balancePay, recharge
      • Requirements: 2.1, 2.2, 2.3
  • 3. Checkpoint - Server Modules 完成

    • 确保所有 Server Module 创建完成
    • 检查函数命名是否语义化
    • 确认错误处理逻辑一致
  • 4. 重构页面接口调用 - shouye 模块

    • 4.1 重构 pages/shouye/index.vue
      • 替换 this.req() 调用为 Server Module 导入
      • 记录使用的 API 地址到清单
      • Requirements: 3.1, 3.2, 3.3, 3.4
    • 4.2 重构 pages/shouye/detail.vue
      • 替换 this.req() 调用为 Server Module 导入
      • 记录使用的 API 地址到清单
      • Requirements: 3.1, 3.2, 3.3, 3.4
    • 4.3 重构 pages/shouye/detail_wuxian.vue
      • 替换 this.req() 调用为 Server Module 导入
      • 记录使用的 API 地址到清单
      • Requirements: 3.1, 3.2, 3.3, 3.4
    • 4.4 重构 pages/shouye 其他页面
      • 包括: bangdan.vue, ranking.vue, dada_ranking.vue, yaoqing_ranking.vue, rili.vue, danye.vue, huanxiang.vue, slots.vue
      • 记录使用的 API 地址到清单
      • Requirements: 3.1, 3.2, 3.3, 3.4
  • 5. 重构页面接口调用 - user 模块

    • 5.1 重构 pages/user/login.vue
      • 替换登录相关接口调用
      • 记录使用的 API 地址到清单
      • Requirements: 3.1, 3.2, 3.3, 3.4
    • 5.2 重构 pages/user/index.vue
      • 替换用户信息相关接口调用
      • 记录使用的 API 地址到清单
      • Requirements: 3.1, 3.2, 3.3, 3.4
    • 5.3 重构 pages/user 其他页面
      • 包括: bangding.vue, bangdingweb.vue, vip.vue, coupon.vue, my_coupon.vue, order.vue, myCa.vue, change.vue, bi_jl.vue, jf_jl.vue, xfjl.vue, fhjl.vue, hsjl.vue, tui-guang.vue, yetx.vue, recharge-page.vue, cancel-account-page.vue, wuliu_detail.vue
      • 记录使用的 API 地址到清单
      • Requirements: 3.1, 3.2, 3.3, 3.4
  • 6. 重构页面接口调用 - other 模块

    • 6.1 重构 pages/other 所有页面
      • 包括: about.vue, address_edit.vue, choose_address.vue, order_info.vue, order_list.vue, prize_draw.vue, web-detail-lucky.vue, web-pay-order.vue, web-pay-success.vue
      • 记录使用的 API 地址到清单
      • Requirements: 3.1, 3.2, 3.3, 3.4
  • 7. 重构页面接口调用 - 其他模块

    • 7.1 重构 pages/mall/index.vue
      • 替换商城相关接口调用
      • 记录使用的 API 地址到清单
      • Requirements: 3.1, 3.2, 3.3, 3.4
    • 7.2 重构 pages/infinite 所有页面
      • 包括: index.vue, benefit.vue, bonus_house.vue, bonus_house_details.vue, daily_check_in.vue, reward_records.vue
      • 记录使用的 API 地址到清单
      • Requirements: 3.1, 3.2, 3.3, 3.4
    • 7.3 重构 pages/hegui/hegui.vue
      • 替换盒柜相关接口调用
      • 记录使用的 API 地址到清单
      • Requirements: 3.1, 3.2, 3.3, 3.4
    • 7.4 重构 pages/guize/guize.vue
      • 替换规则相关接口调用
      • 记录使用的 API 地址到清单
      • Requirements: 3.1, 3.2, 3.3, 3.4
  • 8. 重构 package 分包页面

    • 8.1 重构 package/index 所有页面
      • 包括: coupon-center.vue, leitai.vue, lian-ji.vue, sign.vue
      • 记录使用的 API 地址到清单
      • Requirements: 3.1, 3.2, 3.3, 3.4
    • 8.2 重构 package/mine 所有页面
      • 包括: collect.vue, coupon-detail.vue, equity.vue, qy-rule.vue, skill-card.vue, ti-qu.vue
      • 记录使用的 API 地址到清单
      • Requirements: 3.1, 3.2, 3.3, 3.4
  • 9. Checkpoint - 页面重构完成

    • 确保所有页面不再使用 this.req() 硬编码 URL
    • 检查 API 地址清单完整性
  • 10. 重构组件接口调用

    • 10.1 重构 components/detail-lucky 组件
      • 包括: detail-lucky.vue, detail-lucky-canvas.vue, detail-lucky-web.vue, detail-bao-xiang.vue, detail-grand-prize.vue
      • 记录使用的 API 地址到清单
      • Requirements: 4.1, 4.2, 4.3, 4.4
    • 10.2 重构 components/pay-dialog/pay-dialog.vue
      • 替换支付相关接口调用
      • 记录使用的 API 地址到清单
      • Requirements: 4.1, 4.2, 4.3, 4.4
    • 10.3 重构 components/order-confirm-popup 组件
      • 包括: order-confirm-popup.vue, order-confirm-popup-flw.vue
      • 记录使用的 API 地址到清单
      • Requirements: 4.1, 4.2, 4.3, 4.4
    • 10.4 重构其他使用接口的组件
      • 检查并重构: collect-btn, coupon-pop, detail-toolbar, detail-wuxian-lingzhu, detail-wuxian-rage 等
      • 记录使用的 API 地址到清单
      • Requirements: 4.1, 4.2, 4.3, 4.4
  • 11. 生成接口清单文档

    • 11.1 创建 API 接口清单文档
      • 创建 docs/前端适配调整/API接口清单.md
      • 记录所有 API URL、所属模块、请求方式、使用位置
      • Requirements: 5.1, 5.2, 5.3, 5.5
    • 11.2 标注 C# 后端迁移状态
      • 对照 C# 后端代码,标注每个接口的迁移状态
      • 列出未迁移的接口清单
      • Requirements: 5.4
  • 12. Final Checkpoint - 功能验证

    • 确保所有功能正常工作
    • 验证错误提示正确显示
    • 验证登录跳转正常
    • 验证绑定手机号跳转正常
    • Requirements: 6.1, 6.2, 6.3, 6.4

Notes

  • 每个任务完成后需记录该文件使用的 API 地址
  • 重构时保持原有业务逻辑不变
  • 如发现未迁移的接口,记录到清单中
  • 建议按模块逐一测试,确保功能正常