coupon.vue 7.1 KB

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