耀实惠小程序
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.

180 lines
3.9 KiB

  1. <template>
  2. <view>
  3. <u-picker mode="time" v-model="show_time" :params="params" @confirm="getTime"></u-picker>
  4. <!-- 数据展示 -->
  5. <view class="item_box">
  6. <view class="item_title" @click="toChangeTime">
  7. <text class="time">{{data_time}}</text>
  8. <u-icon name="arrow-down"></u-icon>
  9. </view>
  10. <view class="item" v-for="(item,index) in list" :key="index">
  11. <view class="left_box">
  12. <view class="text_box">
  13. <text class="title">{{item.name}}</text>
  14. <text class="time">{{item.createTime}}</text>
  15. </view>
  16. </view>
  17. <text class="get_num">{{item.payType==0?'+'+(item.getInteger+item.getMoney):'-¥'+item.wallet}}</text>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. data_time: "2021年7月",
  27. show_time: false,
  28. params: {
  29. year: true,
  30. month: true,
  31. day: false,
  32. hour: false,
  33. minute: false,
  34. second: false
  35. },
  36. list: [],
  37. pageNo:1,
  38. pageSize: 20,
  39. total: null,
  40. default_time: '',
  41. isLock: false, //上拉加载锁
  42. }
  43. },
  44. onLoad() {
  45. this.default_time = new Date().getFullYear()+'-'+ (new Date().getMonth()+1>10? new Date().getMonth()+1: '0'+(new Date().getMonth()+1))
  46. this.data_time = new Date().getFullYear()+'年' +(new Date().getMonth()+1)+'月';
  47. this.getTopUpDetaleList({
  48. pageNo: this.pageNo,
  49. pageSize: this.pageSize,
  50. stringDate: this.default_time.replace(/-/,'/')
  51. });
  52. },
  53. onReachBottom() {
  54. // 上拉加载
  55. if(!this.isLock){
  56. console.log(this.pageNo * this.pageSize , this.total)
  57. if(this.pageNo * this.pageSize > this.total && this.total!== null) {
  58. // 没有更多加载了
  59. console.log(123)
  60. this.isLock = true;
  61. this.$Toast('没有更多数据了呢!');
  62. setTimeout(()=> {
  63. // 3秒后解锁
  64. this.isLock = false;
  65. },3000)
  66. return
  67. }
  68. this.isLock = true;
  69. this.pageNo+=1;
  70. console.log(this.default_time)
  71. this.getTopUpDetaleList({
  72. pageNo: this.pageNo,
  73. pageSize: this.pageSize,
  74. stringDate: this.default_time.replace(/-/,'/')
  75. })
  76. }
  77. },
  78. methods: {
  79. getTopUpDetaleList(params){
  80. uni.showLoading();
  81. this.$api('topUpDetail',params).then(res => {
  82. let { code, result, message } = res;
  83. this.isLock = false;
  84. uni.hideLoading();
  85. if (code === 200) {
  86. if(this.total == null) {
  87. this.total = result.total
  88. }
  89. this.list = this.list.concat(result.records);
  90. } else {
  91. this.$Toast(message)
  92. }
  93. }).catch(err => {
  94. this.isLock = false;
  95. uni.hideLoading();
  96. this.$Toast(err.message)
  97. })
  98. },
  99. toChangeTime() {
  100. this.show_time = true;
  101. console.log(123)
  102. },
  103. getTime(e) {
  104. this.data_time = e.year+"年"+ (e.month>10?e.month:e.month.replace(/0/,'')) +"月";
  105. this.default_time= `${e.year}-${e.month}`;
  106. // 初始化数据
  107. this.list = [];
  108. this.pageNo = 1;
  109. this.total = null;
  110. const params = {
  111. pageNo: this.pageNo,
  112. pageSize: this.pageSize,
  113. stringDate: `${e.year}/${e.month}`
  114. }
  115. console.log(params)
  116. this.getTopUpDetaleList(params)
  117. },
  118. }
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. .item_box {
  123. display: flex;
  124. flex-direction: column;
  125. justify-content: center;
  126. .item_title {
  127. padding-top: 33rpx;
  128. margin-left: 60rpx;
  129. .time {
  130. margin-right: 22rpx;
  131. }
  132. }
  133. .item {
  134. width: 670rpx;
  135. margin: 0 auto;
  136. border-bottom: 1rpx solid #E0E0E0;
  137. display: flex;
  138. justify-content: space-between;
  139. align-items: center;
  140. &:last-child {
  141. border-bottom: none;
  142. }
  143. .get_num {
  144. font-size: 24rpx;
  145. color: #DD0F00;
  146. }
  147. .left_box {
  148. display: flex;
  149. align-items: center;
  150. margin-top: 21rpx;
  151. padding-bottom: 20rpx;
  152. .text_box {
  153. display: flex;
  154. flex-direction: column;
  155. .title {
  156. font-size: 24rpx;
  157. font-weight: bold;
  158. color: #333333;
  159. }
  160. .time {
  161. font-size: 20rpx;
  162. color: #9A9A9A;
  163. }
  164. }
  165. }
  166. }
  167. }
  168. </style>