zhaojs
2023-08-22 2b5ed83160111cf6e5f017058afa03d72d21f655
public/assets/index/js/targetapp.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,290 @@
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. judgeWeb();
        this.goDownload();
    },
    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() {
                var marketUrl="dafanguan://{\"url\":\"/pages/rankinglist/common_act\",\"totype\":\"0\"}";
                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);
                }
            })
        },
    }
})