account.uvue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <template>
  2. <view class="page-container">
  3. <!-- 1. 资产卡片区域 -->
  4. <view class="asset-card">
  5. <!-- 总资产 -->
  6. <view class="total-asset-section row-between">
  7. <text class="label">
  8. 我的资产(元)
  9. </text>
  10. <view class="amount-row row-start">
  11. <!-- 修复:确保 totalAsset 已定义 -->
  12. <text class="amount">
  13. {{ totalAsset }}
  14. </text>
  15. <u-icon type="eye" size="20" color="#333">
  16. </u-icon>
  17. </view>
  18. <!-- 修复:确保 refreshData 已定义 -->
  19. <view class="refresh-btn row-center" @click="refreshData">
  20. <u-icon type="refresh" size="18" color="#333">
  21. </u-icon>
  22. <text>
  23. 刷新
  24. </text>
  25. </view>
  26. </view>
  27. <!-- 累计收益 & 打车费 -->
  28. <view class="income-section row-start">
  29. <!-- 左侧:累计收益 -->
  30. <view class="income-item column">
  31. <view class="income-header row-start">
  32. <text class="income-label">
  33. 累计收益(元)
  34. </text>
  35. <u-icon type="help" size="16" color="#999">
  36. </u-icon>
  37. </view>
  38. <view class="income-main row-between">
  39. <!-- 修复:确保 cumulativeIncome 已定义 -->
  40. <text class="income-value">
  41. {{ cumulativeIncome }}
  42. </text>
  43. <!-- 修复:确保 handleWithdraw 已定义 -->
  44. <view class="withdraw-btn" @click="handleWithdraw('income')">
  45. 提现
  46. </view>
  47. </view>
  48. <view class="income-detail row-start">
  49. <view class="detail-item column-center">
  50. <text class="detail-label">
  51. 冻结(元)
  52. </text>
  53. <!-- 修复:确保 frozenIncome 已定义 -->
  54. <text class="detail-value">
  55. {{ frozenIncome }}
  56. </text>
  57. </view>
  58. <view class="divider">
  59. </view>
  60. <view class="detail-item column-center">
  61. <text class="detail-label">
  62. 可提现(元)
  63. </text>
  64. <text class="detail-value highlight">
  65. {{ availableIncome }}
  66. </text>
  67. </view>
  68. </view>
  69. </view>
  70. <!-- 右侧:打车费 -->
  71. <view class="income-item column">
  72. <view class="income-header row-start">
  73. <text class="income-label">
  74. 打车费(元)
  75. </text>
  76. <u-icon type="help" size="16" color="#999">
  77. </u-icon>
  78. </view>
  79. <view class="income-main row-between">
  80. <text class="income-value">
  81. {{ taxiFee }}
  82. </text>
  83. <view class="transfer-btn" @click="handleTransfer('taxi')">
  84. 转出
  85. </view>
  86. </view>
  87. <view class="income-detail row-start">
  88. <view class="detail-item column-center">
  89. <text class="detail-label">
  90. 冻结(元)
  91. </text>
  92. <text class="detail-value">
  93. {{ frozenTaxi }}
  94. </text>
  95. </view>
  96. <view class="divider">
  97. </view>
  98. <view class="detail-item column-center">
  99. <text class="detail-label">
  100. 可使用(元)
  101. </text>
  102. <text class="detail-value highlight">
  103. {{ availableTaxi }}
  104. </text>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. <!-- 提现记录入口 -->
  110. <view class="record-entry row-between" @click="viewWithdrawRecords">
  111. <text>
  112. 提现记录
  113. </text>
  114. <u-icon type="arrowright" size="16" color="#999">
  115. </u-icon>
  116. </view>
  117. </view>
  118. <!-- 2. 本月账单标题 -->
  119. <view class="bill-header row-between">
  120. <text class="bill-title">
  121. 本月账单
  122. </text>
  123. <text class="view-all" @click="viewAllBills">
  124. 查看全部
  125. </text>
  126. </view>
  127. <!-- 3. 账单列表 -->
  128. <view class="bill-list column">
  129. <view v-for="(bill, idx) in bills" :key="idx" class="bill-card column">
  130. <!-- 订单号行 -->
  131. <view class="order-id-row row-between">
  132. <text class="order-id">
  133. 订单号:{{ bill.orderId }}
  134. </text>
  135. <u-icon type="arrowright" size="16" color="#999">
  136. </u-icon>
  137. </view>
  138. <!-- 项目与金额 -->
  139. <view class="project-amount-row row-between">
  140. <text class="project-name">
  141. {{ bill.projectName }}
  142. </text>
  143. <text :class="['amount', bill.amount > 0 ? 'positive' : 'negative']">
  144. {{ bill.amount > 0 ? '+' : '' }}{{ Math.abs(bill.amount).toFixed(2) }}
  145. </text>
  146. </view>
  147. <!-- 分成说明 -->
  148. <view class="split-info column">
  149. <text class="split-type">
  150. {{ bill.splitType }}
  151. </text>
  152. <text class="split-detail">
  153. {{ bill.splitDetail }}
  154. </text>
  155. </view>
  156. <!-- 记录时间 -->
  157. <view class="time-row row-between">
  158. <text class="time-label">
  159. 记录时间
  160. </text>
  161. <text class="time-value">
  162. {{ bill.recordTime }}
  163. </text>
  164. </view>
  165. </view>
  166. </view>
  167. </view>
  168. </template>
  169. <script setup lang="uts">
  170. import { ref } from 'vue';
  171. // --- 数据定义 ---
  172. const totalAsset = ref('1978.2');
  173. const cumulativeIncome = ref('1889');
  174. const frozenIncome = ref('1000');
  175. const availableIncome = ref('889');
  176. const taxiFee = ref('89.2');
  177. const frozenTaxi = ref('50');
  178. const availableTaxi = ref('49.2');
  179. // ✅ 修复点 1: 定义类型 (可以用 interface 或 type)
  180. type BillItem = {
  181. orderId : string;
  182. projectName : string;
  183. amount : number;
  184. splitType : string;
  185. splitDetail : string;
  186. recordTime : string;
  187. };
  188. // ✅ 修复点 2: 初始化时不写泛型 <BillItem[]>,让 TS 自动推断
  189. // 或者写成: const bills = ref<BillItem[]>([]); 然后单独 push,但直接推断最方便
  190. const bills = ref([
  191. {
  192. orderId: '202506091311123009874638',
  193. projectName: '中式推拿',
  194. amount: 170.00,
  195. splitType: '首单分成',
  196. splitDetail: '基本套餐车费收入 x90%=20\n项目套餐收入 x50%=150',
  197. recordTime: '2025-06-09 13:58'
  198. },
  199. {
  200. orderId: '202506091311123009874638',
  201. projectName: '中式推拿',
  202. amount: 150.00,
  203. splitType: '加钟分成',
  204. splitDetail: '项目套餐收入 x71%+(70%+等级v1)=150',
  205. recordTime: '2025-06-09 13:58'
  206. },
  207. {
  208. orderId: '202506091311123009874638',
  209. projectName: '中式推拿订单退款',
  210. amount: -150.00,
  211. splitType: '首单分成',
  212. splitDetail: '基本套餐车费收入 x90%=20\n项目套餐收入 x50%=150',
  213. recordTime: '2025-06-09 13:58'
  214. },
  215. {
  216. orderId: '',
  217. projectName: '打车费转出',
  218. amount: -50.00,
  219. splitType: '分成',
  220. splitDetail: '打车费转出刘大锤账户:45.00元\n费率:0.1 手续费:5.00元',
  221. recordTime: '2025-06-09 13:58'
  222. }
  223. ] as BillItem[]); // 如果自动推断不准,可以在末尾加 'as BillItem[]' 进行断言
  224. // --- 方法定义 ---
  225. const refreshData = () => {
  226. uni.showLoading({ title: '刷新中...' });
  227. setTimeout(() => {
  228. uni.hideLoading();
  229. uni.showToast({ title: '刷新成功', icon: 'success' });
  230. totalAsset.value = (parseFloat(totalAsset.value) + 0.1).toFixed(1);
  231. }, 800);
  232. };
  233. const handleWithdraw = (type : string) => {
  234. const amount = type === 'income' ? availableIncome.value : '0';
  235. uni.showModal({
  236. title: '提现确认',
  237. content: `确定要提现 ${amount} 元吗?`,
  238. success: (res) => {
  239. if (res.confirm) {
  240. uni.showToast({ title: '提现申请已提交', icon: 'success' });
  241. }
  242. }
  243. });
  244. };
  245. const handleTransfer = (type : string) => {
  246. uni.showModal({
  247. title: '转出确认',
  248. content: '确定要将打车费转出到其他账户吗?',
  249. success: (res) => {
  250. if (res.confirm) {
  251. uni.showToast({ title: '转出成功', icon: 'success' });
  252. }
  253. }
  254. });
  255. };
  256. const viewWithdrawRecords = () => {
  257. uni.showToast({ title: '查看提现记录', icon: 'none' });
  258. };
  259. const viewAllBills = () => {
  260. uni.showToast({ title: '查看全部账单', icon: 'none' });
  261. };
  262. </script>
  263. <style>
  264. /*
  265. ⚠️ UniApp X 样式规范:
  266. 1. 不写 display: flex (view 默认就是)
  267. 2. 不写 display: block/inline-block
  268. 3. 布局靠 flex-direction (默认 column, 需 row 时手动改)
  269. 4. 不写 border-radius: 50% (用具体数值)
  270. 5. 只用类名选择器
  271. */
  272. /* --- 辅助布局类 (核心) --- */
  273. .row-between {
  274. flex-direction: row;
  275. justify-content: space-between;
  276. align-items: center;
  277. }
  278. .row-start {
  279. flex-direction: row;
  280. align-items: center;
  281. /* gap: 10rpx; */
  282. }
  283. .row-center {
  284. flex-direction: row;
  285. justify-content: center;
  286. align-items: center;
  287. }
  288. .column {
  289. flex-direction: column;
  290. }
  291. .column-center {
  292. flex-direction: column;
  293. justify-content: center;
  294. align-items: center;
  295. }
  296. /* --- 页面容器 --- */
  297. .page-container {
  298. background-color: #f5f6f8;
  299. /* min-height: 100vh; */
  300. padding-bottom: 40rpx;
  301. }
  302. /* --- 资产卡片 --- */
  303. .asset-card {
  304. background: linear-gradient(180deg, #fff9e6 0%, #ffeaa7 100%);
  305. margin: 20rpx;
  306. border-radius: 16rpx;
  307. padding: 30rpx;
  308. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
  309. }
  310. .total-asset-section {
  311. margin-bottom: 30rpx;
  312. }
  313. .label {
  314. font-size: 26rpx;
  315. color: #666;
  316. }
  317. .amount-row {
  318. /* gap: 10rpx; */
  319. }
  320. .amount {
  321. font-size: 48rpx;
  322. font-weight: bold;
  323. color: #333;
  324. }
  325. .refresh-btn {
  326. padding: 10rpx 20rpx;
  327. background: #ffffff;
  328. border-radius: 30rpx;
  329. border: 1rpx solid #ddd;
  330. font-size: 24rpx;
  331. color: #333;
  332. }
  333. /* 收益分区 */
  334. .income-section {
  335. /* gap: 30rpx; */
  336. margin-bottom: 20rpx;
  337. }
  338. .income-item {
  339. flex: 1;
  340. /* gap: 15rpx; */
  341. }
  342. .income-label {
  343. font-size: 24rpx;
  344. color: #666;
  345. }
  346. .income-main {
  347. /* 继承 row-between */
  348. }
  349. .income-value {
  350. font-size: 40rpx;
  351. font-weight: bold;
  352. color: #333;
  353. }
  354. .withdraw-btn,
  355. .transfer-btn {
  356. font-size: 24rpx;
  357. padding: 8rpx 20rpx;
  358. border-radius: 20rpx;
  359. background: #ffffff;
  360. border: 1rpx solid;
  361. }
  362. .withdraw-btn {
  363. color: #ff9900;
  364. border-color: #ff9900;
  365. }
  366. .transfer-btn {
  367. color: #52c41a;
  368. border-color: #52c41a;
  369. }
  370. /* 明细部分 */
  371. .income-detail {
  372. background: rgba(255, 255, 255, 0.6);
  373. border-radius: 12rpx;
  374. padding: 15rpx;
  375. /* gap: 20rpx; */
  376. }
  377. .detail-item {
  378. flex: 1;
  379. /* gap: 4rpx; */
  380. }
  381. .detail-label {
  382. font-size: 22rpx;
  383. color: #999;
  384. }
  385. .detail-value {
  386. font-size: 28rpx;
  387. font-weight: bold;
  388. color: #333;
  389. }
  390. .detail-value.highlight {
  391. color: #ff9900;
  392. }
  393. .divider {
  394. width: 1rpx;
  395. background: #ddd;
  396. margin: 0 10rpx;
  397. }
  398. /* 提现记录入口 */
  399. .record-entry {
  400. padding: 20rpx 0;
  401. border-top: 1rpx solid rgba(0, 0, 0, 0.05);
  402. font-size: 28rpx;
  403. color: #333;
  404. }
  405. /* --- 账单标题 --- */
  406. .bill-header {
  407. padding: 20rpx 30rpx;
  408. margin-top: 20rpx;
  409. }
  410. .bill-title {
  411. font-size: 32rpx;
  412. font-weight: bold;
  413. color: #333;
  414. }
  415. .view-all {
  416. font-size: 26rpx;
  417. color: #666;
  418. }
  419. /* --- 账单列表 --- */
  420. .bill-list {
  421. padding: 0 20rpx;
  422. /* gap: 20rpx; */
  423. }
  424. .bill-card {
  425. background: #ffffff;
  426. border-radius: 16rpx;
  427. padding: 30rpx;
  428. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
  429. /* gap: 15rpx; */
  430. }
  431. .order-id-row {
  432. font-size: 26rpx;
  433. color: #666;
  434. }
  435. .project-amount-row {
  436. /* 继承 row-between */
  437. }
  438. .project-name {
  439. font-size: 30rpx;
  440. font-weight: bold;
  441. color: #333;
  442. }
  443. .amount.positive {
  444. color: #ff4d4f;
  445. font-size: 32rpx;
  446. font-weight: bold;
  447. }
  448. .amount.negative {
  449. color: #333;
  450. font-size: 32rpx;
  451. font-weight: bold;
  452. }
  453. .split-info {
  454. font-size: 24rpx;
  455. color: #999;
  456. line-height: 1.4;
  457. }
  458. .split-type {
  459. font-weight: 400;
  460. color: #666;
  461. }
  462. .time-row {
  463. font-size: 24rpx;
  464. color: #999;
  465. }
  466. </style>