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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<template>
    <view class="fight-group-detail" v-if="!loadding">
        <!--产品-->
        <view class="product-info p30 d-s-c bg-white">
            <view class="product-cover">
                <image :src="productData.product.image[0].file_path" mode="aspectFit"></image>
            </view>
            <view class="info flex-1 ml30 f30">
                <text>{{productData.product.product_name}}</text>
                <view class="mt20">
                    <text>{{productData.assemble_num}}人团:</text>
                    <text class="ml30 red">¥</text>
                    <text class="fb red f34">{{productData.assembleSku[0].assemble_price}}</text>
                </view>
            </view>
        </view>
        
        <!--拼团人-->
        <view class="fight-users mt20 bg-white">
            <!--成员列表-->
            <view class="user-list d-c-c">
                <view class="user-box pr" v-for="(item,index) in billData.billUser" :key="index">
                    <text class="leader" v-if="index==0">团长</text>
                    <image :src="item.user.avatarUrl" mode="aspectFit"></image>
                </view>
                <view class="user-box user-who d-c-c">
                    ?
                </view>
            </view>
            <view class="d-c-c mt30 gray3">
                还差<text class="fb">{{dif_people}}</text>人成团
            </view>
            <view class="mt20 d-c-c gray6 f34">
                <Countdown :config="countdownConfig" @returnVal="returnValFunc"></Countdown>
            </view>
        </view>
        
        <view class="leader-info d-b-c p30">
            <view class="photo d-s-c">
                <image :src="billData.user.avatarUrl" mode="aspectFit"></image>
                <text class="ml20">{{billData.user.nickName}}</text>
            </view>
            <view class="gray9">
                <text>{{billData.create_time}}</text>
                <text class="ml10">开团</text>
            </view>
        </view>
        
        <!--底部按钮-->
        <view class="fight-group-btns">
            <button v-if="!reallyAssemble" type="default" class="btn-red" @click="gotoAssemble(billData)">去拼团</button>
            <button v-else type="default" class="btn-red" open-type="share" @click="shareFunc">分享拼团</button>
        </view>
        
        <!--分享-->
        <share :isMpShare="isMpShare" :product_id="product_id" @close="closeShare"></share>
        <!--app分享-->
        <AppShare :isAppShare="isAppShare" :appParams="appParams" @close="closeAppShare"></AppShare>
    </view>
</template>
 
<script>
    import Countdown from '@/components/countdown/countdown.vue';
    import share from '@/components/mp-share.vue';
    import AppShare from '@/components/app-share.vue';
    export default {
        components:{
            Countdown,
            share,
            AppShare
        },
        data() {
            return {
                /*是否正在加载*/
                loadding:true,
                /*拼团组ID*/
                assemble_bill_id:null,
                /*拼团组对象*/
                billData:{},
                /*商品对象*/
                productData:{},
                /*倒计时配置*/
                countdownConfig: {
                    type:'text',
                    /*开始时间*/
                    startstamp: 0,
                    /*结束时间*/
                    endstamp: 0
                },
                /*是否分享*/
                isMpShare:false,
                /*还差几人*/
                dif_people: 0,
                /*是否已经参团*/
                reallyAssemble:false,
                /*app分享*/
                isAppShare: false,
                appParams: {
                    title: '',
                    summary: '',
                    path: ''
                }
            }
        },
        onLoad(e) {
            this.assemble_bill_id = e.assemble_bill_id;
            //#ifdef H5
            if (this.isWeixin()) {
                this.url = window.location.href;
            }
            //#endif
        },
        mounted() {
            /*获取产品详情*/
            this.getData();
        },
        methods: {
            
            /*获取数据*/
            getData() {
                let self = this;
                uni.showLoading({
                    title: '加载中'
                });
                self._get(
                    'plus.assemble.bill/detail',
                    {
                        assemble_bill_id: self.assemble_bill_id,
                        url: self.url
                    },
                    function(res) {
                        self.billData=res.data.bill;
                        self.productData=res.data.product
                        self.countdownConfig.startstamp=0;
                        self.countdownConfig.endstamp=self.billData.end_time;
                        self.dif_people = self.productData.assemble_num-self.billData.billUser.length<0?0:self.productData.assemble_num-self.billData.billUser.length
                        // 配置微信分享参数
                        //#ifdef H5
                        if (self.url != '') {
                            let params = {
                                assemble_bill_id: self.assemble_bill_id
                            };
                            self.configWx(res.data.share.signPackage, res.data.share.shareParams, params);
                        }
                        //#endif
                        console.log(self.billData.billUser);
                        self.reallyAssemble=self.hasAssemble(self.billData.billUser);
                        
                        self.loadding = false;
                        uni.hideLoading();
                    }
                );
            },
            
            /*查看是否已经拼团*/
            hasAssemble(list){
                let flag=false;
                let user_id = this.getUserId();
                for(let i=0;i<list.length;i++){
                    if(user_id==list[i].user_id){
                        flag=true;
                        break;
                    }
                }
                return flag;
            },
            
            /*分享*/
            shareFunc(){
                let self = this;
                //#ifndef APP-PLUS
                self.isMpShare = true;
                //#endif
                //#ifdef APP-PLUS
                self.appParams.title = '【仅限' + self.dif_people + '个名额】,快来参与拼团吧';
                self.appParams.summary = self.productData.product.product_name;
                // 构建页面参数
                let params = self.getShareUrlParams({
                    assemble_bill_id: self.assemble_bill_id
                });
                self.appParams.path = '/pages/plus/assemble/fight-group-detail/fight-group-detail?' + params;
                self.appParams.image = self.productData.product.image[0].file_path;
                self.isAppShare = true;
                //#endif
            },
            /*关闭分享*/
            closeShare(){
                this.isMpShare=false;
            },
            //关闭分享
            closeAppShare(data) {
                this.isAppShare = false;
            },
            /*返回状态*/
            returnValFunc(){},
            /*小程序分享*/
            onShareAppMessage() {
                let self = this;
                // 构建页面参数
                let params = self.getShareUrlParams({
                    assemble_bill_id: self.assemble_bill_id
                });
                return {
                    title: '【仅限'+self.dif_people+'个名额】,快来参与拼团吧',
                    path: '/pages/plus/assemble/fight-group-detail/fight-group-detail?' + params
                };
            },
            
            /*去拼团*/
            gotoAssemble(e){
                let url='pages/plus/assemble/detail/detail?assemble_product_id=' + e.assemble_product_id+'&assemble_bill_id='+e.assemble_bill_id
                this.gotoPage(url);
            }
        }
    }
</script>
 
<style>
.fight-group-detail{ padding-bottom: 100rpx;}
.fight-group-detail .product-cover image{ width: 200rpx; height: 200rpx;}
.fight-group-detail .fight-users .user-box{ width: 80rpx; height: 80rpx; margin: 10rpx; border-radius: 50%; border: 1px dashed #CCCCCC;}
.fight-group-detail .fight-users{ padding: 30rpx;}
.fight-group-detail .fight-users .user-box image{width: 80rpx; height: 80rpx;border-radius: 50%;}
.fight-group-detail .fight-users .user-box .leader{ position: absolute; top: -20rpx; left: 50%; margin-left: -30rpx; width: 60rpx; height: 30rpx; line-height: 30rpx; text-align: center; color: #FFFFFF; border-radius: 30rpx; border: 1px solid #FFFFFF; background: red;}
.fight-group-detail .fight-users .user-box.user-who{ font-size: 50rpx; color: #999999;}
.fight-group-detail .leader-info .photo image{ width: 60rpx; height: 60rpx; border-radius: 50%; }
.fight-group-btns{ position: fixed; right: 0; bottom: 0; left: 0; padding: 0 30rpx; box-sizing: border-box;}
.fight-group-btns button.btn-red{ margin-bottom: 20rpx; height: 80rpx; line-height: 80rpx; border-radius: 40rpx;}
</style>