my.vue 3.6 KB

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