珠宝小程序前端代码
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.

265 lines
5.1 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. <template>
  2. <scroll-view scroll-y="true" :style="{height: height}" @scrolltolower="moreCoupon()">
  3. <!-- 优惠券列表 -->
  4. <view class="list">
  5. <view class="item" v-for="item in couponList" @click="select(item)" :key="item.id"
  6. :class="['status-' + item.state]">
  7. <image src="@/pages_order/static/coupon/coupon-bg.png" mode="widthFix" class="coupon-bg"></image>
  8. <view class="item-con">
  9. <view class="price-time">
  10. <view class="price">
  11. <view class="num">
  12. <view class="icon">
  13. </view>
  14. {{ item.money }}
  15. </view>
  16. </view>
  17. <view class="date-tiao">
  18. <view class="time">
  19. {{ formatDate(item.stateTime) }} - {{ formatDate(item.endTime) }}
  20. </view>
  21. <view class="tiao">
  22. {{ item.useMoney }}可用
  23. </view>
  24. </view>
  25. </view>
  26. <view class="status">
  27. <view class="order-status">
  28. <image src="@/pages_order/static/coupon/status.png" mode="widthFix" class="status-img">
  29. </image>
  30. <view class="text">
  31. {{ status[item.state] }}
  32. </view>
  33. </view>
  34. <!-- <view class="surplus">
  35. 剩余28天过期
  36. </view> -->
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <uv-empty v-if="couponList.length == 0" text="空空如也" textSize="30rpx" iconSize="200rpx" icon="list"></uv-empty>
  42. </scroll-view>
  43. </template>
  44. <script>
  45. export default {
  46. name: 'CouponList',
  47. data() {
  48. return {
  49. status: ['已领取', '已使用', '已过期'],
  50. queryParams: {
  51. pageNo: 1,
  52. pageSize: 10
  53. },
  54. couponList: [],
  55. total: 0
  56. }
  57. },
  58. methods: {
  59. select(item) {
  60. this.$emit('select', item)
  61. },
  62. //获取优惠券列表
  63. getCouponList() {
  64. let requestData = {
  65. ...this.queryParams,
  66. state: this.state ? this.state : 0
  67. }
  68. this.$api('getRiceCouponList', requestData, res => {
  69. if (res.code == 200) {
  70. this.couponList = res.result.records
  71. this.total = res.result.total
  72. }
  73. })
  74. },
  75. //格式化年月日
  76. formatDate(date) {
  77. if(!date){
  78. return ''
  79. }
  80. date = new Date(date.replace(/-/g,'/'));
  81. // const year = date.getFullYear();
  82. const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1,并且确保是两位数
  83. const day = String(date.getDate()).padStart(2, '0'); // 确保日期是两位数
  84. return `${month}-${day}`;
  85. },
  86. // 加载更多
  87. moreCoupon() {
  88. if (this.queryParams.pageSize > this.total) return
  89. this.queryParams.pageSize += 10
  90. this.getCouponList()
  91. },
  92. },
  93. props: {
  94. state: {
  95. type: Number,
  96. default: 0
  97. },
  98. height: {
  99. default: 'calc(90vh - 180rpx)'
  100. }
  101. },
  102. watch: {
  103. state: function(newValue) {
  104. this.getCouponList()
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .list {
  111. .item {
  112. color: #FDDFCD;
  113. position: relative;
  114. width: calc(100% - 40rpx);
  115. height: 220rpx;
  116. background-size: 100% 100%;
  117. margin: 20rpx;
  118. box-sizing: border-box;
  119. padding: 30rpx;
  120. .coupon-bg {
  121. width: 100%;
  122. position: absolute;
  123. left: 0rpx;
  124. top: 0rpx;
  125. }
  126. .item-con {
  127. display: flex;
  128. align-items: center;
  129. flex-wrap: wrap;
  130. position: absolute;
  131. top: 50%;
  132. left: 0rpx;
  133. transform: translateY(-50%);
  134. z-index: 99;
  135. width: 100%;
  136. .price-time {
  137. display: flex;
  138. width: 65%;
  139. .price {
  140. display: flex;
  141. align-items: center;
  142. .num {
  143. color: #FFF8E9;
  144. font-weight: 900;
  145. font-size: 70rpx;
  146. display: flex;
  147. align-items: flex-end;
  148. .icon {
  149. color: #FFF8E9;
  150. width: 30rpx;
  151. height: 30rpx;
  152. display: flex;
  153. justify-content: center;
  154. align-items: center;
  155. font-size: 20rpx;
  156. border-radius: 14rpx;
  157. margin-bottom: 14rpx;
  158. margin-right: 10rpx;
  159. }
  160. }
  161. }
  162. .date-tiao {
  163. display: flex;
  164. flex-direction: column;
  165. align-items: center;
  166. font-size: 24rpx;
  167. box-sizing: border-box;
  168. padding-left: 20rpx;
  169. .time {}
  170. .tiao {
  171. display: flex;
  172. justify-content: center;
  173. background: #FDE5BA;
  174. border-radius: 40rpx;
  175. color: #FF2E34;
  176. padding: 5rpx 20rpx;
  177. margin-top: 15rpx;
  178. }
  179. }
  180. }
  181. .status {
  182. display: flex;
  183. flex-direction: column;
  184. align-items: center;
  185. justify-content: center;
  186. width: 35%;
  187. color: #FD4231;
  188. padding-top: 30rpx;
  189. .order-status {
  190. position: relative;
  191. width: 180rpx;
  192. .status-img {
  193. position: absolute;
  194. left: 0;
  195. width: 100%;
  196. }
  197. .text {
  198. height: 90rpx;
  199. display: flex;
  200. justify-content: center;
  201. align-items: center;
  202. position: relative;
  203. z-index: 100;
  204. font-size: 34rpx;
  205. font-weight: bold;
  206. }
  207. }
  208. .surplus {
  209. font-size: 22rpx;
  210. text-align: center;
  211. margin-top: 10rpx;
  212. }
  213. }
  214. }
  215. }
  216. .status-0 {
  217. opacity: 1;
  218. }
  219. .status-1 {
  220. opacity: .9;
  221. }
  222. .status-2 {
  223. opacity: .6;
  224. }
  225. .del {
  226. position: absolute;
  227. top: 0;
  228. left: 0;
  229. width: 100%;
  230. height: 100%;
  231. background-color: #ffffff99;
  232. z-index: 99;
  233. }
  234. }
  235. </style>