index.vue 8.1 KB

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