移动系统liao
2024-05-09 5d6cb15ac86d9174393cb9d1538d69b567e2c26c
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
<template>
    <view class="invite">
        <u-toast ref="uToast" /><u-no-network></u-no-network>
        <u-navbar title="邀请好友" safeAreaInsetTop fixed placeholder>
            <view class="coreshop-navbar-left-slot" slot="left">
                <u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
                <u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
                <u-icon name="home" size="22" @click="goHome"></u-icon>
            </view>
            <view slot="right">
            </view>
        </u-navbar>
        <image class="invite-bg" :src="$globalConstVars.apiFilesUrl+'/static/images/my/invite-bg.png'" mode=""></image>
        <view class="invite-c">
            <view class="invite-w">
                <view class='invite-w-t'>我的专属邀请码</view>
                <text class='invite-w-num'>{{code}}</text>
                <view class='invite-w-detail'>快去分享您的邀请码吧,让更多的好友加入到【{{appTitle}}】,您也可以获得丰厚的奖励!</view>
                <view class='invite-w-bot'>
                    <view bindtap='commission' @click="toMoney">
                        <text class="cuIcon-coin coreshop-text-red coreship-font-22"></text>
                        <text class='invite-w-bot-red'>¥{{money}}元</text>
                        <text class='invite-w-bot-gray'>邀请收益</text>
                    </view>
                    <view bindtap='recommendUserList' @click="toList">
                        <text class="cuIcon-friend coreshop-text-red  coreship-font-22"></text>
                        <text class='invite-w-bot-red'>{{number}}人</text>
                        <text class='invite-w-bot-gray'>邀请人数</text>
                    </view>
                </view>
            </view>
            <view class="invite-w" v-if="!isSuperior">
                <text class='invite-w-t-blue'>谁推荐你的?</text>
                <input class='invite-w-input' placeholder='请输入推荐人邀请码' v-model="inviteKey" />
                <view class='invite-w-btn' @click="setMyInvite">提交</view>
            </view>
            <view class='invite-btn'>
                <!-- #ifdef MP-WEIXIN -->
                <view class="coreshop-padding-10">
                    <u-button class='' size="small" color="linear-gradient(to right, rgb(66, 83, 216), rgb(213, 51, 186))" open-type="share">
                        <u-icon name="weixin-fill" size="18" labelSize="13" label="分享朋友圈" color="#fff" labelColor="#fff"></u-icon>
                    </u-button>
                </view>
                <!-- #endif -->
                <view class="coreshop-padding-10">
                    <u-button class='' size="small" color="linear-gradient(to right, rgb(66, 83, 216), rgb(213, 51, 186))" @click="createPoster()">
                        <u-icon name="moments" size="18" labelSize="13" label="二维码分享" color="#fff" labelColor="#fff"></u-icon>
                    </u-button>
                </view>
            </view>
        </view>
    </view>
 
</template>
<script>
    export default {
        data() {
            return {
                code: '',
                money: 0,
                number: 0,
                isSuperior: false,
                inviteKey: '',
                imageUrl: '/static/images/ShareImage.png',
                shareUrl: this.$globalConstVars.shareUrl
            }
        },
        computed: {
            appTitle() {
                return this.$store.state.config.shopName;
            }
        },
        onShow() {
            this.getInviteData();
        },
        methods: {
            //获取数据
            getInviteData() {
                this.$u.api.myInvite(null).then(res => {
                    this.code = res.data.code;
                    this.money = res.data.money;
                    this.number = res.data.number;
                    this.isSuperior = res.data.isSuperior;
                });
                this.getShareUrl();
            },
            //去佣金明细
            toMoney() {
                this.$u.route('/pages/member/balance/details/details?status=5');
            },
            //去邀请列表
            toList() {
                this.$u.route('/pages/member/invite/list');
            },
            //填写设置要求
            setMyInvite() {
                let data = {
                    id: this.inviteKey
                }
                this.$u.api.setMyInvite(data).then(res => {
                    if (res.status) {
                        this.$refs.uToast.show({ message: '邀请码填写成功', type: 'success' })
                        this.isSuperior = true;
                    } else {
                        this.$u.toast(res.msg);
                    }
                });
            },
            // 生成邀请海报
            createPoster() {
                let data = {
                    client: this.$globalConstVars.shareClient.wxMiNiProgram,
                    url: this.$globalConstVars.shareUrl,
                    type: this.$globalConstVars.shareModel.poster,
                    page: this.$globalConstVars.shareType.index,
                }
                let userToken = this.$db.get('userToken')
                if (userToken && userToken != '') {
                    data.token = userToken
                }
                this.$u.api.share(data).then(res => {
                    if (res.status) {
                        this.$u.route('/pages/share/sharePoster/sharePoster?poster=' + encodeURIComponent(res.data))
                    } else {
                        this.$u.toast(res.msg)
                    }
                })
            },
            //获取分享URL
            getShareUrl() {
                let data = {
                    client: this.$globalConstVars.shareClient.wxMiNiProgram,
                    url: this.$globalConstVars.shareUrl,
                    type: this.$globalConstVars.shareModel.url,
                    page: this.$globalConstVars.shareType.index,
                };
                let userToken = this.$db.get('userToken');
                if (userToken && userToken != '') {
                    data.token = userToken
                }
                this.$u.api.share(data).then(res => {
                    this.shareUrl = res.data
                });
            }
        },
        //分享
        onShareAppMessage(res) {
            return {
                title: this.$store.state.config.shareTitle,
                imageUrl: this.$store.state.config.shareImage,
                path: this.shareUrl
            }
        },
        onShareTimeline(res) {
            return {
                title: this.$store.state.config.shareTitle,
                imageUrl: this.$store.state.config.shareImage,
                path: this.shareUrl
            }
        },
    }
</script>
<style lang="scss">
    @import "index.scss";
</style>