| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- <template>
- <view class="diy-coupon"
- :style="{ background: itemData.style.background, padding: itemData.style.paddingTop + 'px 20rpx' }">
- <scroll-view scroll-x="true">
- <view class="swiper swiper-list">
- <view class="coupon-item" :class="'bg-' + item.color.text" v-for="(item, index) in listData"
- :key="index">
- <view class="side-line left-side-line" ><text class="round" :style="{ background: itemData.style.background}"></text></view>
- <view class="side-line right-side-line"><text class="round" :style="{ background: itemData.style.background}"></text></view>
- <view class="left-type d-c-c">{{ item.coupon_type.text }}</view>
- <view class="center-content pr">
- <view class="content-top">
- <template v-if="item.coupon_type.value == 10">
- <text class="f22">¥</text>
- <text class="f28 fb">{{ item.reduce_price }}</text>
- </template>
- <template v-if="item.coupon_type.value == 20">
- <text class="f28 fb">{{ item.discount }}</text>
- <text>折</text>
- </template>
- </view>
- <view class="content-bottom">
- <text class="f20">{{ item.name }}</text>
- </view>
- </view>
- <!--领取-->
- <view v-if="item.state.value == 1" class="right-receive d-c-c" @click="receiveCoupon(index)">
- 立即领取
- </view>
- <view v-else class="right-receive no-receive d-c-c">
- {{ item.state.text }}
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- /*是否显示点*/
- indicatorDots: false,
- /*是否自动*/
- autoplay: true,
- /*切换时间*/
- interval: 5000,
- /*动画过渡时间*/
- duration: 1000,
- /*数据列表*/
- listData: []
- };
- },
- props: ['itemData'],
- created() {
- this.listData = this.itemData.data;
- },
- methods: {
- scroll(e) {},
- /**
- * 领取优惠券
- */
- receiveCoupon: function(index) {
- let self = this;
- let item = self.listData[index];
- if (item.state.value == 0) {
- return false;
- }
- self._post(
- 'user.coupon/receive', {
- coupon_id: item.coupon_id
- },
- function(result) {
- uni.showToast({
- title: '领取成功',
- icon: 'success',
- mask: true,
- duration: 2000
- });
- item.state.value = 0;
- item.state.text = '已领取';
- }
- );
- }
- }
- };
- </script>
- <style>
- .diy-coupon {
- margin:0 20rpx;
- border-radius: 20rpx;
-
- }
- .f-s-0 {
- flex-shrink: 0;
- }
- .diy-coupon .swiper {
- height: 174rpx;
- display: flex;
- justify-content: flex-start;
- align-items: center;
- overflow-x: auto;
- }
- .diy-coupon .coupon-item {
- width: 196rpx;
- height: 158rpx;
- color: #ffffff;
- flex-shrink: 0;
- margin: 8rpx;
- position: relative;
- border-radius: 8rpx;
- overflow: hidden;
- background: #feefef;
- color: #ef3325;
- display: block;
- }
- .diy-coupon .coupon-item.bg-red .right-receive {
- background: #fe3d30;
- }
- .diy-coupon .coupon-item.bg-blue .right-receive{
- background: #178ed9;
- }
- .diy-coupon .coupon-item.bg-yellow .right-receive{
- background: #fe961a;
- }
- .diy-coupon .coupon-item.bg-violet .right-receive{
- background: #ab0bf6;
- }
- .diy-coupon .coupon-item .left-type {
- padding: 4rpx 8rpx;
- font-size: 18rpx;
- line-height: 18rpx;
- text-align: center;
- position: absolute;
- right: 0;
- top: 0;
- color: #ffffff;
- background: linear-gradient(to right, #ff5b00, #fe8802);
- border-bottom-left-radius: 8rpx;
- }
- .diy-coupon .left-side-line {
- position: absolute;
- width: 12rpx;
- bottom: 36rpx;
- left: -6rpx;
- overflow: hidden;
- }
- .diy-coupon .right-side-line {
- position: absolute;
- width: 12rpx;
- bottom: 36rpx;
- right: -6rpx;
- overflow: hidden;
- }
- .diy-coupon .side-line .round {
- display: block;
- width: 12rpx;
- height: 12rpx;
- border-radius: 50%;
- margin: 4rpx 0;
- background: #ffffff;
- }
- .diy-coupon .center-content::before {
- top: 0;
- right: -16rpx;
- border-radius: 0 0 15rpx 15rpx;
- }
- .diy-coupon .coupon-item .center-content {
- padding: 26rpx 23rpx;
- display: flex;
- justify-content: space-between;
- flex-direction: column;
- align-items: flex-start;
- flex: 1;
- height: 112rpx;
- box-sizing: border-box;
- }
- .diy-coupon .coupon-item .center-content .content-top {
- height: 28rpx;
- line-height: 28rpx;
- }
- .diy-coupon .coupon-item .center-content .content-datatime {
- padding: 4rpx 10rpx;
- border-radius: 30rpx;
- font-size: 20rpx;
- background: rgba(0, 0, 0, .2);
- }
- .diy-coupon .coupon-item .right-receive {
- height: 46rpx;
- width: 100%;
- text-align: center;
- font-size: 20rpx;
- line-height: 20rpx;
- text-align: center;
- color: #FFFFFF;
- }
- .diy-coupon .coupon-item .no-receive {
- background: #acacac !important;
- color: #ffffff;
- }
- </style>
|