account.uvue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  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 walletInfo = ref<UTSJSONObject | null>(null)
  226. const httpGetWalletInfo = async () => {
  227. try {
  228. const res = await getCoachWallteInfo() as UTSJSONObject;
  229. const code = res["code"] as number;
  230. const data = res["data"] as UTSJSONObject;
  231. if (code === 200) {
  232. walletInfo.value = data;
  233. } else {
  234. uni.showToast({
  235. title: '获取钱包信息失败',
  236. icon: 'none'
  237. });
  238. }
  239. } catch (err: any) {
  240. console.error('获取技师钱包信息异常', err);
  241. uni.showToast({
  242. title: '请求失败',
  243. icon: 'none'
  244. });
  245. }
  246. };
  247. // 获取本月账单接口
  248. const billRecords = ref<any[]>([]);
  249. const httpGetBillRecords = async (params = {}) => {
  250. try {
  251. const res = await getCoachTransRecords(params) as UTSJSONObject;
  252. const code = res["code"] as number;
  253. const data = res["data"] as any[];
  254. if (code === 200 && Array.isArray(data)) {
  255. billRecords.value = data;
  256. } else {
  257. uni.showToast({
  258. title: '获取本月账单失败',
  259. icon: 'none'
  260. });
  261. }
  262. } catch (err: any) {
  263. console.error('获取本月账单异常', err);
  264. uni.showToast({
  265. title: '请求失败,请稍后重试',
  266. icon: 'none'
  267. });
  268. }
  269. };
  270. const refreshData = () => {
  271. uni.showLoading({ title: '刷新中...' });
  272. setTimeout(() => {
  273. uni.hideLoading();
  274. uni.showToast({ title: '刷新成功', icon: 'success' });
  275. totalAsset.value = (parseFloat(totalAsset.value) + 0.1).toFixed(1);
  276. }, 800);
  277. };
  278. const handleWithdraw = (type : string) => {
  279. const amount = type === 'income' ? availableIncome.value : '0';
  280. uni.showModal({
  281. title: '提现确认',
  282. content: `确定要提现 ${amount} 元吗?`,
  283. success: (res) => {
  284. if (res.confirm) {
  285. uni.showToast({ title: '提现申请已提交', icon: 'success' });
  286. }
  287. }
  288. });
  289. };
  290. const handleTransfer = (type : string) => {
  291. uni.showModal({
  292. title: '转出确认',
  293. content: '确定要将打车费转出到其他账户吗?',
  294. success: (res) => {
  295. if (res.confirm) {
  296. uni.showToast({ title: '转出成功', icon: 'success' });
  297. }
  298. }
  299. });
  300. };
  301. const viewWithdrawRecords = () => {
  302. uni.showToast({ title: '查看提现记录', icon: 'none' });
  303. };
  304. const viewAllBills = () => {
  305. uni.showToast({ title: '查看全部账单', icon: 'none' });
  306. };
  307. </script>
  308. <style>
  309. /*
  310. ⚠️ UniApp X 样式规范:
  311. 1. 不写 display: flex (view 默认就是)
  312. 2. 不写 display: block/inline-block
  313. 3. 布局靠 flex-direction (默认 column, 需 row 时手动改)
  314. 4. 不写 border-radius: 50% (用具体数值)
  315. 5. 只用类名选择器
  316. */
  317. /* --- 辅助布局类 (核心) --- */
  318. .row-between {
  319. flex-direction: row;
  320. justify-content: space-between;
  321. align-items: center;
  322. }
  323. .row-start {
  324. flex-direction: row;
  325. align-items: center;
  326. /* gap: 10rpx; */
  327. }
  328. .row-center {
  329. flex-direction: row;
  330. justify-content: center;
  331. align-items: center;
  332. }
  333. .column {
  334. flex-direction: column;
  335. }
  336. .column-center {
  337. flex-direction: column;
  338. justify-content: center;
  339. align-items: center;
  340. }
  341. /* --- 页面容器 --- */
  342. .page-container {
  343. background-color: #f5f6f8;
  344. /* */
  345. padding-bottom: 40rpx;
  346. }
  347. /* --- 资产卡片 --- */
  348. .asset-card {
  349. background: linear-gradient(to right, rgba(255, 249, 225, 1), rgba(255, 241, 191, 1));
  350. margin: 20rpx;
  351. border-radius: 16rpx;
  352. padding: 30rpx;
  353. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
  354. }
  355. .total-asset-section {
  356. margin-bottom: 30rpx;
  357. }
  358. .label {
  359. font-size: 26rpx;
  360. color: #666;
  361. }
  362. .amount-row {
  363. /* gap: 10rpx; */
  364. }
  365. .amount {
  366. font-size: 48rpx;
  367. font-weight: bold;
  368. color: #333;
  369. }
  370. .refresh-btn {
  371. padding: 10rpx 20rpx;
  372. background: #ffffff;
  373. border-radius: 30rpx;
  374. border: 1rpx solid #ddd;
  375. font-size: 24rpx;
  376. color: #333;
  377. }
  378. /* 收益分区 */
  379. .income-section {
  380. /* gap: 30rpx; */
  381. margin-bottom: 20rpx;
  382. }
  383. .income-item {
  384. flex: 1;
  385. /* gap: 15rpx; */
  386. }
  387. .income-label {
  388. font-size: 24rpx;
  389. color: #666;
  390. }
  391. .income-main {
  392. /* 继承 row-between */
  393. }
  394. .income-value {
  395. font-size: 40rpx;
  396. font-weight: bold;
  397. color: #333;
  398. }
  399. .withdraw-btn,
  400. .transfer-btn {
  401. font-size: 24rpx;
  402. padding: 8rpx 20rpx;
  403. border-radius: 20rpx;
  404. background: #ffffff;
  405. border: 1rpx solid;
  406. }
  407. .withdraw-btn {
  408. color: #ff9900;
  409. border-color: #ff9900;
  410. }
  411. .transfer-btn {
  412. color: #52c41a;
  413. border-color: #52c41a;
  414. }
  415. /* 明细部分 */
  416. .income-detail {
  417. background: rgba(255, 255, 255, 0.6);
  418. border-radius: 12rpx;
  419. padding: 15rpx;
  420. /* gap: 20rpx; */
  421. }
  422. .detail-item {
  423. flex: 1;
  424. /* gap: 4rpx; */
  425. }
  426. .detail-label {
  427. font-size: 22rpx;
  428. color: #999;
  429. }
  430. .detail-value {
  431. font-size: 28rpx;
  432. font-weight: bold;
  433. color: #333;
  434. }
  435. .detail-value.highlight {
  436. color: #ff9900;
  437. }
  438. .divider {
  439. width: 1rpx;
  440. background: #ddd;
  441. margin: 0 10rpx;
  442. }
  443. /* 提现记录入口 */
  444. .record-entry {
  445. padding: 20rpx 0;
  446. border-top: 1rpx solid rgba(0, 0, 0, 0.05);
  447. font-size: 28rpx;
  448. color: #333;
  449. }
  450. /* --- 账单标题 --- */
  451. .bill-header {
  452. padding: 20rpx 30rpx;
  453. margin-top: 20rpx;
  454. }
  455. .bill-title {
  456. font-size: 32rpx;
  457. font-weight: bold;
  458. color: #333;
  459. }
  460. .view-all {
  461. font-size: 26rpx;
  462. color: #666;
  463. }
  464. /* --- 账单列表 --- */
  465. .bill-list {
  466. padding: 0 20rpx;
  467. /* gap: 20rpx; */
  468. }
  469. .bill-card {
  470. background: #ffffff;
  471. border-radius: 16rpx;
  472. padding: 30rpx;
  473. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
  474. /* gap: 15rpx; */
  475. }
  476. .order-id-row {
  477. font-size: 26rpx;
  478. color: #666;
  479. }
  480. .project-amount-row {
  481. /* 继承 row-between */
  482. }
  483. .project-name {
  484. font-size: 30rpx;
  485. font-weight: bold;
  486. color: #333;
  487. }
  488. .amount.positive {
  489. color: #ff4d4f;
  490. font-size: 32rpx;
  491. font-weight: bold;
  492. }
  493. .amount.negative {
  494. color: #333;
  495. font-size: 32rpx;
  496. font-weight: bold;
  497. }
  498. .split-info {
  499. font-size: 24rpx;
  500. color: #999;
  501. line-height: 1.4;
  502. }
  503. .split-type {
  504. font-weight: 400;
  505. color: #666;
  506. }
  507. .time-row {
  508. font-size: 24rpx;
  509. color: #999;
  510. }
  511. </style>