donateList.vue 3.4 KB

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