heyuntao
2023-06-12 325ddeb137477829b323d7f2f57b361b51e7480e
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
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();
        this. judgeWeb();
    },
    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
        },
        //复制
        handleClipboard() {
            var _this = this;
            var clipboardImg = new Clipboard('.yqm', {
                text: function() {
                    return _this.invitationInfo.invitation_code;
                },
            });
            clipboardImg.on('success', function(e) {
               alert("邀请码复制成功,赶快下载APP,尽享优惠吧~")
            });
 
            clipboardImg.on('error', function(e) {
                alert("邀请码复制失败,您可直接至APP中注册后填写此邀请码")
            });
        },
        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;
                window.location="https://apps.apple.com/cn/app/id6449449829"
            } else if (isAndroid) {
                window.location = this.androidUrl;
            } */
            var agen=this.verifyBrand();
            var marketUrl=this.androidUrl;
                    switch(agen)
                    {
                        case'iphone':
                         marketUrl="https://apps.apple.com/cn/app/id6449449829";
                            break;
                        case'xiaomi':
                        marketUrl="mimarket://details?id=com.dafanguan.app";
                            break;
                        case'huawei':
                        marketUrl="appmarket://details?id=com.dafanguan.app";
                            break;
                        case'oppo':
                        marketUrl="oppomarket://details?packagename=com.dafanguan.app";
                            break;
                        case'vivo':
                        marketUrl="vivomarket://details?id=com.dafanguan.app";
                            break;
                        default:
                            marketUrl = this.androidUrl;
                    }
                    window.location = marketUrl;
             },
            verifyBrand()
            {//判断机子类型
                const userAgent = navigator.userAgent.toLowerCase()
                const isIphone = userAgent.match(/(iphone|ipad|ipod)/i);
                const isHuawei = userAgent.match(/huawei/i);
                const isHonor = userAgent.match(/honor/i);
                const isOppo = userAgent.match(/oppo/i);
                const isOppoR15 = userAgent.match(/PACM00/i);
                const isVivo = userAgent.match(/vivo/i);
                const isXiaomi = userAgent.match(/mi\s/i);
                const isXIAOMI = userAgent.match(/xiaomi/i);
                const isXiaomi2s = userAgent.match(/mix\s/i);
                const isRedmi = userAgent.match(/redmi/i);
 
                if (isIphone) {
                    return 'iphone'
                } else if (isHuawei || isHonor) {
                    return 'huawei';
                } else if (isOppo || isOppoR15) {
                    return 'oppo';
                } else if (isVivo) {
                    return 'vivo';
                } else if (isXiaomi || isRedmi || isXiaomi2s || isXIAOMI) {
                    return 'xiaomi';
                } else {
                    return 'other';
                }
            },
            judgeWeb()
            {
                var webName=this.isNeizhi();
                if(webName=='weixin')
                {
                    alert("请点击右上角,选择'在浏览器打开'~");
                }
                else if(webName=='QQ')
                {
                    alert("请点击右上角,选择'浏览器',打开本网址~");
                }
            },
            isNeizhi()
            {//判断是否内置浏览器
                var ua = navigator.userAgent.toLowerCase();
                // var browserName = "unknow";
                if (ua.match(/MicroMessenger/i) == "micromessenger") {
                    return "weixin";
                } else if (ua.match(/QQ/i) == "qq") {
                    return "QQ";
                } else if (ua.match(/Alipay/i) == "alipay" && payway == 2) {
                    return "alipay";
                }
            },
        /* 用户注册 */
        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);
 
                }
            })
 
        },
    }
 
})