index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <view>
  3. <!-- 优惠券下拉列表 -->
  4. <view class='coupon-list-window' :class='[coupon.coupon==true?"on":"",coupon.goFrom==1?"cart":""]'>
  5. <view v-if="coupon.count" class="nav acea-row row-around">
  6. <view v-if="coupon.count[2]" :class="['acea-row', 'row-middle', coupon.type === 2 ? 'on' : '']" @click="setType(2)">商品券</view>
  7. <view v-if="coupon.count[1]" :class="['acea-row', 'row-middle', coupon.type === 1 ? 'on' : '']" @click="setType(1)">品类券</view>
  8. <view v-if="coupon.count[0]" :class="['acea-row', 'row-middle', coupon.type === 0 ? 'on' : '']" @click="setType(0)">通用券</view>
  9. </view>
  10. <view class='title' v-else>优惠券<text class='iconfont icon-guanbi' @click='close'></text></view>
  11. <view v-if="coupon.count" class="occupy"></view>
  12. <view class='coupon-list' v-if="coupon.list.length">
  13. <view class='item acea-row row-center-wrapper' v-for="(item,index) in coupon.list" @click="getCouponUser(index,item.id)"
  14. :key='index' :class="{svip: item.receive_type === 4}">
  15. <view class="moneyCon acea-row row-center-wrapper">
  16. <view class='money acea-row row-column row-center-wrapper' :class='item.is_use && coupon.count?"moneyGray":""'>
  17. <view><text v-if="item.coupon_type==1">¥</text><text class='num'>{{item.coupon_type==1?item.coupon_price:parseFloat(item.coupon_price)/10}}</text><text v-if="item.coupon_type==2">折</text></view>
  18. <view class="pic-num" v-if="item.use_min_price > 0">满{{item.use_min_price}}元可用</view>
  19. <view class="pic-num" v-else>无门槛券</view>
  20. </view>
  21. </view>
  22. <view class='text'>
  23. <view class='condition line2' :class="coupon.count?'':'order'">
  24. <span class='line-title' :class='item.is_use && coupon.count?"gray":""' v-if='item.type===0'>通用劵</span>
  25. <span class='line-title' :class='item.is_use && coupon.count?"gray":""' v-else-if='item.type===1'>品类券</span>
  26. <span class='line-title' :class='item.is_use && coupon.count?"gray":""' v-else>商品券</span>
  27. <image src='../../static/images/fvip.png' class="pic" v-if="item.receive_type===4"></image>
  28. <span class='name'>{{item.title}}</span>
  29. </view>
  30. <!-- #ifdef H5 || APP-PLUS -->
  31. <slot name="center" :item="item"></slot>
  32. <!-- #endif -->
  33. <!-- #ifdef MP -->
  34. <slot name="center{{index}}"></slot>
  35. <!-- #endif -->
  36. <view class='data acea-row row-between-wrapper'>
  37. <view v-if="item.coupon_time && !openType">领取后{{item.coupon_time}}天内可用</view>
  38. <view v-else>{{ item.start_time ? item.start_time + "-" : ""}}{{ item.end_time }}</view>
  39. <view v-if="coupon.count">
  40. <view class='bnt gray' v-if="item.is_use">{{item.use_title || '已领取'}}</view>
  41. <view class='bnt bg-color' v-else>{{coupon.statusTile || '立即领取'}}</view>
  42. </view>
  43. <view v-else class="orderCou">
  44. <view class="iconfont icon-xuanzhong11" :class="item.receive_type === 4?'svip':'font-num'" v-if="item.is_use"></view>
  45. <view class="iconfont icon-weixuan" v-else></view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- 无优惠券 -->
  52. <view class='pictrue' v-else>
  53. <image :src="imgHost + '/statics/images/noCoupon.png'"></image>
  54. </view>
  55. </view>
  56. <view class='mask' catchtouchmove="true" :hidden='coupon.coupon==false' @click='close'></view>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. setCouponReceive
  62. } from '@/api/api.js';
  63. import {HTTP_REQUEST_URL} from '@/config/app';
  64. export default {
  65. props: {
  66. //打开状态 0=领取优惠券,1=使用优惠券
  67. openType: {
  68. type: Number,
  69. default: 0,
  70. },
  71. coupon: {
  72. type: Object,
  73. default: function() {
  74. return {};
  75. }
  76. }
  77. },
  78. data() {
  79. return {
  80. type: 0,
  81. imgHost:HTTP_REQUEST_URL
  82. };
  83. },
  84. methods: {
  85. close: function() {
  86. this.$emit('ChangCouponsClone');
  87. this.type = 0;
  88. },
  89. getCouponUser: function(index, id) {
  90. let that = this;
  91. let list = that.coupon.list;
  92. if (list[index].is_use == true && this.openType == 0) return true;
  93. switch (this.openType) {
  94. case 0:
  95. //领取优惠券
  96. setCouponReceive(id).then(res => {
  97. that.$emit('ChangCouponsUseState', index);
  98. that.$util.Tips({
  99. title: "领取成功"
  100. });
  101. // that.$emit('ChangCoupons', list[index]);
  102. }).catch(err => {
  103. uni.showToast({
  104. title: err,
  105. icon: 'none'
  106. });
  107. })
  108. break;
  109. case 1:
  110. that.$emit('ChangCoupons', index);
  111. break;
  112. }
  113. },
  114. setType: function(type) {
  115. this.type = type;
  116. this.$emit('tabCouponType', type);
  117. }
  118. }
  119. }
  120. </script>
  121. <style scoped lang="scss">
  122. .orderCou{
  123. position: absolute;
  124. right: 20rpx;
  125. top:50%;
  126. margin-top: -20rpx;
  127. }
  128. .orderCou .iconfont{
  129. font-size: 40rpx;
  130. }
  131. .orderCou .svip{
  132. color:#EDBB75;
  133. }
  134. .coupon-list .item .text{
  135. position: relative;
  136. }
  137. .coupon-list .item .text .condition.order{
  138. width: 350rpx;
  139. }
  140. .coupon-list-window .coupon-list .text .condition .pic {
  141. width: 30rpx;
  142. height: 30rpx;
  143. margin-right: 10rpx;
  144. vertical-align: middle;
  145. }
  146. .coupon-list-window .coupon-list .text .condition .name {
  147. vertical-align: middle;
  148. font-size: 26rpx;
  149. font-weight: 500;
  150. }
  151. .coupon-list-window {
  152. position: fixed;
  153. bottom: 0;
  154. left: 0;
  155. width: 100%;
  156. background-color: #FFFFFF;
  157. border-radius: 16rpx 16rpx 0 0;
  158. z-index: 555;
  159. transform: translate3d(0, 100%, 0);
  160. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  161. }
  162. .coupon-list-window.on {
  163. transform: translate3d(0, 0, 0);
  164. }
  165. .coupon-list-window.cart{
  166. padding-bottom: 150rpx;
  167. padding-bottom: calc(150rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  168. padding-bottom: calc(150rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  169. }
  170. .coupon-list-window .title {
  171. height: 124rpx;
  172. width: 100%;
  173. text-align: center;
  174. line-height: 124rpx;
  175. font-size: 32rpx;
  176. font-weight: bold;
  177. position: relative;
  178. }
  179. .coupon-list-window .title .iconfont {
  180. position: absolute;
  181. right: 30rpx;
  182. top: 50%;
  183. transform: translateY(-50%);
  184. font-size: 35rpx;
  185. color: #8a8a8a;
  186. font-weight: normal;
  187. }
  188. .coupon-list-window .coupon-list {
  189. margin: 0 0 50rpx 0;
  190. height: 721rpx;
  191. padding-top: 28rpx;
  192. overflow: auto;
  193. }
  194. .coupon-list-window .pictrue {
  195. width: 414rpx;
  196. height: 336rpx;
  197. margin: 192rpx auto 243rpx auto;
  198. }
  199. .coupon-list-window .pictrue image {
  200. width: 100%;
  201. height: 100%;
  202. }
  203. .pic-num {
  204. color: #fff;
  205. font-size: 24rpx;
  206. }
  207. .line-title {
  208. width: 70rpx;
  209. height: 32rpx !important;
  210. padding: 0 10rpx;
  211. line-height: 30rpx;
  212. text-align: center;
  213. background: var(--view-minorColorT);
  214. border: 1px solid var(--view-theme);
  215. opacity: 1;
  216. border-radius: 20rpx;
  217. font-size: 18rpx;
  218. color: var(--view-theme);
  219. margin-right: 12rpx;
  220. box-sizing: border-box;
  221. }
  222. .line-title.gray {
  223. border-color: #C1C1C1!important;
  224. color: #C1C1C1!important;
  225. background-color: #F7F7F7!important;
  226. }
  227. .nav {
  228. position: absolute;
  229. top: 0;
  230. left: 0;
  231. width: 100%;
  232. height: 106rpx;
  233. border-bottom: 2rpx solid #F5F5F5;
  234. border-top-left-radius: 16rpx;
  235. border-top-right-radius: 16rpx;
  236. background-color: #FFFFFF;
  237. font-size: 30rpx;
  238. color: #999999;
  239. }
  240. .nav .acea-row {
  241. border-top: 5rpx solid transparent;
  242. border-bottom: 5rpx solid transparent;
  243. }
  244. .nav .acea-row.on {
  245. border-bottom-color: var(--view-theme);
  246. color: #282828;
  247. }
  248. .nav .acea-row:only-child {
  249. border-bottom-color: transparent;
  250. }
  251. .occupy {
  252. height: 106rpx;
  253. }
  254. .coupon-list .item {
  255. margin-bottom: 18rpx;
  256. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.06);
  257. }
  258. .coupon-list .item .money {
  259. font-weight: normal;
  260. }
  261. </style>