java 微信公众号js接入_SpringCloud : 接入 微信公众号平台(三)、获取JsSDK配置参数...

JsSDK配置参数获取Demo

//用于JS调试

var vConsole = new VConsole(); //初始化

-->

name= name.replace(/[]/,"\[").replace(/[]/,"\[").replace(/[]/,"\\\]");

var regexS= "[\\?&]"+name+"=([^]*)";

var regex= newRegExp( regexS );

var results=regex.exec(window.parent.location.href );if( results == null ) return ""; else{return results[1];

}

};

function jssdk() {

$.ajax({

url :"https://www.phpdragon.com/system/getJsSdkConfig",

type :'post',//contentType: "application/json",

dataType : 'json',

data : {'current_url' : location.href.split('#')[0],'app_id': getUrlParameter("app_id")

},

async:true,

success : function(rsp) {

wx.config({

debug :true,

appId : rsp.appId,

timestamp : rsp.timestamp,

nonceStr : rsp.nonceStr,

signature : rsp.signature,

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']

});

},

error : function(data){

alert("获取JsSDK参数异常:" +data);

}

});

}

function isWeiXin5() {

var ua=window.navigator.userAgent.toLowerCase();

var reg= /MicroMessenger\/[5-9]/i;returnreg.test(ua);

}

$(function(){

jssdk();

});

function takePicture(){

wx.chooseImage({

count:1, //默认9

sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有

sourceType: ['album', 'camera'], //可以指定来源是相册还是相机,默认二者都有

success: function (res) {

wx.uploadImage({

localId: localIds.toString(),//需要上传的图片的本地ID,由chooseImage接口获得

isShowProgressTips: 1, //默认为1,显示进度提示

success: function (res) {

var mediaId= res.serverId; //返回图片的服务器端ID,即mediaId//将获取到的 mediaId 传入后台 方法savePicture

$.post("<%=request.getContextPath()%>/savePicture",{mediaId:mediaId},function(res){if(res.t == 'success'){

}else{

alert(res.msg)

}

})

},

fail: function (res) {

alertModal('上传图片失败,请重试')

}

});

},

fail: function (res) {

alertModal('上传图片失败,请重试2')

},

error: function (res) {

alertModal('上传图片失败,请重试3')

}

});

}

function checkJsApifunction () {

wx.checkJsApi({

jsApiList: ['getNetworkType','previewImage',"chooseImage","openLocation","getLocation",

],

success: function (res) {

alert(JSON.stringify(res));

}

});

}

拍照

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值