美文网首页
个推代码

个推代码

作者: daoqing99 | 来源:发表于2017-06-09 10:30 被阅读0次
    <script type="text/javascript">
                mui.plusReady(function() {
    
                    plus.push.addEventListener("click", function(msg) {
    
                        dealPushMsg(msg);
                        //                  plus.push.clear();
                    }, false);
    
                    plus.push.addEventListener("receive", function(msg) {
                        //                  plus.webview.currentWebview().reload();
                        dealPushMsg(msg);
                        //                  plus.push.clear();
                    }, false);
                });
    
                function dealPushMsg(msg) {
                    var payload = msg.payload;
                    payload = JSON.parse(payload);
                    if(payload && payload.type) {
                        var type = payload.type;
                        var businessType = payload.businessType;
                        var id = payload.id;
                        //中奖    
                        if(type == 'win') {
                            if(businessType == 'yydb') {
                                window.parent.popToView("db-lucky-record", "../mine/db-lucky-record.html");
    
                            };
    
                            if(businessType == 'double_pk' || businessType == 'four_pk') {
                                window.parent.popToView("battle-lucky-record", "../mine/battle-lucky-record.html");
                            };
    
                        }
    
                        //活动
                        if(type == 'activity') {
                            var specialId = payload.id;
                            if(specialId) {
                                localStorage.setItem("specialId", specialId);
                                var detail = plus.webview.getWebviewById('goodsActivity');
                                if(detail) {
                                    detail.reload();
                                } else {
                                    window.parent.popToView("goodsActivity", "../activity/goodsActivity.html");
                                }
                            }
                        };
    
                        //产品
                        if(type == 'product') {
                            if(businessType == 'yydb') {
                                var productId = payload.id;
    //                          mui.toast(productId);
                                localStorage.setItem("homeGoodsId", productId);
                                //window.parent.popToView("home_detail", "../home/detail.html");
                                var detail = plus.webview.getWebviewById('home_detail');
                                if(detail) {
                                    detail.reload();
                                } else {
                                    window.parent.popToView("home_detail", "../home/detail.html");
                                }
    
                            };
    
                            if(businessType == 'double_pk' || businessType == 'four_pk') {
                                var productid = payload.id;
                                var goodid = payload.id;
    
                                localStorage.setItem("goodid", goodid);
                                localStorage.setItem("productid", productid);
                                var against_detail1 = plus.webview.getWebviewById('against_detail1');
                                if(against_detail1) {
                                    against_detail1.reload();
                                } else {
                                    window.parent.popToView("against_detail1", "../against/detail.html");
                                }
                            };
                        };
                        if(type == 'mydefine') {
                            window.parent.popToView("main", "../home/main.html");
                        }
                    } else {
                        window.parent.popToView("main", "../home/main.html");
                    }
    
                };
            </script>
    

    相关文章

      网友评论

          本文标题:个推代码

          本文链接:https://www.haomeiwen.com/subject/lrbxqxtx.html