|
- /**
- * 分享新闻
- */
- function fnShareNews() {
- qq = api.require('QQPlus');
- qq.installed(function(ret, err) {
- if (ret.status) {
- api.toast({msg: "已安装QQ"});
- } else {
- api.toast({msg: "没安装QQ"});
- };
- });
-
- api.confirm({
- title: '选项',
- msg: '请选择分享至',
- buttons: [ 'QQ好友','QQ空间']
- }, function(ret, err) {
- _fnShareNews(ret.buttonIndex);
- });
- function _fnShareNews(i) {
- var type = ['QZone', 'QFriend'];
- qq.shareNews({
- type: type[i],
- url: 'https://news**.**/a/20171108/029944.htm',
- title: '携程:被虐儿童为18至24个月幼儿 亲子园明日停业',
- description: '携程:被虐儿童为18至24个月幼儿 亲子园明日停业',
- imgUrl: 'http://inews**.**/newsapp_bt/0/2264720095/641'
- }, function(ret, err) {
- if (ret.status) {
- api.alert({msg: JSON.stringify(ret)});
- console.log("分享新闻成功!");
- console.log(JSON.stringify(ret));
- } else {
- api.alert({msg: JSON.stringify(err)});
- //api.alert(JSON.stringify(err));
- console.log(JSON.stringify(err));
- }
- });
- };
- };
复制代码 这是做的测试,能够检测到qq已安装,也能弹出分享到“QQ好友”还是“QQ空间”,但是在ShareNews这个函数执行时就报错“msg:'cancel',code:'-1'”,看了社区很多朋友也有遇到类似的,但不知道最后怎么解决的。QQ开发平台申请的APP ID和APP Key是没有问题的。(注:已添加QQPlus模块)
|
|