myDonate.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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" @click="lookzs(item)">
  16. <view class="header">
  17. 明细
  18. </view>
  19. <view class="main">
  20. <view class="main-left">
  21. <view class="project">
  22. {{item.order_name}}
  23. </view>
  24. <view class="time">
  25. {{item.paytime_text.split(' ')[0]}}
  26. <!-- {{getRecTime(item.paytime)}} -->
  27. </view>
  28. </view>
  29. <view class="mian-right">
  30. {{item.amount}}元
  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 {
  41. MyDonaList
  42. } from '@/api/ask.js';
  43. import empty from '@/components/empty';
  44. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  45. export default {
  46. components: {
  47. empty,
  48. uniLoadMore
  49. },
  50. data() {
  51. return {
  52. page: 1,
  53. limit: 10,
  54. sum: 3,
  55. loadingType: 'more',
  56. list: []
  57. }
  58. },
  59. onLoad() {
  60. this.loadData();
  61. },
  62. onReachBottom() {
  63. this.loadData();
  64. },
  65. methods: {
  66. // 查看证书
  67. lookzs(item) {
  68. let date = new Date(item.paytime * 1000)
  69. let year = date.getFullYear()
  70. let month = date.getMonth() >= 9 ? date.getMonth() + 1 : '0' + (date
  71. .getMonth() + 1)
  72. let day = date.getDate() >= 10 ? date.getDate() : '0' + date.getDate()
  73. uni.navigateTo({
  74. url: '/pages/form/donaSuccess?money=' + item.amount + '&name=' + encodeURI(item.name) +
  75. '&time=' + encodeURI(year + '年' + month + '月' + day + '日')
  76. })
  77. },
  78. async loadData() {
  79. let obj = this;
  80. if (obj.loadingType === 'noMore' || obj.loadingType == 'loading') {
  81. //防止重复加载
  82. return;
  83. }
  84. // 修改当前对象状态为加载中
  85. obj.loadingType = 'loading';
  86. MyDonaList({
  87. page: obj.page,
  88. limit: obj.limit
  89. }).then(({
  90. data
  91. }) => {
  92. console.log(data)
  93. // obj.sum = data.sum
  94. obj.list = obj.list.concat(data.data);
  95. obj.page++;
  96. if (obj.limit == data.data.length) {
  97. obj.loadingType = 'more';
  98. } else {
  99. obj.loadingType = 'noMore';
  100. }
  101. })
  102. },
  103. getRecTime(timestamp, fmt) {
  104. let d = new Date(timestamp * 1000),
  105. // f = fmt || 'yyyy/MM/dd',
  106. f = fmt || 'yyyy.MM.dd hh:mm:ss',
  107. o = {
  108. 'M+': d.getMonth() + 1, //月份
  109. 'd+': d.getDate(), //日
  110. 'h+': d.getHours(), //小时
  111. 'm+': d.getMinutes(), //分
  112. 's+': d.getSeconds(), //秒
  113. 'q+': Math.floor((d.getMonth() + 3) / 3), //季度
  114. 'S': d.getMilliseconds() //毫秒
  115. };
  116. if (/(y+)/.test(f)) {
  117. f = f.replace(RegExp.$1, (d.getFullYear() + '').substr(4 - RegExp.$1.length));
  118. }
  119. for (let k in o) {
  120. if (new RegExp('(' + k + ')').test(f)) {
  121. f = f.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k])
  122. .length)));
  123. }
  124. }
  125. console.log(f)
  126. return f;
  127. },
  128. }
  129. }
  130. </script>
  131. <style lang="scss">
  132. page,
  133. .content {
  134. height: 100vh;
  135. background-color: #FFFFFF;
  136. }
  137. .top {
  138. display: flex;
  139. align-items: center;
  140. justify-content: center;
  141. background-color: #E63931;
  142. color: #FFFFFF;
  143. padding: 22rpx 0;
  144. }
  145. .total {
  146. padding: 18rpx 24rpx;
  147. display: flex;
  148. justify-content: space-between;
  149. border-bottom: 1rpx solid #e0e0e0;
  150. }
  151. .box {
  152. padding: 0 24rpx;
  153. .box-item {
  154. padding: 24rpx 0;
  155. border-bottom: 1rpx solid #e0e0e0;
  156. .header {
  157. color: #999999;
  158. font-size: 24rpx;
  159. }
  160. .main {
  161. margin-top: 22rpx;
  162. display: flex;
  163. justify-content: space-between;
  164. .mian-right {
  165. display: flex;
  166. flex-direction: column;
  167. justify-content: flex-end;
  168. }
  169. .main-left {
  170. .project {
  171. color: #333;
  172. font-size: 28rpx;
  173. }
  174. .time {
  175. margin-top: 6rpx;
  176. color: #999999;
  177. font-size: 22rpx;
  178. }
  179. }
  180. }
  181. }
  182. }
  183. </style>