my.vue 3.8 KB

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