我又申请了个大王卡,直接把页面源码搞了下来,发现联通是这么打开摄像头录视频的,然后我按照他的套路来写,最后报错: err_msg:System:access_denied
然后我大概百度了下这个错误,发现大家都是在支付的时候才出现的,实在无招,前来求救.....
var url = encodeURIComponent(location.href.split('#')[0]);
//alert('url is ' + url);
//获取签名字段
$.ajax({
url:'http://qq_32b899df.ngrok.wendal.cn/nutzforweixin/weixin/getTicket',
type:'get',
async:false,
data:{url:url},
success:function(data){
console.log(data);
var appid = data.appid;
var timestamp = data.timestamp;
var nonceStr = data.nonceStr;
var signature = data.signature
wx.config({
debug: false,
appId: appid,//id
timestamp:ti mestamp ,//时间戳
nonceStr: nonceStr,//随机字符串
signature:signature,//签名
jsApiList: [
'checkJsApi',
'hideAllNonBaseMenuItem',
'showAllNonBaseMenuItem',
'translateVoice',
'chooseVideo',
'startRecord',
'stopRecord',
'onRecordEnd',
'playVoice',
'pauseVoice',
'stopVoice',
'uploadVoice',
'uploadVideo',
'downloadVoice',
]
});
wx.ready(function () {
//$('.wait').hide();
alert("config ok!");
// // 选取拍摄视频
uploadVideo = function(){
var sourceType = "camera";
var camera = "front";
var maxDuration = "6";
// console.log(sourceType, camera, maxDuration);
// console.log("WeixinJSBridge:");
// console.log(WeixinJSBridge);
alert(WeixinJSBridge);
WeixinJSBridge.invoke('chooseVideo', { //打开前置相机,录视频...
sourceType: sourceType,
maxDuration: maxDuration,
camera: camera
}, function (res) {
alert(111);
alert(JSON.stringify(res));
console.log(res);
videoTag='0';
if(isEmpty(res.localId)){
return;
}
// 上传视频
WeixinJSBridge.invoke('uploadVideo', {
appId: WX_CONFIG.appId,
localId: res.localId
}, function (res) {
alert("执行完毕.."+res);
}
});
});
};
});
wx.error(function (res) {
console.log("error: "+ res.errMsg);
alert("error: "+ res.errMsg);
//alert("出现错误!");
});
},
error:function(e){
console.log(e);
}
});