javascript微信ios自动播放音效方法

javascript微信ios自动播放音效方法

 wx.config({
        //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
        appId: $('#appId').val(), // 必填,公众号的唯一标识
        timestamp: $('#timestamp').val(), // 必填,生成签名的时间戳
        nonceStr: $('#nonceStr').val(), // 必填,生成签名的随机串
        signature: $('#signature').val(), // 必填,签名,见附录1
        jsApiList: ['checkJsApi', 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem', 'translateVoice', 'startRecord', 'stopRecord', 'onRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'uploadVoice', 'downloadVoice', 'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'getNetworkType', 'openLocation', 'getLocation', 'hideOptionMenu', 'showOptionMenu', 'closeWindow', 'scanQRCode', 'chooseWXPay', 'openProductSpecificView', 'addCard', 'chooseCard', 'openCard']
    });
    var ntitle = $('#ntitle').val();
    var ndesc = $('#ndesc').val();
    var nlogo = $('#nlogo').val();
    var link = $('#link').val();
    wx.ready(function() {
        var musiclen = $('#bgmusic').length;
        if (musiclen > 0) {
            playbgmusic();
            $('#yinxiao').load();
            fm2 = function() {
                $('#yinxiao')[0].play();
            };
        }
        wx.checkJsApi({
            jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline'],
            success: function(res) {
                //alert(JSON.stringify(res));
            }
        });
        wx.hideMenuItems({
            menuList: ['menuItem:copyUrl'] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3
        });
        commonshare(ntitle, ndesc, nlogo, link);
    });


fm2();

jquery trim重写

jquery trim重写

String.prototype.trim = function(char, type) {
    if (char) {
        if (type == 'left') {
            return this.replace(new RegExp('^\\' + char + '+', 'g'), '');
        } else if (type == 'right') {
            return this.replace(new RegExp('\\' + char + '+$', 'g'), '');
        }
        return this.replace(new RegExp('^\\' + char + '+|\\' + char + '+$', 'g'), '');
    }
    return this.replace(/^\s+|\s+$/g, '');
};

 str = '/Ruchee/';
    console.log(str.trim('/', 'left')); // Ruchee/