coupon.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <view ref="container">
  3. <view class="tui-coupon-list">
  4. <view class="tui-coupon-item tui-top20" v-for="(item, index) in couponsList" :key="index">
  5. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/purpleShop/bg_coupon_3x.png" class="tui-coupon-bg" mode="widthFix"></image>
  6. <view class="tui-coupon-item-left">
  7. <view class="tui-coupon-price-box" :class="{ 'tui-color-grey': item.receiveCount>0 }">
  8. <view class="tui-coupon-price-sign">¥</view>
  9. <view class="tui-coupon-price" :class="{ 'tui-price-small': false }">{{ item.couponPrice }}</view>
  10. </view>
  11. <view class="tui-coupon-intro">满{{ item.useMinPrice }}元可用</view>
  12. </view>
  13. <view class="tui-coupon-item-right">
  14. <view class="tui-coupon-content">
  15. <view class="tui-coupon-title-box">
  16. <view class="tui-coupon-title">{{ item.couponName }}</view>
  17. </view>
  18. <view class="tui-coupon-rule">
  19. <view class="tui-rule-box tui-padding-btm">
  20. <view class="tui-coupon-circle"></view>
  21. <view class="tui-coupon-text">不可叠加使用</view>
  22. </view>
  23. <view class="tui-rule-box">
  24. <view class="tui-coupon-circle"></view>
  25. <view class="tui-coupon-text">{{ item.limitTime }} 到期</view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="tui-btn-box">
  31. <view class="btn receive" @click="show(item)">查看</view>
  32. </view>
  33. </view>
  34. </view>
  35. <Loading :loaded="loadend" :loading="loading"></Loading>
  36. <!--暂无优惠券-->
  37. <view v-if="couponsList.length == 0 && page > 1" class="no-data-box" >
  38. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/purpleShop/no_data.png" mode="aspectFit"></image>
  39. <view class="empty-title">暂无数据</view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import { getCouponList, receive } from '@/api/user'
  45. import Loading from '@/components/Loading'
  46. export default {
  47. name: 'getCoupon',
  48. components: {
  49. Loading,
  50. },
  51. props: {},
  52. data: function() {
  53. return {
  54. page: 1,
  55. limit: 10,
  56. couponsList: [],
  57. loading: false,
  58. loadend: false,
  59. }
  60. },
  61. onLoad(options) {
  62. },
  63. mounted: function() {
  64. },
  65. onShow() {
  66. this.getCouponList()
  67. },
  68. onReachBottom() {
  69. !this.loading && this.getCouponList()
  70. },
  71. methods: {
  72. show(item){
  73. uni.navigateTo({
  74. url: './couponDetails?id=' +item.id
  75. })
  76. },
  77. getCouponList() {
  78. if (this.loading) return //阻止下次请求(false可以进行请求);
  79. if (this.loadend) return //阻止结束当前请求(false可以进行请求);
  80. this.loading = true
  81. let q = { couponType:1,page: this.page, pageSize: this.limit }
  82. getCouponList(q).then(res => {
  83. this.loading = false
  84. this.couponsList.push.apply(this.couponsList, res.data.list)
  85. this.loadend = res.data.list.length < this.limit //判断所有数据是否加载完成;
  86. this.page = this.page + 1
  87. })
  88. },
  89. },
  90. }
  91. </script>
  92. <style lang="less" scoped>
  93. page {
  94. background-color: #f5f5f5;
  95. }
  96. .container {
  97. padding-bottom: env(safe-area-inset-bottom);
  98. }
  99. .tui-coupon-list {
  100. width: 100%;
  101. padding: 0 25rpx;
  102. box-sizing: border-box;
  103. }
  104. .tui-coupon-banner {
  105. width: 100%;
  106. }
  107. .tui-coupon-item {
  108. width: 100%;
  109. height: 210rpx;
  110. position: relative;
  111. display: flex;
  112. align-items: center;
  113. padding-right: 30rpx;
  114. box-sizing: border-box;
  115. overflow: hidden;
  116. }
  117. .tui-coupon-bg {
  118. width: 100%;
  119. height: 210rpx;
  120. position: absolute;
  121. left: 0;
  122. top: 0;
  123. z-index: 1;
  124. }
  125. .tui-coupon-sign {
  126. height: 110rpx;
  127. width: 110rpx;
  128. position: absolute;
  129. z-index: 9;
  130. top: -30rpx;
  131. right: 40rpx;
  132. }
  133. .tui-coupon-item-left {
  134. width: 218rpx;
  135. height: 210rpx;
  136. position: relative;
  137. z-index: 2;
  138. display: flex;
  139. align-items: center;
  140. justify-content: center;
  141. flex-direction: column;
  142. flex-shrink: 0;
  143. }
  144. .tui-coupon-price-box {
  145. display: flex;
  146. color: #e41f19;
  147. align-items: flex-end;
  148. }
  149. .tui-coupon-price-sign {
  150. font-size: 30rpx;
  151. }
  152. .tui-coupon-price {
  153. font-size: 70rpx;
  154. line-height: 68rpx;
  155. font-weight: bold;
  156. }
  157. .tui-price-small {
  158. font-size: 58rpx !important;
  159. line-height: 56rpx !important;
  160. }
  161. .tui-coupon-intro {
  162. background: #f7f7f7;
  163. padding: 8rpx 10rpx;
  164. font-size: 26rpx;
  165. line-height: 26rpx;
  166. font-weight: 400;
  167. color: #666;
  168. margin-top: 18rpx;
  169. }
  170. .tui-coupon-item-right {
  171. flex: 1;
  172. height: 210rpx;
  173. position: relative;
  174. z-index: 2;
  175. display: flex;
  176. align-items: center;
  177. justify-content: space-between;
  178. padding-left: 24rpx;
  179. box-sizing: border-box;
  180. overflow: hidden;
  181. }
  182. .tui-coupon-content {
  183. width: 82%;
  184. display: flex;
  185. flex-direction: column;
  186. justify-content: center;
  187. }
  188. .tui-coupon-title-box {
  189. display: flex;
  190. align-items: center;
  191. }
  192. .tui-coupon-btn {
  193. padding: 6rpx;
  194. background: #ffebeb;
  195. color: #e41f19;
  196. font-size: 25rpx;
  197. line-height: 25rpx;
  198. display: flex;
  199. align-items: center;
  200. justify-content: center;
  201. transform: scale(0.9);
  202. transform-origin: 0 center;
  203. border-radius: 4rpx;
  204. flex-shrink: 0;
  205. }
  206. .tui-color-grey {
  207. color: #888 !important;
  208. }
  209. .tui-bg-grey {
  210. background: #f0f0f0 !important;
  211. color: #888 !important;
  212. }
  213. .tui-coupon-title {
  214. width: 100%;
  215. font-size: 26rpx;
  216. color: #333;
  217. white-space: nowrap;
  218. overflow: hidden;
  219. text-overflow: ellipsis;
  220. }
  221. .tui-coupon-rule {
  222. padding-top: 52rpx;
  223. }
  224. .tui-rule-box {
  225. display: flex;
  226. align-items: center;
  227. transform: scale(0.8);
  228. transform-origin: 0 100%;
  229. }
  230. .tui-padding-btm {
  231. padding-bottom: 6rpx;
  232. }
  233. .tui-coupon-circle {
  234. width: 8rpx;
  235. height: 8rpx;
  236. background: rgb(160, 160, 160);
  237. border-radius: 50%;
  238. }
  239. .tui-coupon-text {
  240. font-size: 28rpx;
  241. line-height: 28rpx;
  242. font-weight: 400;
  243. color: #666;
  244. padding-left: 8rpx;
  245. white-space: nowrap;
  246. }
  247. .tui-top20 {
  248. margin-top: 20rpx;
  249. }
  250. .tui-coupon-title {
  251. font-size: 28rpx;
  252. line-height: 28rpx;
  253. }
  254. .tui-coupon-radio {
  255. transform: scale(0.7);
  256. transform-origin: 100% center;
  257. }
  258. .tui-btn-box {
  259. position: absolute;
  260. right: 20rpx;
  261. bottom: 40rpx;
  262. z-index: 10;
  263. .btn{
  264. width: 155upx;
  265. height: 64upx;
  266. line-height: 64upx;
  267. font-size: 26upx;
  268. font-family: PingFang SC;
  269. font-weight: 500;
  270. text-align: center;
  271. border-radius: 32upx;
  272. margin-left: 15upx;
  273. &.cancel{
  274. border: 1px solid red;
  275. color: red;
  276. }
  277. &.receive{
  278. background: red;
  279. color: #FFFFFF;
  280. }
  281. }
  282. }
  283. </style>