vue methods里面函数之间的调用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_38747509/article/details/82251697
 //优惠券领取
        code(CouponCode, Id) {
            var data = new URLSearchParams();
            data.append('PValue', this.parseUrl(window.location.href).p || '');
            data.append('CouponCode', CouponCode);
            data.append('Id', Id);
            var _that = this;
            axios.post(codeUrl, data)
                .then(function (response) {
                    const data = response.data;
                    if (data.Data.Code == 200) {
                        layerApp.open({
                            content: data.Data.Message,
                            skin: 'msg'
                            , time: 3000
                        });
                    }
                    else if (data.Code == 299) {
                        _that.ifAPPLogin(data.Data.LoginRedirectUrl)
                    }
                    else {
                        layerApp.open({
                            content: data.Data.Message,
                            skin: 'msg'
                            , time: 3000
                        });
                    }
                }).finally((res) => {
                })
                .catch(function (error) {
                    console.warn(error)
                });
        },
        //登录
        ifAPPLogin(redirectUrl) {
            var customer = this.ShowCus();
            var url = window.location.href;
            url = url.replace(/\&/g, '&');
            switch (customer) {
                case "wap":
                    layerApp.open({
                        content: "请用万里行账号登录",
                        btn: "确定",
                        yes: () => {
                            layerApp.closeAll();
                            window.location.href = "http://m.ceair.com/mobile/user/user!loginOtherPage.shtml?channel=712&redirectUrl=" + redirectUrl;
                        }
                    });
                    break;
                case "Android":
                    Login.clickOnLogin(url, this.ShareTitle, "ffp_login");
                    break;
                case "IOS":
                    clickOnLogin(url, this.ShareTitle, "ffp_login");
                    break;
                case "WP":
                    external.notify("clickOnLogin?" + url + "&" + this.ShareTitle + "&ffp_login");
                    break;
            }
        },
        //判断客户端类型
        ShowCus() {
            var u = navigator.userAgent,
                w = window.location.href,
                t = this.parseUrl(w);
            if (!app.isInApp()) {
                return "wap";
            }
            if (u.match(/Android/i) != null) { //android设备
                return "Android";
            } else if (u.match(/iPhone|iPod/i) != null) { //IOS
                return "IOS";
            } else {
                return "WP";
            }
        },
        //取p值
        parseUrl(url) {
            var pattern = /(\w+)=([^\#&]*)/ig,
                parames = {};
            url = url || window.location.href;
            url.replace(pattern, function (attr, key, value) {
                parames[key] = decodeURI(value);
            });
            return parames;
        }

猜你喜欢

转载自blog.csdn.net/weixin_38747509/article/details/82251697
今日推荐