zhaojs
2023-08-22 4eb8d3f5c8967fa890a18a2ba44994ac0b10e809
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
new Vue({
            el: '#app', // 选择器
            data: {
                show: 0,
                count: '',
                timer: null,
                agreeType: true, //
                tel: "", //手机号
                verification: '', //验证码
                showType: false,
                invitationInfo: "",
                privacyAgreement:"",
                userAgreement:"",
                appName: "",
                appLogo:"",
                beian:"",
                iosUrl:"",
                androidUrl:"",
                tips: "恭喜你,注册成功~",
                tips2: "欢迎您加入,赶紧下载APP,领取您的新人免单专属福利吧~",
                goodslist: [
                {"image": "https://img.alicdn.com/i3/880734502/O1CN01eDKk7i1j7xhJ5c7jV_!!880734502.jpg_310x310.jpg_.webp",
                    "title": "手撕面包2斤"
                },
                {"image": "https://img.alicdn.com/imgextra/i2/2201188731272/O1CN01sR96eg1LGcSFr2aTK_!!2201188731272.jpg_310x310.jpg_.webp",
                    "title": "Unifree洗脸巾"
                },
                {"image": "https://img.alicdn.com/imgextra/i4/2479240580/O1CN01g1cwOs1G9gTFkXFGZ_!!2479240580.png_310x310.jpg_.webp",
                    "title": "手持小风扇"
                },
                {"image": "https://img.alicdn.com/i4/2203738468138/O1CN01glAoIC29zFvNJAGhW_!!2203738468138.jpg_310x310.jpg_.webp",
                    "title": "牛油果沐浴露"
                },
                {"image": "https://img.alicdn.com/imgextra/i4/438927567/O1CN01vaRzJN25ljmb0wxZR_!!438927567.jpg_310x310.jpg_.webp",
                    "title": "无糖薄荷糖"
                },
                {"image": "https://img.alicdn.com/imgextra/i1/503512336/O1CN01wTeXWv1T7vxTSWEr2_!!503512336.jpg_310x310.jpg_.webp",
                    "title": "高蛋白鸡胸肉"
                },
                {"image": "https://img.alicdn.com/imgextra/i4/441512085/O1CN017tZRxE1RGyY2vgJF2_!!441512085.jpg_310x310.jpg_.webp",
                    "title": "4只鲜肉粽子"
                },
                {"image": "https://img.alicdn.com/imgextra/i1/1952819637/O1CN01rQrJu32L3nddEPV0l_!!1952819637.jpg_310x310.jpg_.webp",
                    "title": "加厚无芯卷纸"
                },
                {"image": "https://img.alicdn.com/i1/54801414/O1CN01jaEMbE1MJemh7RYJK_!!54801414.jpg_310x310.jpg_.webp",
                    "title": "大樱桃车厘子"
                }],
            },
            created() {
                this.getInvitationInfo();
            },
            mounted() {
        
                //  访问vm1 data的数据
            },
            methods: {
                getcode() {
                    const times = 60; // 倒计时时间
                    if (!this.timer) {
                        this.count = times;
                        this.show = 1;
                        this.timer = setInterval(() => {
                            if (this.count > 0 && this.count <= times) {
                                this.count--;
                            } else {
                                this.show = 2;
                                clearInterval(this.timer);
                                this.timer = null;
                            }
                        }, 1000)
                    }
                },
                //立即下载
                download() {
                    this.showType = true;
                },
                //注册即同意
                agreeCen() {
                    this.agreeType = !this.agreeType
                },
        
                getInvitationInfo() {
                    var code = vmRequest("code");
                    //alert(code);
                    //以param属性的形式来传递参数
                    axios({
                        method: "post", //请求方式
                        url: "/index/user/getInvitationInfo", //请求路径
                        params: {
                            "code": code
                        } //传递参数
                        //使用 箭头表达式=> 在代替原有的function来做回调函数
                    }).then(result => {
                        if (result.data.code == 1) {
                            alert(result.data.msg);
                        } else {
                            this.invitationInfo = result.data.info.user;
                            this.appName = result.data.info.appName;
                            this.privacyAgreement = result.data.info.privacyAgreement;
                            this.userAgreement = result.data.info.userAgreement;
                            this.appLogo = result.data.info.logo;
                            this.beian = result.data.info.beian;
                            this.iosUrl = result.data.info.appIosDownUrl;
                            this.androidUrl = result.data.info.appAndroidDownUrl;
                        }
                    })
        
                },
                phoneIsRegister() {
                    if (!this.tel) {
                        alert("手机号不能为空")
                        return false;
                    }
                    axios({
                        method: "post", //请求方式
                        url: "/index/user/phoneIsRegister", //请求路径
                        params: {
                            "phone": this.tel
                        } //传递参数
                        //使用 箭头表达式=> 在代替原有的function来做回调函数
                    }).then(result => {
                        if (result.data.code == 1) {
                            alert(result.data.msg);
                        } else {
                            // 号码未注册 发送验证码请求
                            // 号码已经注册
                            console.log(result.data)
                            if(result.data.is_registered == 1){
                                this.tips = "您的帐号已经注册";
                                this.tips2 = "欢迎您加入"+this.appName+",赶紧下载APP,赚取佣金吧~";
                                this.showType = true;
                                this.show = 1 //结束验证码
                                //alert(result.data.message);
                            }else{
                                this.sendCode();
                            }
                            
                            
                        }
                    })
        
                },
        
                // 发送验证码
                sendCode() {
                    console.log("发送验证码")
                    var timerChuo = new Date().getTime()
                    // 拼凑数据
                    var sendInfo = {
                        event: 'register',
                        mobile: this.tel,
                    };
                    axios({
                        method: "post", //请求方式
                        url: "/api/sms/send", //请求路径
                        data: sendInfo
                        // headers: {
                        //     'Content-Type': 'application/json;charset=UTF-8'
                        // },
                        //传递参数
                        //使用 箭头表达式=> 在代替原有的function来做回调函数
                    }).then(result => {
                        if (result.data.code == 1) {
                            // 号码已经注册
                            alert( result.data.msg);
                        } else {
                            // 号码未注册 发送验证码请求
                            //alert("验证码发送成功" + result.data.message);
                            this.getcode();
                        }
                    })
                },
                goDownload() {
                    // 判断是IOS还是安卓? 跳转对应下载页面
                    var u = navigator.userAgent;
                    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
                    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
                    if (isiOS) {
                        window.location = this.iosUrl;
                    } else if (isAndroid) {
                        window.location = this.androidUrl;
                    }
        
                },
                /* 用户注册 */
                userRegist() {
                    if (!this.tel) {
                        alert("手机号不能为空")
                        return false;
                    }
                    if (!this.verification) {
                        alert("验证码不能为空")
                        return false;
                    }
                    if (this.agreeType) {
                        alert("请先阅读并同意《"+this.appName+"用户协议》《隐私政策》")
                        return false;
                    }
                    // 拼凑数据
                    var sendInfo = {
                        mobile: this.tel,
                        captcha: this.verification,
                        invitation_code: this.invitationInfo.invitation_code
                    };
                    axios({
                        method: "post", //请求方式
                        url: "/api/user/register", //请求路径
                        data: sendInfo,
                        headers: {
                            'Content-Type': 'application/json;charset=UTF-8'
                        },
                        //传递参数
                        //使用 箭头表达式=> 在代替原有的function来做回调函数
                    }).then(result => {
                        if (result.data.code == 0) {
                            // 注册成功
                            this.tips2 = "欢迎您加入"+this.appName+",赶紧下载APP,赚取佣金吧~";
                            this.showType = true;
                        } else {
                            //失败
                            alert("注册失败" + result.data.message);
        
                        }
                    })
        
                },
            }
        
        })