123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- <template>
- <view class="app-exclusive-coupon" :style="{'background-color': `${noneColor ? '' : background}`}">
- <view class="app-top dir-left-nowrap main-between" v-if="showTop">
- <view class="app-left dir-left-nowrap main-between cross-center">
- <icon class="app-icon"></icon>
- <text class="app-title">专享优惠券</text>
- </view>
- <view class="app-right dir-left-nowrap main-between cross-center">
- <app-jump-button form url="/pages/coupon/list/list" open_type="navigate">
- <text class="app-text">更多</text>
- <icon class="app-icon"></icon>
- </app-jump-button>
- </view>
- </view>
- <view class="app-bottom">
- <scroll-view scroll-x class="app-scroll dir-left-nowrap">
- <view v-for="(item, index) in coupon_list"
- :key="index"
- class="app-item"
- :style="{backgroundImage: `url(${item.is_receive === '0' ? unclaimedBg : item.is_receive === '1' ? receiveBg : ''})`}"
- >
- <app-form-id @click="receive(index)">
- <view class="dir-left-nowrap main-left">
- <view class="app-text-left">
- <view class="app-text-top">
- <template v-if="item.type === '1'">
- <text class="app-number discount" :style="{color: textColor}">{{item.discount}}</text>
- </template>
- <template v-else>
- <text class="app-symbol" :style="{color: textColor}">¥</text>
- <text class="app-number" :style="{color: textColor}">{{item.sub_price}}</text>
- </template>
- </view>
- <text class="app-text-bottom" :style="{color: textColor}">满{{item.min_price}}元可用</text>
- </view>
- <view class="app-text-right">
- <text :style="{color: textColor}">{{item.is_receive === '0' ? receiveTip : item.is_receive > '0' ? '已领取' : ''}}</text>
- </view>
- </view>
- </app-form-id>
- </view>
- </scroll-view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: 'app-exclusive-coupon',
- props: {
- receiveBg: {
- type: String,
- default: function() {
- return '';
- }
- },
- textColor: {
- type: String,
- default: function() {
- return "#ffffff";
- }
- },
- unclaimedBg: {
- type: String,
- default: function() {
- return ''
- }
- },
- index: {
- type: Number,
- },
- sign: {
- type: String,
- },
- coupon_list: {
- type: Array,
- default: function() {
- return [
- ]
- }
- },
- showTop: {
- type: Boolean,
- default() {
- return true;
- }
- },
- noneColor: {
- type: Boolean,
- default() {
- return false;
- }
- }
- },
- data() {
- return {
- list: []
- };
- },
- watch: {
- coupon_list: {
- handler() {
- // this.list = this.coupon_list;
- },
- immediate: true
- }
- },
- computed: {
- receiveTip() {
- let receiveTip = '立即领取';
- if (this.sign === 'integral-mall') {
- receiveTip = '立即兑换';
- }
- return receiveTip;
- }
- },
- methods: {
- receive(index) {
- let list = this.coupon_list;
- if (this.sign == 'integral-mall') {
- this.$jump({
- url: list[index].page_url,
- open_type: 'navigate'
- });
- return ;
- }
- if (list[index].is_receive == 1) {
- uni.showToast({
- mask: true,
- title: '已领取',
- icon: 'none'
- });
- return true;
- }
- uni.showLoading({
- mask: true,
- title: '领取中'
- });
- this.$request({
- url: this.$api.coupon.receive,
- data: {
- coupon_id: list[index].id
- }
- }).then(e => {
- uni.hideLoading();
- if (e.code === 0) {
- list[index].is_receive = '1';
- this.$store.dispatch('page/actionSetCoupon', {
- list: [list[index]],
- type: 'receive'
- });
- this.list = list;
- }
- }).catch(() => {
- uni.hideLoading();
- });
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .app-exclusive-coupon {
- width: #{750rpx};
- .app-top {
- width: #{750rpx};
- height: #{80rpx};
- border-bottom: #{1rpx} solid #e2e2e2;
- .app-icon {
- background-repeat: no-repeat;
- background-size: 100% 100%;
- }
- .app-left {
- width: #{215rpx};
- height: #{80rpx};
- margin-left: #{24rpx};
- .app-icon {
- width: #{46rpx};
- height: #{46rpx};
- background-image: url("../../../static/image/icon/coupon-icon.png");
- }
- .app-title {
- font-size: #{28rpx};
- color: #ff8831;
- }
- }
- .app-right {
- height: #{80rpx};
- width: #{75rpx};
- margin-right: #{24rpx};
- .app-icon {
- width: #{12rpx};
- height: #{22rpx};
- background-image: url("../../../static/image/icon/arrow-right.png");
- }
- .app-text {
- font-size: #{26rpx};
- color: #999999;
- }
- }
- }
- .app-bottom {
- padding-top: #{16rpx};
- padding-left: #{8rpx};
- padding-bottom: #{16rpx};
- height: #{130+16+16rpx};
- width: #{750rpx};
- .app-scroll {
- height: #{130+16+16rpx};
- width: #{750-24rpx};
- white-space: nowrap;
- }
- .app-item {
- width: #{256rpx};
- height: #{130rpx};
- display: inline-block;
- margin-left: #{16rpx};
- background-repeat: no-repeat;
- background-size: 100% 100%;
- >view {
- width: #{256rpx};
- height: #{130rpx};
- }
- .app-text-left {
- width: #{199rpx};
- height: #{130rpx};
- .app-text-top {
- height: #{78rpx};
- padding-top: #{1rpx};
- overflow: hidden;
- text-align: center;
- .app-symbol {
- display: inline-block;
- height: #{78rpx};
- font-size: #{20rpx};
- }
- .app-number {
- display: inline-block;
- height: #{78rpx};
- padding-top: #{26rpx};
- font-size: #{40rpx};
- width: #{159rpx};
- }
- .discount:after {
- content: '折';
- font-size: 75%;
- }
- }
- .app-text-bottom {
- height: #{50rpx};
- width: #{199rpx};
- text-align: center;
- font-size: #{20rpx};
- display: inline-block;
- }
- }
- .app-text-right {
- width: #{50rpx};
- height: #{130rpx};
- text {
- height: #{130rpx};
- width: #{50rpx};
- display: inline-block;
- text-align: center;
- line-height: #{50rpx};
- font-size: #{20rpx};
- margin-left: #{2rpx};
- writing-mode: vertical-rl;
- letter-spacing: #{5rpx};
- }
- }
- }
- }
- }
- </style>
|