my.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="content">
  3. <view class="mainList">
  4. <uni-list>
  5. <uni-list-item v-for="(item, index) in list" :key="index">
  6. <!-- 自定义 header -->
  7. <template v-slot:header>
  8. <image class="slot-image" :src="fileUrl + item['discountInfo.photo']" @click="btn(item)"></image>
  9. </template>
  10. <!-- 自定义 body -->
  11. <template v-slot:body>
  12. <view class="slot-body titleBox" @click="btn(item)">
  13. <view class="slot-box slot-title">{{ item['discountInfo.name'] }}</view>
  14. <view class="slot-box slot-text">领取时间:{{ item.createTime }}</view>
  15. </view>
  16. </template>
  17. <!-- 自定义 footer-->
  18. <template v-slot:footer></template>
  19. </uni-list-item>
  20. </uni-list>
  21. </view>
  22. <uni-load-more :status="more" />
  23. </view>
  24. </template>
  25. <script>
  26. import login from '../../api/login.js';
  27. import { BASE_URL } from '../../env.js';
  28. import voucher from '../../api/voucher.js';
  29. export default {
  30. components: {},
  31. data() {
  32. return {
  33. fileUrl: BASE_URL.fileUrl,
  34. list: [],
  35. page: 0,
  36. size: 10,
  37. more: 'more',
  38. };
  39. },
  40. onLoad: async function() {
  41. this.query();
  42. },
  43. methods: {
  44. async query() {
  45. this.page += 1;
  46. this.more = 'loading';
  47. // 此处是查询函数
  48. const res = await voucher.getMyList({ pageNum: this.page, pageSize: this.size });
  49. this.list.push(...res.rows.map(e => {
  50. for (const key in e.discountInfo) {
  51. const itemKey = `discountInfo.${key}`;
  52. e[itemKey] = e.discountInfo[key]
  53. }
  54. return e;
  55. }))
  56. // 根据总数 算页数 如果当前页 = 总页数就是没有数据 否则就是上拉加载
  57. this.more = this.page >= Math.ceil(res.total / this.size) ? 'noMore' : 'more';
  58. },
  59. // 详情
  60. btn(item) {
  61. uni.navigateTo({ url: `/pages/good/details?id=${item.voucherId}` });
  62. }
  63. },
  64. // 页面生命周期中onReachBottom(页面滚动到底部的事件)
  65. onReachBottom() {
  66. if(this.more != 'noMore') {
  67. this.more = 'more';
  68. this.query();
  69. }
  70. }
  71. };
  72. </script>
  73. <style scoped>
  74. .content {
  75. width: 100%;
  76. height: 100vh;
  77. padding-bottom: 15rpx;
  78. background: #F8F8F8;
  79. }
  80. .mainList {
  81. width: 90%;
  82. margin: 30rpx auto;
  83. }
  84. .mainText {
  85. width: 100%;
  86. color: #000000;
  87. font-size: 34rpx;
  88. text-align: left;
  89. font-weight: 550;
  90. opacity: 0.5;
  91. margin-bottom: 50rpx;
  92. }
  93. .receive {
  94. display: flex;
  95. justify-content: center;
  96. align-items: center;
  97. width: 120rpx;
  98. background-color: #f60;
  99. color: #FFFFFF;
  100. font-size: 24rpx;
  101. border-radius: 10rpx;
  102. height: 2.5em;
  103. margin-top: 30rpx;
  104. }
  105. button {
  106. margin: unset;
  107. padding: unset;
  108. }
  109. button:after {
  110. border: unset;
  111. }
  112. </style>
  113. <style>
  114. .slot-box {
  115. position: relative;
  116. }
  117. .slot-image {
  118. width: 130rpx;
  119. height: 120rpx;
  120. }
  121. .status {
  122. position: absolute;
  123. left: 0;
  124. top: 0;
  125. font-size: 12px;
  126. color: #fff;
  127. background: #999;
  128. }
  129. .uni-list-item__container {
  130. flex: none !important;
  131. width: 90%;
  132. padding: 12px 5% !important;
  133. }
  134. .titleBox {
  135. width: 70%;
  136. margin-left: 10px;
  137. display: block;
  138. }
  139. .slot-title {
  140. width: 100%;
  141. font-weight: 600;
  142. color: #000;
  143. line-height: 2em;
  144. overflow: hidden;
  145. white-space: nowrap;
  146. text-overflow: ellipsis;
  147. display: block;
  148. }
  149. .slot-text {
  150. display: block;
  151. width: 100%;
  152. font-size: 22rpx;
  153. color: #999;
  154. overflow: hidden;
  155. white-space: nowrap;
  156. text-overflow: ellipsis;
  157. }
  158. .slot-footer {
  159. margin-left: 3%;
  160. }
  161. .footerIcon {
  162. line-height: 3em;
  163. }
  164. .remainCount {
  165. background-color: #999 !important;
  166. }
  167. .swiper {
  168. height: 45vw;
  169. overflow: hidden;
  170. }
  171. /**/
  172. .uni-section .uni-section-header {
  173. padding: 12px 20px !important;
  174. }
  175. </style>