index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view>
  3. <base-drawer mode="bottom" :visible="coupon.coupon" background-color="transparent" mask maskClosable @close="close">
  4. <view class="w-full bg--w111-f5f5f5 rd-t-40rpx">
  5. <view class="flex-around-center fs-30 nav" v-if="coupon.count">
  6. <view v-if="coupon.count[2]" class="h-100 flex-y-center" :class="coupon.type === 2 ? 'active' : ''" @tap="setType(2)">商品券</view>
  7. <view v-if="coupon.count[1]" class="h-100 flex-y-center" :class="coupon.type === 1 ? 'active' : ''" @tap="setType(1)">品类券</view>
  8. <view v-if="coupon.count[0]" class="h-100 flex-y-center" :class="coupon.type === 0 ? 'active' : ''" @tap="setType(0)">通用券</view>
  9. </view>
  10. <view class="text-center fs-32 text--w111-333 fw-500 pt-32 relative" v-else>
  11. 优惠券
  12. <view class="w-36 h-36 rd-50-p111- flex-center close-btn" @tap="close">
  13. <text class="iconfont icon-ic_close fs-24 text--w111-666"></text>
  14. </view>
  15. </view>
  16. <view class="px-20 scroll-content">
  17. <scroll-view scroll-y="true" style="max-height: 800rpx">
  18. <view class="coupon-list" v-if="coupon.list.length">
  19. <view v-for="(item, index) in coupon.list" :key="index" @tap="getCouponUser(index, item.id)">
  20. <view class="mt-24 h-170 bg--w111-fff text-center rd-16rpx flex">
  21. <view class="left-bg bg-gradient">
  22. <view class="left-container w-full h-full relative flex-col flex-between-center py-32">
  23. <baseMoney :money="item.coupon_price" symbolSize="28" integerSize="52" decimalSize="28" color="#ffffff" isCoupon v-if="item.coupon_type == 1"></baseMoney>
  24. <view v-else class="text--w111-fff fs-52">
  25. {{ parseFloat(item.coupon_price) / 10 }}
  26. <text class="fs-28">折</text>
  27. </view>
  28. <text class="fs-24 text--w111-fff">满{{ item.use_min_price }}元可用</text>
  29. </view>
  30. </view>
  31. <view class="right-box pt-24 pl-24 pr-14 pb-22 flex-1 flex-col justify-between bg--w111-fff">
  32. <view class="flex-y-center">
  33. <view class="fs-28 fw-500 text--w111-333 lh-40rpx line1 w-360 text-left">{{ item.title }}</view>
  34. </view>
  35. <view class="flex-between-center">
  36. <view class="fs-20 text--w111-666 lh-28rpx" v-if="item.coupon_time">领取后{{ item.coupon_time }}天内可用</view>
  37. <view class="fs-20 text--w111-666 lh-28rpx" v-else>{{ item.start_time ? item.start_time + '-' : '' }}{{ item.end_time }}</view>
  38. <view class="con_btn bg-primary-light text-primary-con w-136 h-52 rd-28rpx fs-22 flex-center" v-if="coupon.count">
  39. {{ item.is_use ? '去使用' : '立即领取' }}
  40. </view>
  41. <view class="iconfont fs-36 pr-14" :class="" v-else>
  42. <view class="iconfont icon-a-ic_CompleteSelect font-color" :class="item.receive_type === 4 ? 'svip' : 'font-num'" v-if="item.is_use"></view>
  43. <view class="iconfont icon-ic_unselect text--w111-ccc" v-else></view>
  44. </view>
  45. </view>
  46. <view class="flex-y-center fs-20 text--w111-999 lh-28rpx mt-20">
  47. <text>{{ item.type | typeFilter }}</text>
  48. <view v-show="item.rule" @tap.stop="toggleRule(index)">
  49. <text class="pl-8 fs-20">| 查看用券规则</text>
  50. <text class="iconfont icon-ic_downarrow fs-20 ml-4"></text>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="rule-desc" v-show="item.ruleshow" v-html="item.rule"></view>
  56. </view>
  57. <view class="h-200"></view>
  58. </view>
  59. <view class="mt-28" v-else>
  60. <emptyPage title="暂无优惠券" src="/statics/images/noCoupon.gif"></emptyPage>
  61. </view>
  62. </scroll-view>
  63. </view>
  64. </view>
  65. </base-drawer>
  66. </view>
  67. </template>
  68. <script>
  69. import { setCouponReceive } from '@/api/api.js';
  70. import { HTTP_REQUEST_URL } from '@/config/app';
  71. import baseDrawer from '@/components/tui-drawer/tui-drawer.vue';
  72. import dayjs from '@/plugin/dayjs/dayjs.min.js';
  73. import emptyPage from '@/components/emptyPage.vue';
  74. export default {
  75. filters: {
  76. dateFormat: function (value) {
  77. return dayjs(value * 1000).format('YYYY/MM/DD');
  78. },
  79. typeFilter(val) {
  80. let obj = {
  81. 0: '通用券',
  82. 1: '品类券',
  83. 2: '商品券',
  84. 3: '品牌券'
  85. };
  86. return obj[val];
  87. }
  88. },
  89. props: {
  90. //打开状态 0=领取优惠券,1=使用优惠券
  91. openType: {
  92. type: Number,
  93. default: 0
  94. },
  95. coupon: {
  96. type: Object,
  97. default: function () {
  98. return {};
  99. }
  100. }
  101. },
  102. components: {
  103. baseDrawer,
  104. emptyPage
  105. },
  106. data() {
  107. return {
  108. type: 0,
  109. imgHost: HTTP_REQUEST_URL
  110. };
  111. },
  112. methods: {
  113. close: function () {
  114. this.$emit('ChangCouponsClone');
  115. this.type = 0;
  116. },
  117. getCouponUser: function (index, id) {
  118. let that = this;
  119. let list = that.coupon.list;
  120. if (list[index].is_use == true && this.openType == 0) {
  121. that.$emit('ChangCoupons', 0);
  122. return;
  123. }
  124. switch (this.openType) {
  125. case 0:
  126. //领取优惠券
  127. setCouponReceive(id)
  128. .then((res) => {
  129. that.$emit('ChangCouponsUseState', index);
  130. that.$util.Tips({
  131. title: '领取成功'
  132. });
  133. })
  134. .catch((err) => {
  135. uni.showToast({
  136. title: err,
  137. icon: 'none'
  138. });
  139. });
  140. break;
  141. case 1:
  142. that.$emit('ChangCoupons', index);
  143. break;
  144. }
  145. },
  146. setType: function (type) {
  147. this.type = type;
  148. this.$emit('tabCouponType', type);
  149. },
  150. toggleRule(index) {
  151. this.$emit('ruleToggle', index);
  152. }
  153. }
  154. };
  155. </script>
  156. <style scoped lang="scss">
  157. .nav {
  158. height: 100rpx;
  159. border-bottom: 1px solid #eee;
  160. }
  161. .active {
  162. border-bottom: 1px solid var(--view-theme);
  163. color: var(--view-theme);
  164. }
  165. .left-bg {
  166. width: 190rpx;
  167. height: 170rpx;
  168. background-size: 100%;
  169. background-repeat: no-repeat;
  170. border-radius: 24rpx 0 0 24rpx;
  171. }
  172. .right-box {
  173. border-radius: 0 24rpx 24rpx 0;
  174. }
  175. .left-container {
  176. background: radial-gradient(circle at 0px 84rpx, #f5f5f5 12rpx, transparent 0px) top;
  177. &:after {
  178. content: '';
  179. position: absolute;
  180. top: 0;
  181. right: 0px;
  182. width: 6rpx;
  183. height: 100%;
  184. background-image: radial-gradient(circle at 6rpx 12rpx, #ffffff 6rpx, transparent 6rpx);
  185. background-size: 6rpx 18rpx;
  186. }
  187. }
  188. .text-primary-con {
  189. color: var(--view-theme);
  190. }
  191. .bg-primary-light {
  192. background: var(--view-minorColorT);
  193. }
  194. .con-border {
  195. border: 1px solid var(--view-theme);
  196. }
  197. .scroll-content {
  198. height: 800rpx;
  199. .coupon-list{
  200. margin-bottom: 120rpx;
  201. }
  202. }
  203. .rule-desc {
  204. margin-top: -16rpx;
  205. padding: 40rpx 24rpx 24rpx;
  206. white-space: pre-wrap;
  207. font-size: 20rpx;
  208. line-height: 28rpx;
  209. background-color: #fff;
  210. border-radius: 0 0 16rpx 16rpx;
  211. color: #999;
  212. }
  213. .close-btn {
  214. position: absolute;
  215. right: 32rpx;
  216. top: 36rpx;
  217. background-color: #eee;
  218. }
  219. </style>