coupon.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="cu-modal" :class="{ show: visible }">
  3. <view class="mask" @click="close"></view>
  4. <view class="wrapper cu-dialog">
  5. <view
  6. class="content"
  7. v-if="coupons && coupons.length > 0"
  8. :style="{ backgroundImage: 'url(' + ossurl.common.giftBg + ')' }"
  9. >
  10. <view class="contenttip">
  11. 恭喜您,获得
  12. <span class="num">{{ coupons.length }}</span>
  13. 张优惠券
  14. </view>
  15. <scroll-view
  16. scroll-y
  17. :style="{
  18. height: '250px'
  19. }"
  20. >
  21. <view style="padding-bottom: 100rpx">
  22. <view class="cell" v-for="(item, index) in coupons" :key="index">
  23. <view
  24. class="flex-align relative"
  25. style="height: 180rpx;background-size: 100% 100%;"
  26. :style="{ opacity: item.status === 1 ? '1' : '0.6' ,backgroundImage: 'url(' + ossurl.common.gift + ')'}"
  27. >
  28. <view class="left self-stretch flex-column-align-center">
  29. <view>
  30. <text class="font4">¥</text>
  31. <text class="bold marginL2" style="font-size: 60rpx">
  32. {{ item.amount }}
  33. </text>
  34. </view>
  35. <view class="marginT1 font2" style="color: rgba(0, 0, 0, 0.3)">
  36. <text v-if="item.fullAmount > 0">
  37. 满{{ item.fullAmount }}可用
  38. </text>
  39. <text v-else>无门槛</text>
  40. </view>
  41. </view>
  42. <view class="right marginL20 paddingY5">
  43. <view class="font4 bold" style="margin-bottom: 20rpx">
  44. {{ item.name }}
  45. </view>
  46. <view class="font2" style="color: rgba(0, 0, 0, 0.3)">
  47. {{ formatTime(item.endTime) }}过期
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </scroll-view>
  54. </view>
  55. <view class="flex-align-center paddingT15 giftTop">
  56. <image :src="ossurl.common.giftTop" class="giftTopImage" mode="widthFix" />
  57. <view>
  58. <view>
  59. <button class="giftTopBtn" @click="apply">一键领取</button>
  60. </view>
  61. <view class="giftTopTip">优惠券详情可在【我的-优惠券】中查看</view>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="closeBtn" @click="visible = false">
  66. <view class="cuIcon-close"></view>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. import { throttle } from '@/utils'
  72. import resource from '@/utils/resource'
  73. import ossurl from '@/utils/ossurl'
  74. export default {
  75. data() {
  76. return {
  77. resource,
  78. coupons: [],
  79. visible: false,
  80. ossurl
  81. }
  82. },
  83. computed: {},
  84. methods: {
  85. show(coupons) {
  86. this.coupons = coupons
  87. this.visible = true
  88. },
  89. async refresh() {
  90. if (!this.visible) return
  91. const res = await this.$service.wallet.targetCoupon('LUCK', null, false)
  92. if (res && res.length > 0) {
  93. this.coupons = res
  94. } else {
  95. this.close()
  96. }
  97. },
  98. close() {
  99. this.visible = false
  100. this.$emit('close', false)
  101. },
  102. apply() {
  103. if (!this.$common.checkLogin()) return
  104. throttle.call(this.realApply)
  105. },
  106. async realApply() {
  107. const ids = this.coupons.map((item) => item.id)
  108. const res = await this.$service.wallet.receiveCouponAll(ids)
  109. res && this.$emit('success')
  110. this.close()
  111. },
  112. formatTime(val) {
  113. let time = val
  114. time = time.slice(0, 10)
  115. console.log(val,time)
  116. return time
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. .mask {
  123. position: absolute;
  124. left: 0;
  125. right: 0;
  126. top: 0;
  127. bottom: 0;
  128. }
  129. .wrapper {
  130. z-index: 1001;
  131. background-color: transparent;
  132. width: 100vw;
  133. padding-top: 120rpx;
  134. padding-bottom: 160rpx;
  135. position: relative;
  136. background-size: 100% auto;
  137. background-repeat: no-repeat;
  138. padding-left:0 ;
  139. padding-right: 0;
  140. .giftTop {
  141. position: absolute;
  142. bottom: 0rpx;
  143. height: 300rpx;
  144. left: 0;
  145. right: 0;
  146. z-index: 20;
  147. .giftTopImage {
  148. width: 100%;
  149. position: absolute;
  150. left: 0;
  151. right: 0;
  152. top: 0;
  153. bottom: 0;
  154. z-index: -1;
  155. }
  156. .giftTopBtn {
  157. height: 64rpx;
  158. background: #020101;
  159. border-radius: 178rpx 178rpx 178rpx 178rpx;
  160. color: #f0cd49;
  161. // line-height: 40rpx;
  162. font-size: 28rpx;
  163. }
  164. .giftTopTip {
  165. font-size: 24rpx;
  166. font-family: Source Han Sans, Source Han Sans;
  167. font-weight: 400;
  168. color: #000000;
  169. line-height: 44rpx;
  170. margin-top: 24rpx;
  171. }
  172. }
  173. // background-color: rgba(0, 0, 0, 0.6);
  174. .coupon_popup {
  175. position: absolute;
  176. left: 0;
  177. top: 0;
  178. width: 100%;
  179. z-index: -2;
  180. }
  181. .content {
  182. width: 100%;
  183. padding: 24rpx 64rpx;
  184. padding-top:100rpx;
  185. min-height: 640rpx;
  186. background-size: 100% auto;
  187. background-repeat: no-repeat;
  188. .contenttip {
  189. padding: 18rpx 0;
  190. text-align: center;
  191. .num {
  192. display: inline-block;
  193. background: #f0cd49;
  194. border-radius: 4rpx;
  195. padding: 4rpx 12rpx;
  196. font-weight: bold;
  197. }
  198. }
  199. }
  200. .cell {
  201. margin-bottom: 20rpx;
  202. position: relative;
  203. .bg {
  204. position: absolute;
  205. top: 0;
  206. left: 0;
  207. width: 100%;
  208. z-index: -1;
  209. }
  210. .left {
  211. width: 200rpx;
  212. height: 100%;
  213. // border-right: 2rpx dashed #E7E4DA;
  214. }
  215. .right {
  216. // height: 100%;
  217. }
  218. }
  219. }
  220. .closeBtn {
  221. background: #d8d8d8;
  222. position: fixed;
  223. bottom: 180rpx;
  224. right: calc(50% - 32rpx);
  225. width: 64rpx;
  226. height: 64rpx;
  227. border-radius: 50%;
  228. line-height: 64rpx;
  229. text-align: center;
  230. .cuIcon-close {
  231. color: #000;
  232. font-size: 32rpx;
  233. }
  234. }
  235. </style>