zhaojs
2023-06-10 69ea24e8fdfb41fc48c3fdb8c444645c13b1bbc4
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
<template>
    <view class="inviteFriends-wrapper wrapperLayer">
        <titleBar :titleText='"邀请好友"' :pageForm='"inviteFriends"'></titleBar>
        <view class="swiper-container">
            <view class="tower-swiper" @touchmove="TowerMove" @touchstart="TowerStart" @touchend="TowerEnd">
                <view class="tower-item" :class="item.zIndex==1?'none':''" v-for="(item,index) in swiperList" :key="index" :style="[{'--index': item.zIndex,'--left':item.mLeft}]"
                 :data-direction="direction">
                    <view class="swiper-item">
                        <image :src="item.img" mode="aspectFill"></image>
                        <view class="code rowCenCen">
                            <image :src="codeSrc" mode="aspectFill"></image>
                        </view>
                    </view>
                </view>
            </view>
        </view>
        <view class="pagebottom-container pd30 colCen">
            <view class="inviteCode-container pd30 rowCenBet">
                <view class="left-code">
                    我的邀请码:{{user.invitation_code}}
                </view>
                <view class="clipbtn rowCenCen" @tap="clipcode()">
                    <view>复制</view>
                </view>
            </view>
 
            <view class="invite-step colCen">
                <view class="step-title">
                    邀请步骤
                </view>
                <view class="step-list">
                    1. 将邀请码或海报分享给好友</br>
                    ⒉ 好友注册时填写您的邀请码</br>
                    3. 好友即可0元购买改商品</br>
                    未来他/她有购物订单,您可获得佣金奖励,并自动计入您的帐户
                </view>
            </view>
            
            <view class="invit_cont">
                <view class="invit_v" @click="checkVideo(0)"><image src='https://yanfeiobpub.obs.cn-east-3.myhuaweicloud.com/dfg/vi_jiaocheng.png'></image></view>
                <view class="invit_v" @click="checkVideo(1)"><image src='https://yanfeiobpub.obs.cn-east-3.myhuaweicloud.com/dfg/vi_yaoqing.png'></image></view>
            </view>
            
            <view class="bottom-options-container rowCenAro">
                <view class="option-items-container colCen" @tap='copyLink()'>
                    <image class="icon-box" src="../../static/images/mine/link.png" mode="aspectFill"></image>
                    <view class="option-name">
                        分享链接
                    </view>
                    <view class="option-explain">
                        一键授权
                    </view>
                </view>
                <view class="option-items-container colCen" @tap='showModel()'>
                    <image class="icon-box" src="../../static/images/mine/pic.png" mode="aspectFill"></image>
                    <view class="option-name">
                        分享海报
                    </view>
                    <view class="option-explain">
                        强力锁粉
                    </view>
                </view>
                <!-- <view class="option-items-container colCen" @tap="goodsnew()">
                    <image class="icon-box" src="../../static/images/mine/code.png" mode="aspectFill"></image>
                    <view class="option-name">
                        商品拉新
                    </view>
                    <view class="option-explain">
                        助力社群
                    </view>
                </view> -->
            </view>
        </view>
 
 
        <u-popup v-model="shareShow" mode="bottom" border-radius="14" height="auto">
            <view class="share-container colCen">
                <view class="share-title rowCenCen">
                    <view class="title-text">
                        分享到
                    </view>
                </view>
                <view class="shareList rowCen">
                    <view class="items-container colCen" @tap='sharewx()'>
                        <view class="icon-box defIcon">
                            <image src="../../static/images/mine/wxshare.png" mode=""></image>
                        </view>
                        <view class="modeName">
                            微信好友
                        </view>
                    </view>
                    <view class="items-container colCen" @tap='sharepyq()'>
                        <view class="icon-box defIcon">
                            <image src="../../static/images/mine/sharefriend.png" mode=""></image>
                        </view>
                        <view class="modeName">
                            朋友圈
                        </view>
                    </view>
                    <view class="items-container colCen" @tap='shareqq()'>
                        <view class="icon-box defIcon">
                            <image src="../../static/images/mine/shareqq.png" mode=""></image>
                        </view>
                        <view class="modeName">
                            QQ
                        </view>
                    </view>
                    <view class="items-container colCen" @tap='savepic()'>
                        <view class="icon-box defIcon">
                            <image src="../../static/images/app/saveimg.png" mode=""></image>
                        </view>
                        <view class="modeName">
                            保存相册
                        </view>
                    </view>
                </view>
 
                <view class="cancelbox rowCenCen" @click="closeModel()">
                    <view class="canceltext">
                        取消
                    </view>
                </view>
            </view>
        </u-popup>
        <canvas canvas-id="qrcode" class="canvass" style="width: 260rpx;height: 260rpx;opacity: 0;" />
        <canvas canvas-id="sharePoster" class="canvass" :style="{ width: canvasInfo.canvasW + 'px', height: canvasInfo.canvasH + 'px'}" />
    </view>
</template>
 
<script>
    import util from '../../utils/utils.js' 
    import uQRCode from '../../utils/qrcode.js'
    import titleBar from '../../components/backTitlebar.vue'
    let qrcode
    export default {
        components: {
            titleBar
        },
        data() {
            return {
                code: '',
                codeSrc: '',
                direction: '',
                user: '',
                swiperList: [],
 
                shareShow: false,
                bannerUrl: '',
 
                CVS: null,
                canvasInfo: {
                    canvasW: 750,
                    canvasH: 1334,
                },
                shareUrl: ''
            }
        },
        onLoad() {
            this.getpageInfo()
            this.user = util.getCacheSync('userInfo')
            this.makeCode()
        },
        methods: {
            checkVideo(type)
            {
                console.log(type)
                if(type==1)
                {
                    uni.navigateTo({
                        url: '/pages/webView/webView?url=http://dfgapp.ushopvip.com/html/fxguid.html'
                    })
                }
                else{
                    uni.navigateTo({
                        url: '/pages/webView/webView?url=http://dfgapp.ushopvip.com/html/newuse.html'
                    })
                }
                
            },
            showModel() {
                this.$nextTick(()=>{
                    this.getbanner()
                })
            },
            closeModel() {
                this.shareShow = false
            },
 
            async getbanner() {
                uni.showLoading()
                let goodsPic = await this.getImageInfo(this.bannerUrl) //广告图
                console.log(goodsPic);
                this.CVS = uni.createCanvasContext('sharePoster', this);
                this.canvasInfo.canvasW = 750
                this.canvasInfo.canvasH = 1334
                this.CVS.setFillStyle('white'); //canvas背景颜色
                this.CVS.fillRect(0, 0, 750, 1334); //canvas画布大小 
 
                this.CVS.drawImage(goodsPic.path, 0, 0, 750, 1334);
                this.CVS.drawImage(this.codeSrc, 259, 1034, 232, 232);
                
                this.CVS.setFontSize(28); //设置标题字体大小
                this.CVS.setFillStyle('#ffffff'); //设置标题文本颜色
                
                this.CVS.setTextAlign('center')
                this.CVS.fillText('邀请码:' + this.user.invitation_code, 374, 1296)
                this.CVS.draw(false, res => {
                    console.log(res);
                    uni.canvasToTempFilePath({
                        canvasId: 'sharePoster',
                        success: ress => {
                            console.log(ress);
                            uni.hideLoading()
                            this.shareShow = true
                            this.shareUrl = ress.tempFilePath
                        }
                    });
                });
            },
 
            async getImageInfo(imgSrc) {
                return new Promise((resolve, errs) => {
                    uni.getImageInfo({
                        src: imgSrc,
                        success: image => {
                            resolve(image);
                        },
                        fail: err => {
                            errs(err);
                            uni.hideLoading()
                        }
                    });
                });
            },
 
            async makeCode() {
                var globalData = util.getCacheSync('appInfo')
                console.log(globalData)
                //var txt = globalData.appAndroidDownUrl
                var txt = globalData.invite_url + "?code="+this.user.invitation_code
                console.log(txt)
                // #ifdef APP-PLUS
                //txt = plus.os.name == 'Android' ? globalData.appAndroidDownUrl : globalData.appIosDownUrl, // 生成内容
                    // #endif
                    qrcode = new uQRCode({
                        context: this, // 上下文环境
                        canvasId: 'qrcode', // canvas-id
                        usingComponents: false, // 是否是自定义组件
                        loadingText: '', // loading文字
                        text: txt, // 生成内容
                        size: uni.upx2px(260), // 二维码大小
                        cbResult: res => { // 生成二维码的回调
                            this.codeSrc = res
                        },
                    });
            },
            copyLink() {
                var globalData = util.getCacheSync('appInfo')
                // #ifdef APP-PLUS
                var txtdata = globalData.invite_url + "?code="+this.user.invitation_code
                // if (plus.os.name == 'Android') {
                //     txtdata = globalData.appName + '的下载链接为:' + globalData.appAndroidDownUrl +
                //         '\n邀请码:' + this.user.invitation_code
                // } else {
                //     txtdata = globalData.appName + '的下载链接为:' + globalData.appIosDownUrl + '\n邀请码:' +
                //         this.user.invitation_code
                // }
                console.log(this.user)
                uni.setClipboardData({
                    data: txtdata,
                    success: res => {
                        console.log(res)
                        uni.showToast({
                            title: '邀请链接已复制~快去分享给好友吧!',
                            icon: 'none'
                        })
                        uni.setStorageSync('clipboard', txtdata);
                    }
                });
                // #endif
            },
            
            clipcode(){
                uni.setClipboardData({
                    data: this.user.invitation_code,
                    success: res => {
                        console.log(res)
                        uni.showToast({
                            title: '邀请码已复制~快去分享给好友吧!',
                            icon: 'none'
                        })
                        uni.setStorageSync('clipboard', this.user.invitation_code);
                    }
                });
            },
            goodsnew() {
                uni.navigateTo({
                    url: './pullNew'
                })
            },
            getpageInfo() {
                var globalData = util.getCacheSync('appInfo')
                this.swiperList = globalData['inviteImgs'];
                this.TowerSwiper('swiperList');
            },
 
 
            sharewx() {
                uni.share({
                    provider: "weixin",
                    scene: "WXSceneSession",
                    type: 2,
                    imageUrl: this.shareUrl,
                    success: function(res) {
                        console.log("success:" + JSON.stringify(res));
                    },
                    fail: function(err) {
                        console.log("fail:" + JSON.stringify(err));
                    }
                });
            },
            
            sharepyq() {
                uni.share({
                    provider: "weixin",
                    scene: "WXSenceTimeline",
                    type: 2,
                    imageUrl: this.shareUrl,
                    success: function (res) {
                        console.log("success:" + JSON.stringify(res));
                    },
                    fail: function (err) {
                        console.log("fail:" + JSON.stringify(err));
                    }
                });
            },
            
            shareqq(){
                uni.share({
                    provider: "qq",
                    type: 2,
                    imageUrl: this.shareUrl,
                    success: function (res) {
                        console.log("success:" + JSON.stringify(res));
                    },
                    fail: function (err) {
                        console.log("fail:" + JSON.stringify(err));
                    }
                });
            },
            
            savepic(){
                uni.saveImageToPhotosAlbum({
                    filePath: this.shareUrl,
                    success: res => {
                        uni.showToast({
                            title:'保存相册成功~',
                            icon:'none'
                        })
                        this.closeModel()
                    },
                    fail(err) {
                        console.log(err);
                    },
                });
            },
            
 
 
            DotStyle(e) {
                this.dotStyle = e.detail.value
            },
            // cardSwiper
            cardSwiper(e) {
                this.cardCur = e.detail.current
            },
            // towerSwiper
            // 初始化towerSwiper
            TowerSwiper(name) {
                let list = this[name];
                for (let i = 0; i < list.length; i++) {
                    list[i].zIndex = parseInt(list.length / 2) + 1 - Math.abs(i - parseInt(list.length / 2))
                    list[i].mLeft = i - parseInt(list.length / 2)
                }
                this.swiperList = list
                this.swiperList.forEach((items, index) => {
                    if (items.mLeft == 0) {
                        this.bannerUrl = items.img
                    }
                })
            },
 
            // towerSwiper触摸开始
            TowerStart(e) {
                this.towerStart = e.touches[0].pageX
            },
 
            // towerSwiper计算方向
            TowerMove(e) {
                this.direction = e.touches[0].pageX - this.towerStart > 0 ? 'right' : 'left'
            },
 
            // towerSwiper计算滚动
            TowerEnd(e) {
                let direction = this.direction;
                let list = this.swiperList;
                if (direction == 'right') {
                    let mLeft = list[0].mLeft;
                    let zIndex = list[0].zIndex;
                    for (let i = 1; i < this.swiperList.length; i++) {
                        this.swiperList[i - 1].mLeft = this.swiperList[i].mLeft
                        this.swiperList[i - 1].zIndex = this.swiperList[i].zIndex
                    }
                    this.swiperList[list.length - 1].mLeft = mLeft;
                    this.swiperList[list.length - 1].zIndex = zIndex;
                } else {
                    let mLeft = list[list.length - 1].mLeft;
                    let zIndex = list[list.length - 1].zIndex;
                    for (let i = this.swiperList.length - 1; i > 0; i--) {
                        this.swiperList[i].mLeft = this.swiperList[i - 1].mLeft
                        this.swiperList[i].zIndex = this.swiperList[i - 1].zIndex
                    }
                    this.swiperList[0].mLeft = mLeft;
                    this.swiperList[0].zIndex = zIndex;
                }
                this.direction = ""
                this.swiperList.forEach((items, index) => {
                    if (items.mLeft == 0) {
                        this.bannerUrl = items.img
                    }
                })
            },
        }
    }
</script>
 
<style lang="scss">
    .invit_cont
    {
            display: flex;
            justify-content: space-between;
            width: 100%;
            margin-top: 25rpx;
            .invit_v
            {
                width: 49%;
            }
            image
            {
                height: 145rpx;
            }
    }
    .inviteFriends-wrapper {
        width: 100%;
 
        .swiper-container {
            width: 100%;
            height: 665rpx;
 
            .tower-swiper {
                height: 100%;
 
                .tower-item {
                    width: 374rpx;
                    height: 100%;
 
                    .swiper-item {
                        position: relative;
 
                        .code {
                            position: absolute;
                            width: 100%;
                            bottom: 44rpx;
 
                            image {
                                width: 106rpx;
                                height: 106rpx;
                                z-index: 10;
                            }
                        }
                    }
                }
            }
        }
 
        .pagebottom-container {
            width: 100%;
            margin-bottom: 260rpx;
 
            .inviteCode-container {
                width: 100%;
                height: 86rpx;
                background: #FFFFFF;
                border-radius: 16rpx;
 
                .left-code {
                    font-size: 28rpx;
                    font-weight: 500;
                    color: #333333;
                }
 
                .clipbtn {
                    width: 122rpx;
                    height: 52rpx;
                    background: linear-gradient(0deg, #7A11F2, #D31BF7);
                    border-radius: 26rpx;
                    font-size: 28rpx;
                    font-weight: 500;
                    color: #FFFFFF;
                }
            }
 
            .invite-step {
                width: 100%;
                margin-top: 30rpx;
                background-color: #FFFFFF;
                border-radius: 16rpx;
                padding: 30rpx;
 
                .step-title {
                    width: 100%;
                }
 
                .step-list {
                    font-size: 24rpx;
                    font-weight: 500;
                    color: #666666;
                    line-height: 38rpx;
                    margin-top: 25rpx;
                }
            }
 
            .bottom-options-container {
                width: 100%;
                background: #FFFFFF;
                border-radius: 16rpx;
                padding: 20rpx 0;
                position: fixed;
                bottom: 0;
 
                .option-items-container {
                    .icon-box {
                        width: 96rpx;
                        height: 96rpx;
                    }
 
                    .option-name {
                        font-size: 24rpx;
                        font-weight: 500;
                        color: #333333;
                    }
 
                    .option-explain {
                        font-size: 22rpx;
                        font-weight: 500;
                        color: #666666;
                    }
                }
            }
        }
    }
 
    .tower-swiper .tower-item {
        transform: scale(calc(0.65 + var(--index) / 10));
        margin-left: calc(var(--left) * 430upx - 184upx);
        z-index: var(--index);
    }
 
    .share-container {
        width: 100%;
 
        .share-title {
            width: 100%;
            height: 90rpx;
            flex-wrap: wrap;
            border-bottom: 1rpx solid #EFF1F7;
 
            .title-text {
                font-size: 28rpx;
                font-weight: 500;
                color: #333333;
            }
        }
 
        .shareList {
            width: 100%;
            flex-wrap: wrap;
            border-bottom: 1rpx solid #EFF1F7;
            margin-top: 45rpx;
 
            .items-container {
                width: 25%;
                margin-bottom: 30rpx;
 
                .icon-box {
                    width: 95rpx;
                    height: 95rpx;
                }
 
                .modeName {
                    font-size: 24rpx;
                    font-weight: 500;
                    color: #333333;
                    margin-top: 15rpx;
                }
            }
        }
 
        .cancelbox {
            width: 100%;
            height: 90rpx;
 
            .canceltext {
                font-size: 28rpx;
                font-weight: 500;
                color: #333333;
            }
        }
    }
 
    .canvass {
        opacity: 0;
        position: fixed; 
        pointer-events: none;
        bottom: 0;
        left: 0;
    }
    .pd30 {
        padding: 0 30rpx;
    }
</style>