bill.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <view class="container">
  3. <!-- 导航栏 -->
  4. <view class="nav-bar">
  5. <view class="nav-left" @click="navBack">
  6. <image class="back-icon" src="/static/icons/chevron_right_dark.svg"></image>
  7. </view>
  8. <text class="nav-title">账单明细</text>
  9. <view class="nav-right"></view>
  10. </view>
  11. <!-- 内容区域 -->
  12. <view class="content-area">
  13. <!-- Tabs -->
  14. <view class="tabs-row">
  15. <view class="tab-item" :class="{ active: currentTab === 0 }" @click="switchTab(0)">
  16. <text>全部</text>
  17. <view class="tab-line" v-if="currentTab === 0"></view>
  18. </view>
  19. <view class="tab-item" :class="{ active: currentTab === 1 }" @click="switchTab(1)">
  20. <text>收入</text>
  21. <view class="tab-line" v-if="currentTab === 1"></view>
  22. </view>
  23. <view class="tab-item" :class="{ active: currentTab === 2 }" @click="switchTab(2)">
  24. <text>支出</text>
  25. <view class="tab-line" v-if="currentTab === 2"></view>
  26. </view>
  27. </view>
  28. <!-- 账单列表 -->
  29. <scroll-view scroll-y class="bill-list">
  30. <view v-for="(group, gIndex) in displayGroups" :key="gIndex" class="month-group">
  31. <!-- 月份头 -->
  32. <view class="group-header">
  33. <text class="month-title">{{ group.month }}</text>
  34. <text class="month-summary">收入 ¥{{ group.income }} 支出 ¥{{ group.expense }}</text>
  35. </view>
  36. <!-- 列表项 -->
  37. <view class="list-item" v-for="(item, index) in group.items" :key="index">
  38. <!-- 图标 -->
  39. <view class="item-icon-box" :class="item.type">
  40. <text class="item-icon-symbol">{{ item.type === 'income' ? '+' : '-' }}</text>
  41. </view>
  42. <!-- 中间内容 -->
  43. <view class="item-center">
  44. <text class="item-title">{{ item.title }}</text>
  45. <text class="item-desc">{{ item.time }} {{ item.desc }}</text>
  46. </view>
  47. <!-- 右侧数据 -->
  48. <view class="item-right">
  49. <text class="item-amount" :class="{ income: item.type === 'income', expense: item.type === 'expense' }">
  50. {{ item.type === 'income' ? '+' : '' }}{{ item.amount }}
  51. </text>
  52. <view class="item-tag">
  53. <text>{{ item.tag }}</text>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="list-padding-bottom"></view>
  59. </scroll-view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. export default {
  65. data() {
  66. return {
  67. currentTab: 0,
  68. // 模拟数据结构
  69. groups: [
  70. {
  71. month: '2月 2026',
  72. income: '35.00',
  73. expense: '10.00',
  74. items: [
  75. {
  76. title: '订单服务费用',
  77. desc: '订单完成',
  78. time: '02-03 14:30',
  79. amount: '20.00',
  80. type: 'income',
  81. tag: '订单'
  82. },
  83. {
  84. title: '奖励费用',
  85. desc: '早高峰奖励', // shortened to match ui better
  86. time: '02-03 10:00',
  87. amount: '15.00',
  88. type: 'income',
  89. tag: '奖励'
  90. },
  91. {
  92. title: '惩罚金额',
  93. desc: '超时送达',
  94. time: '02-02 18:20',
  95. amount: '-10.00',
  96. type: 'expense',
  97. tag: '惩罚'
  98. }
  99. ]
  100. },
  101. {
  102. month: '1月 2026',
  103. income: '3500.00',
  104. expense: '100.00',
  105. items: [
  106. {
  107. title: '后台转账',
  108. desc: '1月工资发放',
  109. time: '01-31 09:00',
  110. amount: '3500.00',
  111. type: 'income',
  112. tag: '工资'
  113. },
  114. {
  115. title: '装备扣款',
  116. desc: '装备费用',
  117. time: '01-15 10:00',
  118. amount: '-100.00',
  119. type: 'expense',
  120. tag: '扣款'
  121. }
  122. ]
  123. }
  124. ]
  125. }
  126. },
  127. computed: {
  128. displayGroups() {
  129. if (this.currentTab === 0) return this.groups;
  130. return this.groups.map(group => {
  131. const filteredItems = group.items.filter(item => {
  132. const type = this.currentTab === 1 ? 'income' : 'expense';
  133. return item.type === type;
  134. });
  135. return {
  136. ...group,
  137. items: filteredItems
  138. };
  139. }).filter(group => group.items.length > 0);
  140. }
  141. },
  142. methods: {
  143. navBack() {
  144. uni.navigateBack();
  145. },
  146. switchTab(index) {
  147. this.currentTab = index;
  148. }
  149. }
  150. }
  151. </script>
  152. <style>
  153. /* 基础容器 */
  154. .container {
  155. background-color: #F5F7FA;
  156. min-height: 100vh;
  157. display: flex;
  158. flex-direction: column;
  159. }
  160. /* 导航栏 */
  161. .nav-bar {
  162. background-color: #fff;
  163. padding-top: var(--status-bar-height);
  164. padding-left: 30rpx;
  165. padding-right: 30rpx;
  166. height: 88rpx;
  167. box-sizing: content-box;
  168. display: flex;
  169. justify-content: space-between;
  170. align-items: center;
  171. position: sticky;
  172. top: 0;
  173. z-index: 100;
  174. }
  175. .nav-left {
  176. height: 100%;
  177. display: flex;
  178. align-items: center;
  179. width: 60rpx;
  180. }
  181. .back-icon {
  182. width: 40rpx;
  183. height: 40rpx;
  184. transform: rotate(180deg);
  185. }
  186. .nav-title {
  187. font-size: 28rpx; /* 14pt (Strictly enforced) */
  188. font-weight: bold;
  189. color: #333;
  190. }
  191. .nav-right {
  192. width: 60rpx;
  193. }
  194. /* 内容区域 */
  195. .content-area {
  196. flex: 1;
  197. display: flex;
  198. flex-direction: column;
  199. }
  200. /* Tabs */
  201. .tabs-row {
  202. background-color: #fff;
  203. display: flex;
  204. justify-content: space-around; /* Match Figure 1 spacing */
  205. padding-top: 20rpx;
  206. padding-bottom: 2rpx;
  207. margin-bottom: 20rpx;
  208. }
  209. .tab-item {
  210. padding-bottom: 16rpx;
  211. font-size: 28rpx;
  212. color: #666;
  213. position: relative;
  214. display: flex;
  215. flex-direction: column;
  216. align-items: center;
  217. min-width: 100rpx;
  218. }
  219. .tab-item.active {
  220. font-weight: bold;
  221. color: #FF6B00; /* Orange text for active */
  222. }
  223. .tab-line {
  224. width: 40rpx; /* Little wider line */
  225. height: 4rpx;
  226. background-color: #FF6B00;
  227. border-radius: 4rpx;
  228. position: absolute;
  229. bottom: 0;
  230. }
  231. /* 列表容器 */
  232. .bill-list {
  233. flex: 1;
  234. padding: 0 20rpx;
  235. box-sizing: border-box;
  236. }
  237. /* 月份卡片 */
  238. .month-group {
  239. background-color: #fff;
  240. border-radius: 16rpx;
  241. padding: 0 20rpx;
  242. margin-bottom: 20rpx;
  243. box-shadow: 0 2rpx 6rpx rgba(0,0,0,0.02);
  244. }
  245. .group-header {
  246. display: flex;
  247. justify-content: space-between;
  248. align-items: center;
  249. padding: 24rpx 10rpx;
  250. /* No border bottom for header in card view usually, or light one */
  251. border-bottom: 1rpx solid #f9f9f9;
  252. }
  253. .month-title {
  254. font-size: 30rpx;
  255. font-weight: bold;
  256. color: #333;
  257. }
  258. .month-summary {
  259. font-size: 24rpx;
  260. color: #999;
  261. }
  262. /* 列表项 */
  263. .list-item {
  264. display: flex;
  265. align-items: center;
  266. padding: 30rpx 10rpx;
  267. border-bottom: 1rpx solid #f9f9f9;
  268. }
  269. .list-item:last-child {
  270. border-bottom: none;
  271. }
  272. /* 左侧图标 */
  273. .item-icon-box {
  274. width: 80rpx;
  275. height: 80rpx;
  276. border-radius: 50%;
  277. display: flex;
  278. justify-content: center;
  279. align-items: center;
  280. margin-right: 20rpx;
  281. flex-shrink: 0;
  282. }
  283. .item-icon-box.income {
  284. background-color: #EEF9F2; /* Light Green */
  285. }
  286. .item-icon-box.expense {
  287. background-color: #FFF0F0; /* Light Red */
  288. }
  289. .item-icon-symbol {
  290. font-size: 40rpx;
  291. font-weight: 300;
  292. line-height: 1;
  293. margin-top: -4rpx; /* Visual center adjustment */
  294. }
  295. .item-icon-box.income .item-icon-symbol {
  296. color: #4CAF50;
  297. }
  298. .item-icon-box.expense .item-icon-symbol {
  299. color: #FF4D4F;
  300. }
  301. /* 中间内容 */
  302. .item-center {
  303. flex: 1;
  304. display: flex;
  305. flex-direction: column;
  306. justify-content: space-around;
  307. height: 80rpx;
  308. }
  309. .item-title {
  310. font-size: 28rpx;
  311. font-weight: 500;
  312. color: #333;
  313. }
  314. .item-desc {
  315. font-size: 22rpx;
  316. color: #999;
  317. margin-top: 8rpx;
  318. }
  319. /* 右侧数据 */
  320. .item-right {
  321. display: flex;
  322. flex-direction: column;
  323. align-items: flex-end;
  324. justify-content: space-around;
  325. height: 80rpx;
  326. margin-left: 10rpx;
  327. }
  328. .item-amount {
  329. font-size: 30rpx;
  330. font-weight: bold;
  331. }
  332. .item-amount.income {
  333. color: #4CAF50;
  334. }
  335. .item-amount.expense {
  336. color: #333;
  337. }
  338. .item-tag {
  339. display: inline-flex;
  340. justify-content: flex-end;
  341. margin-top: 6rpx;
  342. }
  343. .item-tag text {
  344. background-color: #FFFFFF;
  345. border: 1rpx solid #eee;
  346. padding: 2rpx 8rpx;
  347. border-radius: 6rpx;
  348. font-size: 20rpx;
  349. color: #999;
  350. }
  351. .list-padding-bottom {
  352. height: 40rpx;
  353. }
  354. </style>