my-balance.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <view class="flex-common-css iPhone-bottom box-border-box seckill-box">
  3. <Nav title="我的余额" bgckgroundBox='transparent' leftColor='#fff' titleColor='#fff'></Nav>
  4. <view class="p-24 box-border-box">
  5. <view class="zzc-box b-rad-20 bgc-f flex-direction align-items-center flex-justify-center">
  6. <view class="fs-28 fc-9 mb-8">
  7. 总资产(元)
  8. </view>
  9. <view class="fs-52 fc-3 fw-b">
  10. <text class="fs-40 fw-600">¥</text>{{Number(moneyNum).toFixed(2)}}
  11. </view>
  12. </view>
  13. </view>
  14. <view class="plr-24 box-border-box mb-24">
  15. <view class="b-rad-200 bgc-f box-border-box">
  16. <scroll-view class="scroll-view_H" scroll-x="true">
  17. <view class="title-box b-rad-200 box-border-box text-align-center" v-for="(item,index) in titleData"
  18. @click="titleBut(item)" :class="item.water_key === titleId?'bgc-4FB3EF fc-f':''">
  19. {{item.water_name}}
  20. </view>
  21. </scroll-view>
  22. </view>
  23. </view>
  24. <view class="plr-24 box-border-box">
  25. <view class="p-24 box-border-box bgc-f sx-box">
  26. <picker mode="date" fields="month" :value="tiem" :start="startDate" :end="endDate"
  27. @change="bindDateChange">
  28. <view class="align-items-center">
  29. <view class=" fs-28 fc-0 fw-400 align-items-center mr-8">
  30. {{tiem}}
  31. </view>
  32. <image class="right" src="@/static/img/toRight.png" mode=""></image>
  33. </view>
  34. </picker>
  35. </view>
  36. </view>
  37. <scroll-view :scroll-y="true" class="scroll-view-css plr-24 box-border-box" @scrolltolower="scrolltolower">
  38. <view class="bgc-f plr-32 box-border-box">
  39. <view v-if="listData.length == 0" class="scroll-view-css">
  40. <EnBlank :customSrc='true'>
  41. <template v-slot:blankImg>
  42. <image class="black-custom-img" src="@/static/img/common/no-order.png" mode=""></image>
  43. </template>
  44. </EnBlank>
  45. </view>
  46. <view class="ptb-24 item-box" v-for="(item,index) in listData" :key="index">
  47. <view class="align-items-center flex-justify-space mb-4">
  48. <view class="fs-32 fc-3">
  49. {{item.mark}}
  50. </view>
  51. <view class="fs-32 fw-600" :class="item.add_reduce === 0?'fc-3':'fc-FE9E11'">
  52. {{item.price}}
  53. </view>
  54. </view>
  55. <view class="align-items-center flex-justify-space">
  56. <view class="fs-24 fc-9">
  57. {{item.created_at}}
  58. </view>
  59. <view class="fs-24 fc-9">
  60. 当前余额{{Number(item.remainder).toFixed(2)}}
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </scroll-view>
  66. </view>
  67. </template>
  68. <script>
  69. import {
  70. moneyStatus,
  71. moneyList
  72. } from "@/api/money.js"
  73. import EnBlank from "@/components/en-utils/en-blank/en-blank";
  74. export default {
  75. components: {
  76. EnBlank
  77. },
  78. data() {
  79. // const currentDate = this.getDate({
  80. // format: true
  81. // })
  82. return {
  83. titleId: "0",
  84. titleData: [],
  85. listData: [],
  86. tiem: '',
  87. page: 1,
  88. total: 0,
  89. moneyNum: ''
  90. };
  91. },
  92. computed: {
  93. startDate() {
  94. return this.getDate('start');
  95. },
  96. endDate() {
  97. return this.getDate('end');
  98. }
  99. },
  100. onLoad(data) {
  101. if (data) {
  102. this.moneyNum = data.money
  103. }
  104. },
  105. mounted() {
  106. this.moneyStatus()
  107. this.moneyList()
  108. this.getTime()
  109. },
  110. methods: {
  111. getTime() {
  112. const now = new Date();
  113. const year = now.getFullYear();
  114. const month = now.getMonth() + 1; // 月份从 0 开始,需要加 1
  115. this.tiem = `${year}-${month < 10 ? "0" + month : month}`; // 格式化为 YYYY-MM
  116. },
  117. moneyList() {
  118. moneyList({
  119. status: this.titleId,
  120. monthDate: this.tiem,
  121. page: this.page
  122. }).then((res) => {
  123. if (res.code === 1) {
  124. this.listData.push(...res.data.list)
  125. this.total = res.data.total
  126. }
  127. })
  128. },
  129. bindDateChange(e) {
  130. this.tiem = e.detail.value
  131. this.page = 1;
  132. this.listData = [];
  133. this.moneyList();
  134. },
  135. titleBut(item) {
  136. if (item.water_key === this.titleId) {
  137. return
  138. }
  139. this.titleId = item.water_key
  140. this.page = 1;
  141. this.listData = [];
  142. this.moneyList();
  143. },
  144. moneyStatus() {
  145. moneyStatus().then((res) => {
  146. if (res.code === 1) {
  147. this.titleData = res.data
  148. }
  149. })
  150. },
  151. getDate(type) {
  152. const date = new Date();
  153. let year = date.getFullYear();
  154. let month = date.getMonth() + 1;
  155. let day = date.getDate();
  156. if (type === 'start') {
  157. year = year - 60;
  158. } else if (type === 'end') {
  159. year = year + 2;
  160. }
  161. month = month > 9 ? month : '0' + month;
  162. day = day > 9 ? day : '0' + day;
  163. return `${year}-${month}-${day}`;
  164. },
  165. scrolltolower() {
  166. if (this.listData.length < this.total) {
  167. ++this.page
  168. this.moneyList()
  169. }
  170. }
  171. },
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. .item-box {
  176. border-bottom: 1rpx solid #EEEEEE;
  177. }
  178. .item-box:last-child {
  179. border: none;
  180. }
  181. .right {
  182. width: 32rpx;
  183. height: 32rpx;
  184. }
  185. .sx-box {
  186. border-radius: 20rpx 20rpx 0 0;
  187. }
  188. .seckill-box {
  189. background: linear-gradient(to bottom, #4FB3EF, #F5F5F5, #F5F5F5);
  190. }
  191. .zzc-box {
  192. width: 100%;
  193. height: 268rpx;
  194. }
  195. .scroll-view_H {
  196. white-space: nowrap;
  197. width: 100%;
  198. }
  199. .title-box {
  200. min-width: 28.3%;
  201. display: inline-block;
  202. height: 70rpx;
  203. line-height: 70rpx;
  204. padding: 0 50rpx;
  205. }
  206. </style>