绿满眶商城微信小程序-uniapp
zxl
4 天以前 c9928dd4f6d25e2339ea1400f59ec58674a927a7
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
136
137
138
139
140
141
142
143
144
<template>
  <view class="wrapper" v-if="res">
    <view v-for="(prom, index) in Object.keys(res)" :key="index">
      <view>
        <view v-if="prom.split('-')[0] == 'FULL_DISCOUNT'">
          <div class="res_prom_item" v-if="res[prom].fullMinus">
            <u-tag text="满减" type="error"></u-tag>
            <!-- TODO 后续将优化为可点击的商品以及优惠券显示明细 -->
            <span class="pro-text"
              >满{{ res[prom].fullMoney }}元 立减现金
              <span class="price">{{ res[prom].fullMinus }}元</span>
              <span v-if="res[prom].couponFlag"> 赠送<span>优惠券</span></span>
              <span v-if="res[prom].pointFlag"> 赠送{{ res[prom].point }}积分</span>
              <span v-if="res[prom].giftFlag"> 赠送商品</span>
              <span v-if="res[prom].freeFreightFlag">赠送包邮服务</span>
            </span>
          </div>
          <div class="res_prom_item" v-if="res[prom].fullRate && res[prom].fullRateFlag">
            <u-tag text="打折" type="error"></u-tag>
            <span class="pro-text"
              >满{{ res[prom].fullMoney }}元,立享<span class="price"
                >{{ res[prom].fullRate }}折</span
              >优惠</span
            >
          </div>
        </view>
 
        <view v-if="prom.split('-')[0] == 'PINTUAN'">
          <div class="res_prom_item" v-if="res[prom].requiredNum">
            <u-tag text="拼团" type="error"></u-tag>
            <span class="pro-text"
              >{{ res[prom].requiredNum }}人拼团 限购<span class="price"
                >{{ res[prom].limitNum }}件</span
              ></span
            >
          </div>
        </view>
 
        <view v-if="prom.split('-')[0] == 'SECKILL'">
          <div class="res_prom_item">
            <u-tag text="限时抢购" type="error"></u-tag>
            <span class="pro-text">限时抢购</span>
          </div>
        </view>
 
        <view v-if="prom.split('-')[0] == 'POINTS_GOODS'">
          <div class="res_prom_item">
            <u-tag text="积分活动" type="error"></u-tag>
            <span class="pro-text">当前商品参与积分活动。<span @click="handClickToJoinPromotion(prom)" class="href">点击此处参与活动</span></span>
          </div>
        </view>
 
         <view v-if="prom.split('-')[0] == 'KANJIA'">
          <div class="res_prom_item">
            <u-tag text="砍价活动" type="error"></u-tag>
            <span class="pro-text">当前商品参与砍价活动。<span @click="handClickToJoinPromotion(prom)" class="href">点击此处参与活动</span></span>
          </div>
        </view>
      </view>
    </view>
    <view v-if="!res">暂无促销活动</view>
  </view>
</template>
<script>
import '@/components/uview-components/uview-ui';
 
export default {
  data() {
    return {};
  },
  watch: {
    res: {
      handler() {
        if (this.res && this.res.length != 0) {
          Object.keys(this.res).forEach((item) => {
            if (item != "COUPON") {
              let key = item.split("-")[0];
              this.res[item]._key = key;
            }
          });
        }
      },
 
      immediate: true,
    },
  },
 
  props: {
    // 父组件传递回来的数据
    res: {
      type: null,
      default: "",
    },
  },
  mounted() {},
  methods: {
    // 跳转到参与商品活动的详情列表中
    handClickToJoinPromotion(val){
    
      const promotion = {
        "POINTS_GOODS": `/pages/promotion/point/detail?id=${this.res[val].id}`,
        "KANJIA": `/pages/promotion/bargain/detail?id=${this.res[val].id}`,
      }
 
      uni.navigateTo({
        url:promotion[val.split('-')[0]]
      })
 
    }
  },
};
</script>
<style lang="scss" scoped>
.pro-text {
  font-size: 26rpx;
  font-family: PingFang SC, PingFang SC-Regular;
  font-weight: 400;
  text-align: left;
  color: #333333;
  margin-left: 20rpx;
  > span {
    margin-right: 15rpx;
  }
}
 
.wrapper {
  display: block;
}
 
/deep/ .u-mode-light-error {
  border: none;
}
 
.res_prom_item {
  margin: 20rpx 0;
}
 
.price_image {
  display: block;
}
.href{
  color: $main-color;
}
</style>