index.vue 6.3 KB

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