index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <view :style="viewColor">
  3. <view class='coupon-list-window animated' :class='coupon.coupon==true?"slideInUp":""'>
  4. <view class='title'>
  5. <view class="item">优惠券<text class='iconfont icon-guanbi' @tap='close'></text></view>
  6. </view>
  7. <view class='coupon-list' v-if="coupon.list.length">
  8. <view class='item acea-row row-center-wrapper' v-for="(item,index) in coupon.list" @click="getCouponUser(index,item)"
  9. :key='index'>
  10. <view class='money acea-row row-column row-center-wrapper' :style="{ 'background-image': `url(${domain}/static/diy/couponBg${keyColor}.png)` }">
  11. <view>¥<text class='num'>{{item.coupon_price}}</text></view>
  12. <view class="pic-num">满{{item.use_min_price}}元可用</view>
  13. </view>
  14. <view class='text'>
  15. <view class='condition line1'>
  16. <span class='line-title' v-if='item.type===0'>店铺券</span>
  17. <span class='line-title' v-else-if='item.type===1'>商品券</span>
  18. <span>{{item.title}}</span>
  19. </view>
  20. <view class='data acea-row row-between-wrapper'>
  21. <block v-if="item.coupon_type == 1">
  22. <view>{{ item.use_start_time |timeYMD }}-{{ item.use_end_time |timeYMD}}</view>
  23. </block>
  24. <block v-if="item.coupon_type == 0">
  25. <view>领取后{{ item.coupon_time}}天内可用</view>
  26. </block>
  27. <view class='gray iconfont icon-yilingqu2' v-if="item.issue"></view>
  28. <view class='bnt b-color' v-else>{{coupon.statusTile || '立即领取'}}</view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 无优惠券 -->
  34. <view class='pictrue' v-else>
  35. <image :src="`${domain}/static/images/noCoupon.png`"></image>
  36. </view>
  37. </view>
  38. <view class='mask' catchtouchmove="true" :hidden='coupon.coupon==false' @click='close'></view>
  39. </view>
  40. </template>
  41. <script>
  42. // +----------------------------------------------------------------------
  43. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  44. // +----------------------------------------------------------------------
  45. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  46. // +----------------------------------------------------------------------
  47. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  48. // +----------------------------------------------------------------------
  49. // | Author: CRMEB Team <admin@crmeb.com>
  50. // +----------------------------------------------------------------------
  51. import { setCouponReceive } from '@/api/api.js';
  52. import { mapGetters } from "vuex";
  53. import { HTTP_REQUEST_URL } from '@/config/app';
  54. export default {
  55. props: {
  56. //打开状态 0=领取优惠券,1=使用优惠券
  57. openType: {
  58. type: Number,
  59. default: 0,
  60. },
  61. coupon: {
  62. type: Object,
  63. default: function() {
  64. return {};
  65. }
  66. },
  67. showTitle: {
  68. type: Number,
  69. default: 1,
  70. },
  71. isShop: {
  72. type: Number,
  73. default: 0,
  74. },
  75. },
  76. filters: {
  77. timeYMD: function (value) {
  78. if(value){
  79. var newDate=/\d{4}-\d{1,2}-\d{1,2}/g.exec(value)
  80. return newDate[0]
  81. }
  82. }
  83. },
  84. computed: mapGetters(['viewColor','keyColor']),
  85. data() {
  86. return {
  87. domain: HTTP_REQUEST_URL,
  88. tabList:['商品券','店铺券'],
  89. tabIndex:this.isShop,
  90. couponArr:[],
  91. };
  92. },
  93. mounted() {
  94. this.$nextTick(function(){
  95. this.couponArr = this.coupon.list
  96. })
  97. },
  98. methods: {
  99. close: function() {
  100. this.$emit('ChangCouponsClose');
  101. },
  102. getCouponUser: function(index, item) {
  103. let that = this;
  104. if (item.issue) return true;
  105. switch (this.openType) {
  106. case 0:
  107. //领取优惠券
  108. setCouponReceive(item.coupon_id).then(res => {
  109. item.issue = true
  110. that.$emit('ChangCouponsUseState', index);
  111. that.$util.Tips({
  112. title: "领取成功"
  113. });
  114. that.$emit('ChangCoupons', item);
  115. })
  116. break;
  117. case 1:
  118. that.$emit('ChangCoupons', index);
  119. break;
  120. }
  121. },
  122. bindTab(item,index){
  123. this.tabIndex = index
  124. this.filterArray()
  125. }
  126. }
  127. }
  128. </script>
  129. <style scoped lang="scss">
  130. .animated{
  131. animation-duration:.3s
  132. }
  133. .title{
  134. display: flex;
  135. border-radius: 16rpx 16rpx 0 0;
  136. .item{
  137. position: relative;
  138. flex: 1;
  139. font-size: 28rpx;
  140. color: #999999;
  141. &::after{
  142. content: ' ';
  143. position: absolute;
  144. left: 50%;
  145. bottom: 18rpx;
  146. width:50rpx;
  147. height:5rpx;
  148. background:transparent;
  149. border-radius:3px;
  150. transform: translateX(-50%);
  151. }
  152. &.on{
  153. color: #282828;
  154. &::after{
  155. background: var(--view-theme);
  156. }
  157. }
  158. }
  159. }
  160. .b-color {
  161. background-color: var(--view-theme);
  162. }
  163. .coupon-list{
  164. padding: 30rpx;
  165. .item{
  166. box-shadow:0px 2px 10px 0px rgba(0, 0, 0, 0.06);
  167. }
  168. }
  169. .coupon-list-window {
  170. position: fixed;
  171. bottom: 0;
  172. left: 0;
  173. width: 100%;
  174. background-color: #fff;
  175. border-radius: 16rpx 16rpx 0 0;
  176. z-index: 555;
  177. transform: translate3d(0, 100%, 0);
  178. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  179. }
  180. .coupon-list-window.on {
  181. animation: aminup ;
  182. }
  183. .coupon-list-window .title {
  184. height: 106rpx;
  185. width: 100%;
  186. text-align: center;
  187. line-height: 106rpx;
  188. font-size: 32rpx;
  189. font-weight: bold;
  190. position: relative;
  191. border: 1px solid #f5f5f5;
  192. }
  193. .coupon-list-window .title .iconfont {
  194. position: absolute;
  195. right: 30rpx;
  196. top: 50%;
  197. transform: translateY(-50%);
  198. font-size: 35rpx;
  199. color: #8a8a8a;
  200. font-weight: normal;
  201. }
  202. .coupon-list-window .coupon-list {
  203. margin: 0 0 50rpx 0;
  204. height: 550rpx;
  205. overflow: auto;
  206. }
  207. .coupon-list-window .pictrue {
  208. width: 414rpx;
  209. height: 336rpx;
  210. margin: 0 auto 50rpx auto;
  211. }
  212. .coupon-list-window .pictrue image {
  213. width: 100%;
  214. height: 100%;
  215. }
  216. .pic-num {
  217. color: #fff;
  218. font-size: 24rpx;
  219. }
  220. .line-title {
  221. width: 90rpx;
  222. padding: 0 10rpx;
  223. box-sizing: border-box;
  224. background: var(--view-minorColor);
  225. border: 1px solid var(--view-theme);
  226. opacity: 1;
  227. border-radius: 20rpx;
  228. font-size: 20rpx;
  229. color: var(--view-theme);
  230. margin-right: 12rpx;
  231. }
  232. .line-title.gray {
  233. border-color: #BBB;
  234. color: #bbb;
  235. background-color: #F5F5F5;
  236. }
  237. </style>