You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

251 lines
6.2 KiB

3 months ago
  1. <template>
  2. <view>
  3. <view class='coupon-list-window' :class='coupon.coupon==true?"on":""'>
  4. <view v-if="!orderShow" class="nav acea-row row-around">
  5. <view :class="['acea-row', 'row-middle', type === 1 ? 'on' : '']" @click="setType(1)">通用券</view>
  6. <view :class="['acea-row', 'row-middle', type === 2 ? 'on' : '']" @click="setType(2)">商品券</view>
  7. <view :class="['acea-row', 'row-middle', type === 3 ? 'on' : '']" @click="setType(3)">品类券</view>
  8. </view>
  9. <!-- <view class="occupy" v-if="!orderShow"></view> -->
  10. <!-- <view class='title'>优惠券<text class='iconfont icon-guanbi' @click='close'></text></view> -->
  11. <view class='coupon-list' :style="{'margin-top':!orderShow?'0':'50rpx'}">
  12. <block v-if="coupon.list.length">
  13. <!-- <view class='item acea-row row-center-wrapper' v-for="(item,index) in coupon.list" :key='index'> -->
  14. <view class='item acea-row row-center-wrapper' v-for="(item,index) in coupon.list"
  15. @click="getCouponUser(index,item.id)" :key='index'>
  16. <view class='money acea-row row-column row-center-wrapper' :class='item.isUse?"moneyGray":"main_bg"'>
  17. <view><text class='num' :style="[{'font-size':item.money.length>=7?'42rpx':'60rpx'}]" >{{item.money?Number(item.money):''}}</text></view>
  18. <view class="pic-num">{{item.minPrice}}元可用</view>
  19. </view>
  20. <view class='text'>
  21. <view class='condition line2'>
  22. <span class='line-title' :class='item.isUse?"gray":"select"' v-if='item.useType===1'>通用</span>
  23. <span class='line-title' :class='item.isUse?"gray":"select"'
  24. v-else-if='item.useType===3'>品类</span>
  25. <span class='line-title' :class='item.isUse?"gray":"select"' v-else>商品</span>
  26. <span>{{item.name}}</span>
  27. </view>
  28. <view class='data acea-row row-between-wrapper'>
  29. <view v-if="item.day>0">领取后{{item.day}}天内可用</view>
  30. <view v-else>
  31. {{ item.useStartTimeStr&& item.useEndTimeStr ? item.useStartTimeStr + " - " + item.useEndTimeStr : ""}}
  32. </view>
  33. <view class='bnt gray' v-if="item.isUse">{{item.use_title || '已领取'}}</view>
  34. <view class='bnt main_bg' v-else>{{coupon.statusTile || '立即领取'}}</view>
  35. </view>
  36. </view>
  37. </view>
  38. </block>
  39. <!-- 无优惠券 -->
  40. <view class='pictrue' v-else>
  41. <image :src="urlDomain+'crmebimage/perset/staticImg/noCoupon.png'"></image>
  42. </view>
  43. </view>
  44. </view>
  45. <view class='mask' catchtouchmove="true" :hidden='coupon.coupon==false' @click='close'></view>
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. setCouponReceive
  51. } from '@/api/api.js';
  52. export default {
  53. props: {
  54. //打开状态 0=领取优惠券,1=使用优惠券
  55. openType: {
  56. type: Number,
  57. default: 0,
  58. },
  59. coupon: {
  60. type: Object,
  61. default: function() {
  62. return {};
  63. }
  64. },
  65. //下单页面使用优惠券组件不展示tab切换页
  66. orderShow: {
  67. type: String,
  68. default: function() {
  69. return '';
  70. }
  71. },
  72. typeNum:{
  73. type:Number,
  74. default:0
  75. }
  76. },
  77. data() {
  78. return {
  79. urlDomain: this.$Cache.get("imgHost"),
  80. type: 1,
  81. };
  82. },
  83. methods: {
  84. close: function() {
  85. this.type = this.typeNum;
  86. this.$emit('ChangCouponsClone');
  87. },
  88. getCouponUser: function(index, id) {
  89. let that = this;
  90. let list = that.coupon.list;
  91. if (list[index].isUse == true && this.openType == 0) return true;
  92. switch (this.openType) {
  93. case 0:
  94. //领取优惠券
  95. let ids = [];
  96. ids.push(id);
  97. setCouponReceive(id).then(res => {
  98. that.$emit('ChangCouponsUseState', index);
  99. that.$util.Tips({
  100. title: "领取成功"
  101. }, function(res) {
  102. return that.$util.Tips({
  103. title: res
  104. });
  105. });
  106. that.$emit('ChangCoupons', list[index]);
  107. })
  108. break;
  109. case 1:
  110. that.$emit('ChangCoupons', index);
  111. break;
  112. }
  113. },
  114. setType: function(type) {
  115. this.$emit('tabCouponType', type);
  116. this.type = type;
  117. }
  118. }
  119. }
  120. </script>
  121. <style scoped lang="scss">
  122. .coupon-list-window {
  123. position: fixed;
  124. bottom: 0;
  125. left: 0;
  126. width: 100%;
  127. background-color: #f5f5f5;
  128. border-radius: 16rpx 16rpx 0 0;
  129. z-index: 555;
  130. transform: translate3d(0, 100%, 0);
  131. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  132. }
  133. .coupon-list-window.on {
  134. transform: translate3d(0, 0, 0);
  135. }
  136. .coupon-list-window .title {
  137. height: 124rpx;
  138. width: 100%;
  139. text-align: center;
  140. line-height: 124rpx;
  141. font-size: 32rpx;
  142. font-weight: bold;
  143. position: relative;
  144. }
  145. .coupon-list-window .title .iconfont {
  146. position: absolute;
  147. right: 30rpx;
  148. top: 50%;
  149. transform: translateY(-50%);
  150. font-size: 35rpx;
  151. color: #8a8a8a;
  152. font-weight: normal;
  153. }
  154. .coupon-list-window .coupon-list {
  155. margin: 0 0 30rpx 0;
  156. height: 823rpx;
  157. overflow: auto;
  158. padding-top: 30rpx;
  159. }
  160. .coupon-list-window .pictrue {
  161. width: 414rpx;
  162. height: 336rpx;
  163. margin: 208rpx auto;
  164. }
  165. .coupon-list-window .pictrue image {
  166. width: 100%;
  167. height: 100%;
  168. }
  169. .pic-num {
  170. color: #fff;
  171. font-size: 24rpx;
  172. }
  173. .line-title {
  174. width: 90rpx;
  175. padding: 0 10rpx;
  176. box-sizing: border-box;
  177. background: #fff;
  178. border: 1px solid rgba(232, 51, 35, 1);
  179. opacity: 1;
  180. border-radius: 20rpx;
  181. font-size: 20rpx;
  182. color: #E83323;
  183. margin-right: 12rpx;
  184. }
  185. .line-title.gray {
  186. border-color: #BBB;
  187. color: #bbb;
  188. background-color: #F5F5F5;
  189. }
  190. .nav {
  191. // position: absolute;
  192. // top: 0;
  193. // left: 0;
  194. width: 100%;
  195. height: 96rpx;
  196. border-bottom: 2rpx solid #F5F5F5;
  197. border-top-left-radius: 16rpx;
  198. border-top-right-radius: 16rpx;
  199. background-color: #FFFFFF;
  200. font-size: 30rpx;
  201. color: #999999;
  202. }
  203. .nav .acea-row {
  204. border-top: 5rpx solid transparent;
  205. border-bottom: 5rpx solid transparent;
  206. }
  207. .nav .acea-row.on {
  208. @include tab_border_bottom(theme);
  209. color: #282828;
  210. }
  211. .nav .acea-row:only-child {
  212. border-bottom-color: transparent;
  213. }
  214. .occupy {
  215. height: 106rpx;
  216. }
  217. .coupon-list .item {
  218. margin-bottom: 20rpx;
  219. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.06);
  220. }
  221. .coupon-list .item .money {
  222. font-weight: normal;
  223. }
  224. .main_bg{
  225. @include main_bg_color(theme);
  226. }
  227. .select{
  228. @include main_color(theme);
  229. @include coupons_border_color(theme);
  230. }
  231. </style>