敢为人鲜小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

221 lines
5.3 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="assets-page">
  3. <!-- 导航栏 -->
  4. <navbar title="资产明细" leftClick @leftClick="$utils.navigateBack" bgColor="#019245" color="#fff" />
  5. <!-- diy的tab栏 -->
  6. <uv-sticky>
  7. <view class="tab-container">
  8. <view class="tab-wrapper">
  9. <view
  10. v-for="(item, index) in list"
  11. :key="index"
  12. class="tab-item"
  13. :class="{ active: currentTab === index }"
  14. @click="switchTab(index)"
  15. >
  16. {{ item.name }}
  17. </view>
  18. <!-- 滑块 -->
  19. <view class="tab-slider" :style="{ left: currentTab * 50 + '%' }" />
  20. </view>
  21. </view>
  22. </uv-sticky>
  23. <!-- 交易记录列表 -->
  24. <view class="transaction-list">
  25. <view class="transaction-item" v-for="item in comeList" :key="item.id">
  26. <!-- 左侧图标和类型 -->
  27. <view class="item-left">
  28. <view class="icon-container">
  29. <uv-icon name="empty-coupon" color="#019245" size="44"></uv-icon>
  30. </view>
  31. <view class="item-info">
  32. <view class="item-type">{{ item.title }}</view>
  33. <view class="item-time">{{ item.createTime }}</view>
  34. </view>
  35. </view>
  36. <!-- 右侧金额 -->
  37. <view class="item-amount income">¥{{ item.amount }}</view>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import navbar from '@/components/base/navbar.vue'
  44. // import { assetsData, assetsDataForHead } from '@/static/js/mockAssets.js'
  45. export default {
  46. components: {
  47. navbar
  48. },
  49. data() {
  50. return {
  51. currentTab: 0, // 0-收入明细 1-支出明细
  52. comeList: [],
  53. list: [
  54. {
  55. name: '收入明细',
  56. },
  57. {
  58. name: '支出明细',
  59. }
  60. ],
  61. Data: []
  62. }
  63. },
  64. computed: {
  65. incomeList() {
  66. return this.Data.filter(item => item.cashType == "0")
  67. },
  68. expenseList() {
  69. return this.Data.filter(item => item.cashType == "1")
  70. }
  71. },
  72. onLoad() {
  73. const identity = uni.getStorageSync('identity')
  74. this.getData()
  75. },
  76. methods: {
  77. // 切换标签
  78. switchTab(index) {
  79. this.currentTab = index
  80. // 切换显示的列表
  81. if (index === 0) {
  82. this.comeList = this.incomeList
  83. } else if(index === 1) {
  84. console.log(this.expenseList, '支出', this.Data);
  85. this.comeList = this.expenseList
  86. }
  87. },
  88. getData() {
  89. this.$api('queryAmountLog', {}, res => {
  90. if (res.code === 200) {
  91. this.Data = res.result.records
  92. this.switchTab(0)
  93. }
  94. })
  95. }
  96. },
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .assets-page {
  101. // min-height: 100vh;
  102. // background-color: #f5f5f5;
  103. }
  104. .transaction-list {
  105. padding: 0 20rpx;
  106. // background-color: #fff;
  107. }
  108. .transaction-item {
  109. display: flex;
  110. justify-content: space-between;
  111. align-items: center;
  112. padding: 30rpx 10rpx;
  113. border-bottom: 1rpx solid #E0E0E0;
  114. &:last-child {
  115. border-bottom: none;
  116. }
  117. .item-left {
  118. display: flex;
  119. align-items: center;
  120. .icon-container {
  121. width: 70rpx;
  122. height: 70rpx;
  123. border-radius: 50%;
  124. // background-color: rgba(1, 146, 69, 0.1);
  125. display: flex;
  126. justify-content: center;
  127. align-items: center;
  128. margin-right: 20rpx;
  129. border: 4rpx solid $uni-color ;
  130. }
  131. .item-info {
  132. .item-type {
  133. font-size: 30rpx;
  134. color: #333;
  135. margin-bottom: 6rpx;
  136. font-weight: 600;
  137. }
  138. .item-time {
  139. font-size: 24rpx;
  140. color: #949494;
  141. }
  142. }
  143. }
  144. .item-amount {
  145. font-size: 32rpx;
  146. font-weight: 500;
  147. &.income {
  148. color: $uni-color-second;
  149. }
  150. &.expense {
  151. color: #333;
  152. }
  153. }
  154. }
  155. // 添加tab样式
  156. .tab-container {
  157. width: 100%;
  158. // background-color: #fff;
  159. padding: 30rpx 0;
  160. }
  161. .tab-wrapper {
  162. display: flex;
  163. position: relative;
  164. width: 90%;
  165. height: 68rpx;
  166. margin: 0 auto;
  167. background-color: #cfcfcf;
  168. border-radius: 42rpx;
  169. overflow: hidden;
  170. margin-bottom: 20rpx;
  171. }
  172. .tab-item {
  173. flex: 1;
  174. display: flex;
  175. justify-content: center;
  176. align-items: center;
  177. height: 100%;
  178. font-size: 28rpx;
  179. color: #333;
  180. position: relative;
  181. z-index: 1;
  182. transition: color 0.3s;
  183. &.active {
  184. color: #fff;
  185. font-weight: 500;
  186. }
  187. }
  188. .tab-slider {
  189. position: absolute;
  190. width: 50%;
  191. height: 100%;
  192. background-color: $uni-color;
  193. border-radius: 42rpx;
  194. top: 0;
  195. transition: left 0.3s cubic-bezier(0.35, 0, 0.25, 1);
  196. z-index: 0;
  197. }
  198. </style>