//优惠券领取
        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;
        }

 

Logo

前往低代码交流专区

更多推荐