绿满眶商城微信小程序-uniapp
xiangpei
6 天以前 70738d032bd80f5b13075f8a13045ff4de57c2c3
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
<template>
  <view class="group-list">
    <view class="group-name">拼购列表</view>
    <view v-if="assembleOrder.length != 0">
      <view class="group-item" v-for="(order, index) in assembleOrder" :key="index">
        <view class="group-item-user">
          <u-image shape="circle" width="40px" height="40px" :src="order.face || userImage"></u-image>
          <span class="group-item-name">{{ order.nickName | noPassByName }}</span>
        </view>
        <view>
          <span class="group-item-name">还差{{ order.toBeGroupedNum }}人成团</span>
        </view>
        <view>
          <u-button size="mini" :custom-style="customStyle" @click="buy(order)"
            >去参团</u-button
          >
        </view>
      </view>
    </view>
    <view v-else class="nomore">
      <u-empty text="暂无拼团信息" mode="list"></u-empty>
    </view>
  </view>
</template>
 
<script>
import '@/components/uview-components/uview-ui';
 
import * as API_Promotions from "@/api/promotions";
import configs from '@/config/config'
export default {
  data() {
    return {
      configs,
      userImage:configs.defaultUserPhoto,
 
      customStyle: {
        background: this.$lightColor,
        color: "#fff",
      },
      /** 待成团订单 */
      assembleOrder: "",
 
      /** 查看更多待成团订单 */
      assembleOrderAll: "",
    };
  },
  props: ["res"],
 
  watch: {
    res: {
      handler() {
        if (this.res && this.res.length != 0) {
          Object.keys(this.res).forEach((item) => {
            let key = item.split("-");
            if (key && key[0] == "PINTUAN") {
              this.getAssembleInfo(item);
            }
          });
        }
      },
      immediate: true,
    },
 
    // assembleOrder(val) {
    //   this.$emit("assembleOrder", val);
    // },
  },
  computed: {},
  mounted() {},
  methods: {
    // 获取此商品所有待成团的订单
    getAssembleInfo(val) {
      let id = this.res[val].id;
      API_Promotions.getPromotionGroupMember(id).then((res) => {
        if (res.data.success) {
          console.warn(res.data.result);
          this.assembleOrder = res.data.result;
        }
      });
    },
 
    buy(order) {
      this.$emit("to-assemble-buy-now", order);
    },
  },
};
</script>
 
<style lang="scss" scoped>
@import "../product.scss";
.nomore {
  padding: 10rpx 0;
}
 
.group-item {
  margin: 30rpx 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
 
.group-item-user {
  display: flex;
  align-items: center;
}
 
.group-item-name {
  margin-left: 23rpx;
  font-size: 24rpx;
  color: #999999;
  font-weight: 400;
}
</style>