绿满眶商城微信小程序-uniapp
xiangpei
2025-05-09 c3e6cdbb29580e77444541c7953aca33581a4267
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<template>
    <view>
        <view v-for="(promotionItem, promotionIndex) in promotion" :key="promotionIndex" class="promotion_row" @click="shutMask(1)">
            <view v-if="res != null" v-for="(item, index) in Object.keys(res)" :key="index">
                <div class="promotion_col" v-if="item.split('-')[0] == promotionItem.value && item.split('-')[0] == 'FULL_DISCOUNT'">
                    <!-- 满减,折扣 -->
                    <div class="flex">
                        <view class="deg_tag">{{ promotionItem.title }}</view>
                        <div class="text proText">满{{ res[item].fullMoney }}元,立享优惠</div>
                    </div>
                </div>
                <div class="promotion_col" v-if="item.split('-')[0] == promotionItem.value && item.split('-')[0] == 'PINTUAN'">
                    <!-- 拼团 -->
                    <div class="flex">
                        <view class="deg_tag">{{ promotionItem.title }}</view>
                        <div class="text proText">{{ res[item].promotionName }}</div>
                    </div>
                </div>
                <div class="promotion_col" v-if="item.split('-')[0] == promotionItem.value && item.split('-')[0] == 'POINTS_GOODS'">
                    <!-- 积分活动 -->
                    <div class="flex">
                        <view class="deg_tag">{{ promotionItem.title }}</view>
                        <div class="text proText">{{ res[item].promotionName }}</div>
                    </div>
                </div>
                <div class="promotion_col" v-if="item.split('-')[0] == promotionItem.value && item.split('-')[0] == 'KANJIA'">
                    <!-- 砍价活动 -->
                    <div class="flex">
                        <view class="deg_tag">{{ promotionItem.title }}</view>
                        <div class="text proText"></div>
                    </div>
                </div>
                <div class="promotion_col" v-if="item.split('-')[0] == promotionItem.value && item.split('-')[0] == 'SECKILL'">
                    <!-- 限时抢购 -->
                    <div class="flex">
                        <view class="deg_tag">{{ promotionItem.title }}</view>
                        <div class="text proText">{{ res[item].promotionName }}</div>
                    </div>
                </div>
            </view>
 
            <view class="promotion_row">
                <view>
                    <div class="promotion_col coupon" v-if="couponList && promotionIndex == 1">
                        <!-- 优惠券 -->
 
                        <div><view class="deg_tag">优惠券</view></div>
                    </div>
                </view>
            </view>
        </view>
 
        <view v-if="this.res != null && Object.keys(res).length == 0">暂无促销信息</view>
    </view>
</template>
 
<script>
import promotion from './promotion_type';
export default {
    data() {
        return {
            promotion,
            couponList: ''
        };
    },
    props: {
        // 父组件传递回来的数据
        res: {
            type: null,
            default: {}
        }
    },
    watch: {
        res: {
            handler() {
                if (this.res && this.res.length != 0 && this.res != null) {
                    Object.keys(this.res).forEach(item => {
                        let key = item.split('-')[0];
                        this.res[item].__key = key;
 
                        if (item.split('-')[0] == 'COUPON') {
                            this.couponList = 'COUPON';
                        }
                    });
                }
            },
            immediate: true
        }
    },
    mounted() {},
    methods: {
        // 此方法条用父级方法
        shutMask(val) {
            this.$emit('shutMasks', val);
        }
    }
};
</script>
 
<style lang="scss" scoped>
.deg_tag {
    color: $price-color;
    padding: 0 4rpx;
    border: 2rpx solid $price-color;
    font-size: 22rpx;
}
 
.promotion_col {
    /**/
    // margin: 0 0 17rpx 0;
 
    padding: 0 !important;
 
    margin: 10rpx 0;
}
.promotion_row {
}
.flex {
    display: flex;
}
.proText {
    font-size: 26rpx;
    font-family: PingFang SC, PingFang SC-Regular;
    font-weight: 400;
    text-align: left;
    color: #333333;
    margin-left: 20rpx;
}
/deep/ .u-mode-light-error {
    border: none;
}
.coupon{
    display: flex;
}
</style>