louis
louis
  • 发布:2015-05-18 14:54
  • 更新:2015-08-08 17:15
  • 阅读:4393

个推消息的监听事件click、receive的JS应该写到什么地方?

分类:HTML5+

个推消息的监听事件click、receive的JS应该写到什么地方?
如果写到某个页面中,能否起到监听整个APP的作用?如果不能该怎么处理?

2015-05-18 14:54 2 条评论 负责人:无 分享
已邀请:
小飞鱼

小飞鱼 - 做一只文艺的程序员

哥们解决了么,我也想问这个问题

deiphi

deiphi

写在入口页面。

小飞鱼

小飞鱼 - 做一只文艺的程序员

我现在透传消息的recive事件好像只有打开程序才能够触发
你那边弄好了么
方不方便加一个qq讨教下:1129330609

流星雨

流星雨

我也是能收到推送消息,但是监听不到点击事件

同求!

大海花开

大海花开

同求

apche

apche

同求,我的事件没有写在manifest.json 指定的首页,而是首页打开的主页上,因为我们的首页需要判断是否是新用户,新旧用户的主页是不同的。

zk_james

zk_james

在一个页面创建了之后 ,他会始终存在的,像我做过的一个 在登陆完成之后创建,整个app都会监听的

严生

严生

<script>
(function($) {
//微信配置信息接口
wx.config({
debug : false,
appId : '{$wxid}',
timestamp : '{$timestamp}',
nonceStr : '{$nonceStr}',
signature : '{$signature}',
jsApiList : [ 'startRecord', 'stopRecord', 'onRecordEnd',
'playVoice', 'pauseVoice', 'stopVoice', 'uploadVoice',
'downloadVoice' ]
});

    var voice = {  
        localId : [],  
        serverId : []  
    };  
    var getUrl = function(serverID) {  
        $.ajax({  
            type : "GET",  
            url : "__ROOT__/Wap/Wap/getImgUrl",  
            data : 'sid=' + serverID + '&ext=amr',  
            success : function(res) {  
                var ss = eval('(' + res + ')');  
                var tt = ss.url;  
                $(".guolai").val(tt);  

                //$(".mmUl").append("<li><img src='"+ss.url+"'><input type='hidden' value='"+ ss.path +"'></li>");  
            }  
        });  
    }  
    var delImdex = 0;  
    var hideRangeBox = function() {  
        $(".commonDalalog").css("display", "none");  
    }  
    var showRangeBox = function(objs) {  
        $(".dalalogBg").css("height", $(document).height());  
        $(objs).css("display", "block");  
    }  
    $(function() {  

        $(document).on(  
                'click',  
                '.mmUl img',  
                function() {  
                    $(".dalalogTrigger").find("img").eq(0).attr("src",  
                            $(this).attr("src"));  
                    $(".currentImg").css("max-height",  
                            $(window).height() * 0.85);  
                    delImdex = $(this).parent().index();  
                    showRangeBox(".commonDalalog");  
                });  
        $(".dalalogBg").click(function() {  
            hideRangeBox();  
        });  
        $(".currentImg").click(function() {  
            hideRangeBox();  
        });  
        $(".delCurrentImg").click(function() {  
            $(".mmUl").find("div").eq(delImdex).remove();  
            hideRangeBox();  
        });  

        //          // 4 音频接口  
        //          // 4.2 开始录音  
        document.querySelector('.Sound').onclick = function() {  
            wx.startRecord({  
                cancel : function() {  
                    // alert('用户拒绝授权录音');  
                }  
            });  
        };  

        wx.onVoiceRecordEnd({  
            // 录音时间超过一分钟没有停止的时候会执行 complete 回调  
            complete : function(res) {  
                var localId = res.localId;  
            }  
        });  

        //      // 4.3 停止录音  
        document.querySelector('.Sound2').onclick = function() {  
            wx.stopRecord({  
                success : function(res) {  
                    voice.localId = res.localId;  
                    upload();  
                },  
                fail : function(res) {  
                    // alert(JSON.stringify(res));  
                }  
            });  
        };  

        // 4.5 播放音频  
        document.querySelector('.shuoting').onclick = function() {  
            // alert(voice.localId);  
            if (voice.localId == '') {  
                // alert('请先使用 startRecord 接口录制一段声音');  
                return;  
            }  

            wx.playVoice({  

                localId : voice.localId  
            });  
        };  

        // 4.8 上传语音  
        function upload() {  
            if (voice.localId == '') {  
                //alert('请先使用 startRecord 接口录制一段声音');  
                return;  
            }  
            //alert('本地localId:'+voice.localId);  
            wx.uploadVoice({  
                localId : voice.localId,  
                success : function(res) {  
                    //alert('上传语音成功,serverId 为' + res.serverId);  
                    voice.serverId = res.serverId;  
                    getUrl(res.serverId);  
                }  
            });  
        }  
        ;  
    });  
})(jQuery);  

</script>

<script>
var imageObject = {
clickSwap : function(obj) {
obj.click(function() {
var activeImage = $(this).children('img.active');
activeImage.removeClass('active');
if (activeImage.next().length > 0) {
activeImage.next().addClass('active');
} else {
$(this).children('img:first-child').addClass('active');
}
return false;
});
}
};
$(function() {
imageObject.clickSwap($('#imageContainer'));
});
</script>

该问题目前已经被锁定, 无法添加新回复