tr-recharge.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <view class="tr-recharge_content">
  3. <!-- :enable-back-to-top="current_index===tab_index" 在微信小程序上可以多加这一句,因为默认是允许点击返回顶部的,但是这个页面有多个scroll-view,会全部返回顶部,所以需要控制是当前index才允许点击返回顶部 -->
  4. <!-- 如果当前页已经加载过数据或者当前切换到的tab是当前页,才展示当前页数据(懒加载) -->
  5. <z-paging v-if="first_loaded || is_currentPage"
  6. ref="paging"
  7. v-model="data_list"
  8. :default-page-size="15"
  9. @query="queryList"
  10. :fixed="false">
  11. <!-- 如果希望其他view跟着页面滚动,可以放在z-paging标签内 -->
  12. <view class="list" v-for="(item,index) in data_list" :key="index" @click="itemClick(item)">
  13. <view class="item">
  14. <view class="item__info">
  15. <view class="item__info__title">
  16. <view class="item__info__title__text">
  17. {{item.goods_name}}
  18. </view>
  19. <view class="item__info__title__status" :style="{backgroundColor:tools.getOrderStatusInfo(item.status).bg_color}">
  20. {{tools.getOrderStatusInfo(item.status).title}}
  21. </view>
  22. </view>
  23. <view class="item__info__date">
  24. {{item.create_at}}
  25. </view>
  26. </view>
  27. <view class="item__rmb">
  28. -{{(item.amount/100).toFixed(2)}}
  29. </view>
  30. </view>
  31. </view>
  32. </z-paging>
  33. </view>
  34. </template>
  35. <script setup lang="ts">
  36. import { nextTick, ref, watch } from 'vue';
  37. import { trading_record_item_data } from '../../data/data';
  38. import { tools } from '../../framework/tools';
  39. let data_list = ref([]) //v-model绑定的这个变量不要在分页请求结束中自己赋值!!!
  40. let first_loaded = ref(false) //当前组件是否已经加载过了
  41. let is_currentPage = ref(false) //是否滚动到当前页
  42. const paging = ref(null) //$ref:paging
  43. const props = defineProps({
  44. tab_index: Number, //当前组件的index,也就是当前组件是swiper中的第几个
  45. current_index:Number, // 当前swiper切换到第几个index
  46. })
  47. watch(()=>props.current_index, (new_v,old_v)=>{
  48. if(new_v === props.tab_index){
  49. // 懒加载,当滑动到当前的item时,才去加载
  50. if(!first_loaded.value){
  51. first_loaded.value = true
  52. // 这里需要延迟渲染z-paging的原因是为了避免在一些平台上立即渲染可能引发的底层报错问题
  53. nextTick(()=>{
  54. setTimeout(() => {
  55. is_currentPage.value = true
  56. }, 100);
  57. })
  58. }
  59. }
  60. },{immediate:true})
  61. function queryList(pageNum:number, pageSize:number) {
  62. // console.log('pageNum=',pageNum,'pageSize=',pageSize)
  63. tools.requestOrderList(1,pageNum,pageSize,(data)=>{
  64. // console.log('充值data=',data)
  65. if(data) {
  66. if (pageNum == 1) {
  67. data_list.value = []
  68. }
  69. paging.value.complete(data.list)
  70. data_list.value = data_list.value.concat(data.list)
  71. } else {
  72. paging.value.complete(false)
  73. }
  74. })
  75. }
  76. function itemClick(item_data:trading_record_item_data) {
  77. }
  78. </script>
  79. <style lang="scss">
  80. /* 注意:父节点需要固定高度,z-paging的height:100%才会生效 */
  81. .tr-recharge_content {
  82. height: 100%;
  83. background-color: #ffffff;
  84. .list{
  85. display: flex;
  86. justify-content: center;
  87. .item{
  88. margin-top: 4%;
  89. display: flex;
  90. justify-content: space-between;
  91. align-items: center;
  92. width: 88%;
  93. padding: 3% 3%;
  94. border-radius: 20rpx;
  95. box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.1);
  96. background-color: #ffffff;
  97. &__info {
  98. display: flex;
  99. flex-direction: column;
  100. width: 78%;
  101. margin-right: 2%;
  102. &__title {
  103. display: flex;
  104. flex-direction: row;
  105. &__text {
  106. font-size: 17px;
  107. color: #000;
  108. max-width: 80%;
  109. white-space: nowrap; /* 防止文本换行 */
  110. overflow: hidden; /* 隐藏溢出的文本 */
  111. text-overflow: ellipsis; /* 超出部分显示为省略号 */
  112. }
  113. &__status{
  114. display: flex;
  115. justify-content: center;
  116. align-items: center;
  117. margin-left: 15rpx;
  118. padding: 0 10rpx;
  119. font-size: 12.5px;
  120. color: #ffffff;
  121. background-color: #93DB6B; // #FDCC22
  122. border-top-left-radius: 20rpx;
  123. border-top-right-radius: 20rpx;
  124. border-bottom-right-radius: 20rpx;
  125. }
  126. }
  127. &__date{
  128. margin-top: 16rpx;
  129. font-size: 14px;
  130. color: #6D6D6D;
  131. }
  132. }
  133. &__rmb{
  134. margin-top: -2%;
  135. display: flex;
  136. justify-content: right;
  137. width: 20%;
  138. font-size: 17px;
  139. color: #FF133A;
  140. }
  141. }
  142. }
  143. }
  144. </style>