myDonate.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. 我的捐赠
  5. </view>
  6. <view class="total">
  7. <view class="total-left">
  8. 捐赠总额
  9. </view>
  10. <view class="total-right">
  11. {{ sum }}元
  12. </view>
  13. </view>
  14. <view class="box">
  15. <view class="box-item" v-for="item in list" :key="item.id">
  16. <view class="header">
  17. 明细
  18. </view>
  19. <view class="main">
  20. <view class="main-left">
  21. <view class="project">
  22. {{item.intention}}
  23. </view>
  24. <view class="time">
  25. <!-- {{item.pay_time}} -->
  26. {{getRecTime(item.pay_time)}}
  27. </view>
  28. </view>
  29. <view class="mian-right">
  30. {{item.money}}元
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <empty v-if="list.length === 0"></empty>
  36. <uni-load-more :status="loadingType"></uni-load-more>
  37. </view>
  38. </template>
  39. <script>
  40. import { MyDonaList } from '@/api/ask.js';
  41. import empty from '@/components/empty';
  42. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  43. export default{
  44. components: {
  45. empty,
  46. uniLoadMore
  47. },
  48. data() {
  49. return{
  50. page: 1,
  51. limit: 10,
  52. sum:3,
  53. loadingType: 'more',
  54. list:[
  55. // { id: 0, price: '500.00', project: '疫情防控', name: '韩**', phone: '139****3217', time: '2020-10-24 16:42:53' },
  56. // { id: 1, price: '450.00', project: '会费缴纳', name: '江**', phone: '139****3217', time: '2020-10-24 16:42:53' },
  57. // { id: 2, price: '398.00', project: '红十字人道事业(非定向捐赠)',name: '阮**', phone: '139****3217', time: '2020-10-24 16:42:53' },
  58. ]
  59. }
  60. },
  61. onLoad() {
  62. this.loadData();
  63. },
  64. methods:{
  65. async loadData() {
  66. let obj = this;
  67. if (obj.loadingType === 'noMore') {
  68. //防止重复加载
  69. return;
  70. }
  71. // 修改当前对象状态为加载中
  72. obj.loadingType = 'loading';
  73. MyDonaList({
  74. page: obj.page,
  75. limit: obj.limit
  76. }).then(({
  77. data
  78. }) => {
  79. console.log(data)
  80. obj.sum = data.sum
  81. // obj.list = data.list
  82. obj.list = obj.list.concat(data.list);
  83. obj.page++;
  84. if (obj.limit == data.length) {
  85. obj.loadingType = 'more';
  86. } else {
  87. obj.loadingType = 'noMore';
  88. }
  89. })
  90. },
  91. getRecTime(timestamp, fmt) {
  92. let d = new Date(timestamp * 1000),
  93. // f = fmt || 'yyyy/MM/dd',
  94. f = fmt || 'yyyy.MM.dd hh:mm:ss',
  95. o = {
  96. 'M+': d.getMonth() + 1, //月份
  97. 'd+': d.getDate(), //日
  98. 'h+': d.getHours(), //小时
  99. 'm+': d.getMinutes(), //分
  100. 's+': d.getSeconds(), //秒
  101. 'q+': Math.floor((d.getMonth() + 3) / 3), //季度
  102. 'S': d.getMilliseconds() //毫秒
  103. };
  104. if (/(y+)/.test(f)) {
  105. f = f.replace(RegExp.$1, (d.getFullYear() + '').substr(4 - RegExp.$1.length));
  106. }
  107. for (let k in o) {
  108. if (new RegExp('(' + k + ')').test(f)) {
  109. f = f.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)));
  110. }
  111. }
  112. return f;
  113. console.log(f)
  114. },
  115. }
  116. }
  117. </script>
  118. <style lang="scss">
  119. page, .content{
  120. height: 100vh;
  121. background-color: #FFFFFF;
  122. }
  123. .top{
  124. display: flex;
  125. align-items: center;
  126. justify-content: center;
  127. background-color: #E63931;
  128. color: #FFFFFF;
  129. padding: 22rpx 0;
  130. }
  131. .total{
  132. padding: 18rpx 24rpx;
  133. display: flex;
  134. justify-content: space-between;
  135. border-bottom: 1rpx solid #e0e0e0;
  136. }
  137. .box{
  138. padding: 0 24rpx;
  139. .box-item{
  140. padding: 24rpx 0;
  141. border-bottom: 1rpx solid #e0e0e0;
  142. .header{
  143. color: #999999;
  144. font-size: 24rpx;
  145. }
  146. .main{
  147. margin-top: 22rpx;
  148. display: flex;
  149. justify-content: space-between;
  150. .mian-right{
  151. display: flex;
  152. flex-direction: column;
  153. justify-content: flex-end;
  154. }
  155. .main-left{
  156. .project{
  157. color: #333;
  158. font-size: 28rpx;
  159. }
  160. .time{
  161. margin-top: 6rpx;
  162. color: #999999;
  163. font-size: 22rpx;
  164. }
  165. }
  166. }
  167. }
  168. }
  169. </style>