示例:
script
// 分享
goGoodsShare() {
// 1.打开分享窗口
if (window.TencentNews && window.TencentNews.showActionMenu) {
window.TencentNews.showActionMenu();
} else {
alert("没有注册接口!");
}
// 2.自定义分享信息接口
// 接口:setShareArticleInfo(String shareTitle, String longTitle, String shareContent,
// String shareUrl, String shareImgUrl)
// 参数:
// {String} shareTitle 分享标题
// {String} longTitle 不支持 content 分享的长标题
// {String} shareContent 分享的描述内容
// {String} url 分享的 url
// {String} imgUrl 分享的图片 url
if (window.TencentNews && window.TencentNews.setShareArticleInfo) {
window.TencentNews.setShareArticleInfo('分享测试标题-wangrong', '分享测试标题-wangrong',
'分享测试内容——say hello3', 'https://uatprizejiangbei.92jiangbei.com/#/dashboard',
'http://mat1.gtimg.com/www/newsapp/img/android/default_list_logo.png');
} else {
alert("没有注册接口!");
}
}
相关文档:
1.腾讯新闻客户端JS API(IOS) https://sh.qq.com/zhuanti/wxpage/handbook.htm#EnableSingleH5Share
2.tencent-share https://npm.taobao.org/package/tencent-share
腾讯分享相关api
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>JsApi接口测试页面_腾讯新闻</title>
<script>
var test_ready_event_getCurrentLocationInfo = function () {
if (window.TencentNews && window.TencentNews.getCurrentLocationInfo) {
window.TencentNews.getCurrentLocationInfo({
onCallback: function (res) {
window.TencentNews.showWarningTips("injectionComplete:" + window.TencentNews.injectionComplete + JSON.stringify(res));
}
});
} else {
alert("没有注册接口!");
}
window.TencentNews.setTagSecondTitle({"title":"英超 排名19"});
}
window.TencentNewsJsReady = test_ready_event_getCurrentLocationInfo;
window.TencentNewsMsgReceiver = function(jsonStr) {
window.TencentNews.writeLog("WebViewCommunicator_", "received msg: " + JSON.stringify(jsonStr));
window.TencentNews.showWarningTips("regReceiver:" + JSON.stringify(jsonStr));
}
</script>
<!-- <script type="text/javascript" src="./js/resourceNews.js"></script> -->
<script type="text/javascript" src="http://mat1.gtimg.com/www/js/newsapp/jsapi/news.js?_tsid=1"></script>
</head>
<body>
<style>
.button-div {
margin-top: 15px;
margin-left: 15px;
height: 30px;
line-height: 30px;
display: block;
font-size: 16px;
background-color: aliceblue;
}
</style>
<a href="./test_js_api_1.html">gotoTest1</a>
<img src="./images/audio_play.gif">
<div class="button-div" onclick="test_isMethodSupport()">
test_isMethodSupport()
</div>
<div class="button-div" onclick="test_share()">
test_share()
</div>
<div class="button-div" onclick="test_webview_bug()">
test_webview_bug()
</div>
<div class="button-div" onclick="test_regReceiver()">
test_regReceiver()
</div>
<div class="button-div" onclick="test_broadcastMsg()">
test_broadcastMsg()
</div>
<div class="button-div" onclick="test_openNewWebView()">
test_openNewWebView()测试不同webview广播与接受
</div>
<div class="button-div" onclick="test_notifyAppMsg()">
test_notifyAppMsg() webview给App发消息
</div>
<div class="button-div" onclick="test_getConfigInfo()">
test_getConfigInfo() 获取客户端参数配置或本地数据
</div>
<div class="button-div" onclick="test_sendBoss()">
test_sendBoss
</div>
<div class="button-div" onclick="test_jumpToChannelWithFloat()">
test_jumpToChannelWithFloat
</div>
<div class="button-div" onclick="test_jumpToChannelWithFloatTest()">
test_jumpToChannelWithFloatTest
</div>
<div class="button-div" onclick="test_setTagSecondTitle_1()">
test_setTagSecondTitle_1
</div>
<div class="button-div" onclick="test_setTagSecondTitle_2()">
test_setTagSecondTitle_2
</div>
<div class="button-div" onclick="test_setReturnBtnActionType_1()">
test_setReturnBtnActionType_1
</div>
<div class="button-div" onclick="test_setReturnBtnActionType_0()">
test_setReturnBtnActionType_0
</div>
<div class="button-div" onclick="test_getAppInfo()">
test_getAppInfo
</div>
<div class="button-div" onclick="test_getAppInfo()">
test_getAppInfo
</div>
<div class="button-div" onclick="test_getNetworkStatus()">
test_getNetworkStatus
</div>
<div class="button-div" onclick="test_getImei()">
test_getImei
</div>
<div class="button-div" onclick="test_getUid()">
test_getUid
</div>
<div class="button-div" onclick="test_getGestureQuit()">
test_getGestureQuit
</div>
<div class="button-div" onclick="test_setGestureQuit_1()">
test_setGestureQuit(true) 禁用右滑退出
</div>
<div class="button-div" onclick="test_setGestureQuit_2()">
test_setGestureQuit(false) 开启右滑退出
</div>
<div class="button-div" onclick="test_enableShowBigImg()">
test_enableShowBigImg(openBigImage需打开)
</div>
<div class="button-div" onclick="test_showWarningTips()">
test_showWarningTips
</div>
<div class="button-div" onclick="test_showSuccessTips()">
test_showSuccessTips
</div>
<div class="button-div" onclick="test_showErrorTips()">
test_showErrorTips
</div>
<div class="button-div" onclick="test_showTextTips()">
test_showTextTips
</div>
<div class="button-div" onclick="test_showAlert()">
test_showAlert
</div>
<div class="button-div" onclick="test_showActionMenu()">
test_showActionMenu
</div>
<div class="button-div" onclick="test_setShareArticleInfo()">
test_setShareArticleInfo
</div>
<div class="button-div" onclick="test_deleteShareItems()">
test_deleteShareItems
</div>
<div class="button-div" onclick="test_changeMainAccount()">
test_changeMainAccount(qqorweixin)
</div>
<div class="button-div" onclick="test_showNativeLoginWithType_1()">
test_showNativeLoginWithType(qq&wx)
</div>
<div class="button-div" onclick="test_showNativeLoginWithType_2()">
test_showNativeLoginWithType(qq)
</div>
<div class="button-div" onclick="test_showNativeLoginWithType_3()">
test_showNativeLoginWithType(weixin)
</div>
<div class="button-div" onclick="test_showNativeLoginWithType_4()">
test_showNativeLoginWithType(qqconnect)
</div>
<div class="button-div" onclick="test_showNativeLoginWithType_5()">
test_showNativeLoginWithType(qqconnectorweixin)
</div>
<div class="button-div" onclick="test_isQQLogin()">
test_isQQLogin
</div>
<div class="button-div" onclick="test_isWeixinLogin()">
test_isWeixinLogin
</div>
<div class="button-div" onclick="test_setUserData()">
test_setUserData
</div>
<div class="button-div" onclick="test_getUserData()">
test_getUserData
</div>
<div class="button-div" onclick="test_clearUserData()">
test_clearUserData
</div>
<div class="button-div" onclick="test_getMainAccount()">
test_getMainAccount
</div>
<div class="button-div" onclick="test_isAvailable()">
test_isAvailable
</div>
<div class="button-div" onclick="test_setTitle()">
test_setTitle
</div>
<div class="button-div" onclick="test_showNews()">
test_showNews
</div>
<div class="button-div" onclick="test_openApp()">
test_openApp
</div>
<div class="button-div" onclick="test_openNativeUrl_1()">
test_openNativeUrl 打开QQ
</div>
<div class="button-div" onclick="test_openNativeUrl_2()">
test_openNativeUrl 调起浏览器下载应用
</div>
<div class="button-div" onclick="test_openWebViewWithType()">
test_openWebViewWithType
</div>
<div class="button-div" onclick="test_sendPayRequest()">
test_sendPayRequest
</div>
<div class="button-div" onclick="test_getAppVersionName()">
test_getAppVersionName
</div>
<div class="button-div" onclick="test_checkCanOpenNativeUrl()">
test_checkCanOpenNativeUrl 安装QQ了?
</div>
<div class="button-div" onclick="test_downloadApp()">
test_downloadApp
</div>
<div class="button-div" onclick="test_downloadAppByLocal()">
test_downloadAppByLocal
</div>
<div class="button-div" onclick="test_downloadAppFromBrowser()">
test_downloadAppFromBrowser
</div>
<div class="button-div" onclick="test_getCurrentLocationInfo()">
test_getCurrentLocationInfo
</div>
<div class="button-div" onclick="test_getCurrentSubChannelCityInfo()">
test_getCurrentSubChannelCityInfo
</div>
<div class="button-div" onclick="test_copy()">
test_copy
</div>
<div class="button-div" onclick="test_zoomImageSrc()">
test_zoomImageSrc
</div>
<div class="button-div" onclick="test_playVideo()">
test_playVideo
</div>
<div class="button-div" onclick="test_getWeixinUserInfo()">
test_getWeixinUserInfo(callback)
</div>
<div class="button-div" onclick="test_syncRedpacketUpdateInfo()">
test_syncRedpacketUpdateInfo(callback)
</div>
<div class="button-div" onclick="test_getUserInfo()">
test_getUserInfo(callback)
</div>
<div class="button-div" onclick="test_setSyncStatus_1()">
test_setSyncStatus(true) 同步成功
</div>
<div class="button-div" onclick="test_setSyncStatus_2()">
test_setSyncStatus(false) 同步失败
</div>
<div class="button-div" onclick="test_getAllInstalledApp()">
test_getAllInstalledApp(callback)
</div>
<div class="button-div" onclick="test_isAppInstalled('com.tencent.mobileqq')">
test_isAppInstalled("com.tencent.mobileqq")
</div>
<div class="button-div" onclick="test_isAppInstalled('com.taobao.taobao')">
test_isAppInstalled("com.taobao.taobao")
</div>
<div class="button-div" onclick="test_setActionBtn_0()">
test_setActionBtn("0")
</div>
<div class="button-div" onclick="test_setActionBtn_1()">
test_setActionBtn("1")
</div>
<div class="button-div" onclick="test_setActionBtn_2()">
test_setActionBtn("2")
</div>
<div class="button-div" onclick="test_saveImageToLocal()">
test_saveImageToLocal("url","imgType")
</div>
<div class="button-div" onclick="test_checkAppStatus()">
test_checkAppStatus(apkInfo, callback)
</div>
<div class="button-div" onclick="test_downloadApp_gdt()">
test_downloadApp_gdt(apkInfo, callback)
</div>
<div class="button-div" onclick="test_installApp()">
test_installApp(apkInfo, callback)
</div>
<div class="button-div" onclick="test_launchApp()">
test_launchApp(apkInfo)
</div>
<div class="button-div">
广告下载回调结果:<span id="callback">status, progress</span>
</div>
<div class="button-div" onclick="test_syncSignPointUpdateInfo()">
test_syncSignPointUpdateInfo(1) 签到积分
</div>
<div class="button-div" onclick="test_loginOut()">
test_loginOut()
</div>
<div class="button-div" onclick="test_loginOut_callBack()">
test_loginOut_callBack()
</div>
<div class="button-div" onclick="test_buyDiamond()">
test_buyDiamond() 购买钻石
</div>
<div class="button-div" onclick="test_previewDetailImage()">
test_previewDetailImage
</div>
<div class="button-div" onclick="test_setBottomBarVisibility_true()">
test_setBottomBarVisibility(true)
</div>
<div class="button-div" onclick="test_setBottomBarVisibility_false()">
test_setBottomBarVisibility(false)
</div>
<div class="button-div" onclick="test_getAdInfo()">
test_getAdInfo()
</div>
<div class="button-div" onclick="test_appUsedSceonds()">
test_appUsedSceonds()
</div>
<div class="button-div" onclick="test_pluginRequest()">
test_pluginRequest()
</div>
<div class="button-div" onclick="test_openReadingPage()">
test_openReadingPage()
</div>
<div class="button-div" onclick="test_openBookShelfPage()">
test_openBookShelfPage()
</div>
<div class="button-div" onclick="test_openClassifyPage()">
test_openClassifyPage()
</div>
<div class="button-div" onclick="test_openWebViewPage()">
test_openWebViewPage()
</div>
<div class="button-div" onclick="test_adVideoBeginPlay()">
test_adVideoBeginPlay()
</div>
<div class="button-div" onclick="test_refreshWxAccessToken()">
test_refreshWxAccessToken()
</div>
<div class="button-div" onclick="test_gotoPushHistoryPage()">
test_gotoPushHistoryPage()
</div>
<div class="button-div" onclick="test_getSecurityRequestCheckCode()">
test_getSecurityRequestCheckCode()
</div>
<div class="button-div" onclick="test_writeLog()">
test_writeLog()
</div>
<div class="button-div" onclick="test_pluginInvoke()">
test_pluginInvoke()
</div>
<div class="button-div" onclick="test_adjustWebViewInfo()">
test_adjustWebViewInfo()
</div>
<div class="button-div" onclick="test_isAllPushClose()">
test_isAllPushClose()
</div>
<div class="button-div" onclick="test_isNotificationEnabled()">
test_isNotificationEnabled()
</div>
<div class="button-div" onclick="test_gotoPushSwitchSettingPage()">
test_gotoPushSwitchSettingPage()
</div>
<div class="button-div" onclick="test_enableLocalPush()">
test_enableLocalPush()
</div>
<div class="button-div" onclick="test_showBigImageShareMenu()">
test_showBigImageShareMenu()
</div>
<div class="button-div" onclick="test_removeWebView()">
test_removeWebView()
</div>
<div class="button-div" onclick="test_changeTitleColorBlack()">
test_changeTitleColorBlack()
</div>
<div class="button-div" onclick="test_changeTitleColorWhite()">
test_changeTitleColorWhite()
</div>
<div class="button-div" onclick="test_closeWebview()">
test_closeWebview()
</div>
<a href="https://view.inews.qq.com/a/TWF201812280026861P?uid=&chlid=news_news_top">h5ToNative专题文章</a>
<a href="https://view.inews.qq.com/a/20181223A0T8FS00?uid=">h5ToNative图文文章</a>
<a href="https://view.inews.qq.com/a/20180829V1TNXI00?uid=&cur_vid=s0770adlxac">h5ToNative视频文章</a>
<script type="text/javascript">
var alertInfo = function (res) {
alert(res)
};
var test_regReceiver = function () {
if (window.TencentNews && window.TencentNews.regReceiver) {
var jsonObject = {
onCallback:function (ret) {
alert('"监听注册成功,可在当前webview或新打开webview发送广播了"')
}
};
window.TencentNews.regReceiver(jsonObject);
} else {
alert(' 没有注册接口!')
}
}
var broadcastMsg = {"content":"broadcast msg"};
<!--var broadcastMsg = {"content":{"broad_key":"broad_value"}}-->
var test_broadcastMsg = function () {
if (window.TencentNews && window.TencentNews.broadcastMsg) {
alert('广播成功,可在注册的webview中接受到改事件')
window.TencentNews.broadcastMsg(broadcastMsg);
} else {
alert(' 没有注册接口!')
}
}
var notifyAppMsg = {
"content": {
"sign_success":"1",
"force_point_strong_tip":"1"
}
};
var test_notifyAppMsg = function () {
if (window.TencentNews && window.TencentNews.notifyAppMsg) {
window.TencentNews.notifyAppMsg(notifyAppMsg);
alert('通知成功:'+ JSON.stringify(notifyAppMsg))
} else {
alert(' 没有注册接口!')
}
}
var test_getConfigInfo = function () {
if (window.TencentNews && window.TencentNews.getConfigInfo) {
window.TencentNews.getConfigInfo("newUserTaskReadCount");
} else {
alert(' 没有注册接口!')
}
}
var test_jumpToChannelWithFloat = function () {
var jsonObject = {
"onCallback": "",
"channelId": "news_news_sports",
"floatInfo": {
"iconUrl": "http://inews.gtimg.com/newsapp_bt/0/2734515840/641",
"iconDesc": "获得超级勋章",
"title": "体育领域冠军",
"description": "体育领域达到500分",
"buttonText": "返回智者荣耀",
"openUrl": "file:///android_asset/test_js_api.html"
}
};
if (window.TencentNews && window.TencentNews.jumpToChannelWithFloat) {
//window.TencentNews.jumpToChannelWithFloat('','news_news_sports',JSON.stringify(jsonObject));
window.TencentNews.jumpToChannelWithFloat(jsonObject);
} else {
alert("没有注册接口!");
}
}
var test_showBigImageShareMenu = function () {
var jsonObject = {
"url": "https://file.service.qq.com/user-files/uploads/201903/4f05bb2b9d557ec64d45d65847098607.jpg",
"onCallback": function (res) {
alert(JSON.stringify(res))
}
};
if (window.TencentNews && window.TencentNews.showBigImageShareMenu) {
window.TencentNews.showBigImageShareMenu(jsonObject);
} else {
alert("没有注册接口!");
}
}
var test_removeWebView = function () {
if (window.TencentNews && window.TencentNews.removeWebView) {
window.TencentNews.removeWebView();
} else {
alert("没有注册接口!");
}
}
var test_jumpToChannelWithFloatTest = function () {
var jsonObject = {
"iconUrl": "http://inews.gtimg.com/newsapp_ls/0/214174d957805441135aef21fd29c564/0",
"iconDesc": "获得超级勋章",
"description": "体育领域达到500分",
"buttonText": "点击返回",
"openUrl": "file:///android_asset/test_js_api.html"
};
if (window.TencentNews && window.TencentNews.jumpToChannelWithFloat) {
window.TencentNews.jumpToChannelWithFloat('alertInfo','news_news_sports',JSON.stringify(jsonObject));
} else {
alert("没有注册接口!");
}
}
var test_getAppInfo = function () {
if (window.TencentNews && window.TencentNews.getAppInfo) {
window.TencentNews.getAppInfo('alertInfo');
} else {
alert("没有注册接口!");
}
}
var test_getNetworkStatus = function () {
if (window.TencentNews && window.TencentNews.getNetworkStatus) {
window["getNetworkStatusCallBack"] = function (re) {
alert("当前网络状态:" + re);
};
window.TencentNews.getNetworkStatus("getNetworkStatusCallBack");
} else {
alert("没有注册接口!");
}
}
var test_getImei = function () {
if (window.TencentNews && window.TencentNews.getImei) {
window.TencentNews.getImei('alertInfo');
} else {
alert("没有注册接口!");
}
}
var test_getUid = function () {
if (window.TencentNews && window.TencentNews.getUid) {
window.TencentNews.getUid('alertInfo');
} else {
alert("没有注册接口!");
}
}
var test_getGestureQuit = function () {
if (window.TencentNews && window.TencentNews.getGestureQuit) {
window["getGestureQuitNameCallBack"] = function (re) {
alert(re);
};
window.TencentNews.getGestureQuit("getGestureQuitNameCallBack");
} else {
alert("没有注册接口!");
}
}
var test_setGestureQuit_1 = function () {
if (window.TencentNews && window.TencentNews.setGestureQuit) {
window.TencentNews.setGestureQuit(true);
} else {
alert("没有注册接口!");
}
}
var test_setGestureQuit_2 = function () {
if (window.TencentNews && window.TencentNews.setGestureQuit) {
window.TencentNews.setGestureQuit(false);
} else {
alert("没有注册接口!");
}
}
var test_enableShowBigImg = function () {
if (window.TencentNews && window.TencentNews.enableShowBigImg) {
window.TencentNews.enableShowBigImg(1);
} else {
alert("没有注册接口!");
}
}
var test_showWarningTips = function () {
if (window.TencentNews && window.TencentNews.showWarningTips) {
window.TencentNews.showWarningTips("警告你不要乱搞啊!!!");
} else {
alert("没有注册接口!");
}
}
var test_showSuccessTips = function () {
if (window.TencentNews && window.TencentNews.showSuccessTips) {
window.TencentNews.showSuccessTips("操作成功!");
} else {
alert("没有注册接口!");
}
}
var test_showErrorTips = function () {
if (window.TencentNews && window.TencentNews.showErrorTips) {
window.TencentNews.showErrorTips("哎哟,崩溃了!");
} else {
alert("没有注册接口!");
}
}
var test_showTextTips = function () {
if (window.TencentNews && window.TencentNews.showTextTips) {
window.TencentNews.showTextTips("next tips");
} else {
alert("没有注册接口!");
}
}
var test_showAlert = function () {
if (window.TencentNews && window.TencentNews.showAlert) {
var alertInfo = function (res) {
alert("你点击了[" + res + "]按钮")
};
window.TencentNews.showAlert('0', '测试对话框', '测试一下', '["确定","取消""]', 'alertInfo', '');
} else {
alert("没有注册接口!");
}
}
var test_showActionMenu = function () {
if (window.TencentNews && window.TencentNews.showActionMenu) {
window.TencentNews.showActionMenu();
} else {
alert("没有注册接口!");
}
}
var test_setShareArticleInfo = function () {
if (window.TencentNews && window.TencentNews.setShareArticleInfo) {
window.TencentNews.setShareArticleInfo('分享测试标题', '分享测试长标题',
'分享测试内容', 'http://www.qq.com',
'http://mat1.gtimg.com/www/newsapp/img/android/default_list_logo.png');
} else {
alert("没有注册接口!");
}
}
var test_deleteShareItems = function () {
if (window.TencentNews && window.TencentNews.deleteShareItems) {
window.TencentNews.deleteShareItems("0,1,2");
} else {
alert("没有注册接口!");
}
}
var test_changeMainAccount = function () {
//登录后的回调函数
window["changeMainAccountCallBack"] = function (status, params) {
if (status == 1) {
alert("切换成功:" + params);
}
if (status == 0) {
alert("切换失败:" + params);
}
};
if (window.TencentNews && window.TencentNews.changeMainAccount) {
window.TencentNews.changeMainAccount("changeMainAccountCallBack", "qqorweixin", "自定义参数");
} else {
alert("没有注册接口!");
}
}
var test_showNativeLoginWithType_1 = function () {
//登录后的回调函数
window["showNativeLoginWithTypeCallBack"] = function (status, params) {
if (status == 1) {
alert("登录成功:" + params);
}
if (status == 0) {
alert("登录失败:" + params);
}
};
//调起登录界面包含QQ和微信
if (window.TencentNews && window.TencentNews.showNativeLoginWithType) {
window.TencentNews.showNativeLoginWithType("qqorweixin", "showNativeLoginWithTypeCallBack", "自定义参数");
} else {
alert("没有注册接口!");
}
}
var test_showNativeLoginWithType_2 = function () {
//登录后的回调函数
window["showNativeLoginWithTypeCallBack"] = function (status, params) {
if (status == 1) {
alert("登录成功:" + params);
}
if (status == 0) {
alert("登录失败:" + params);
}
};
//调起登录界面只包含QQ
if (window.TencentNews && window.TencentNews.showNativeLoginWithType) {
window.TencentNews.showNativeLoginWithType("qq", "showNativeLoginWithTypeCallBack", "自定义参数");
} else {
alert("没有注册接口!");
}
}
var test_showNativeLoginWithType_3 = function () {
//登录后的回调函数
window["showNativeLoginWithTypeCallBack"] = function (status, params) {
if (status == 1) {
alert("登录成功:" + params);
}
if (status == 0) {
alert("登录失败:" + params);
}
};
//调起登录界面只包含QQ
if (window.TencentNews && window.TencentNews.showNativeLoginWithType) {
window.TencentNews.showNativeLoginWithType("weixin", "showNativeLoginWithTypeCallBack", "自定义参数");
} else {
alert("没有注册接口!");
}
}
var test_showNativeLoginWithType_4 = function () {
//登录后的回调函数
window["showNativeLoginWithTypeCallBack"] = function (status, params) {
if (status == 1) {
alert("登录成功:" + params);
}
if (status == 0) {
alert("登录失败:" + params);
}
};
//调起登录界面包含QQ和微信
if (window.TencentNews && window.TencentNews.showNativeLoginWithType) {
window.TencentNews.showNativeLoginWithType("qqconnect", "showNativeLoginWithTypeCallBack", "自定义参数");
} else {
alert("没有注册接口!");
}
}
var test_showNativeLoginWithType_5 = function () {
//登录后的回调函数
window["showNativeLoginWithTypeCallBack"] = function (status, params) {
if (status == 1) {
alert("登录成功:" + params);
}
if (status == 0) {
alert("登录失败:" + params);
}
};
//调起登录界面包含QQ和微信
if (window.TencentNews && window.TencentNews.showNativeLoginWithType) {
window.TencentNews.showNativeLoginWithType("qqconnectorweixin", "showNativeLoginWithTypeCallBack", "自定义参数");
} else {
alert("没有注册接口!");
}
}
var test_isQQLogin = function () {
window["isQQLoginCallBack"] = function (re) {
alert(re);
};
if (window.TencentNews && window.TencentNews.isQQLogin) {
window.TencentNews.isQQLogin("isQQLoginCallBack");
} else {
alert("没有注册接口!");
}
}
var test_isWeixinLogin = function () {
window["isWeixinLoginCallBack"] = function (re) {
alert(re);
};
if (window.TencentNews && window.TencentNews.isWeixinLogin) {
window.TencentNews.isWeixinLogin("isWeixinLoginCallBack");
} else {
alert("没有注册接口!");
}
}
var test_setUserData = function () {
if (window.TencentNews && window.TencentNews.setUserData) {
window.TencentNews.setUserData('testKey', 'testValue');
} else {
alert("没有注册接口!");
}
}
var test_getUserData = function () {
if (window.TencentNews && window.TencentNews.getUserData) {
window.TencentNews.getUserData('testKey', 'alert');
} else {
alert("没有注册接口!");
}
}
var test_clearUserData = function () {
if (window.TencentNews && window.TencentNews.clearUserData) {
window.TencentNews.clearUserData('testKey');
} else {
alert("没有注册接口!");
}
}
var test_getMainAccount = function () {
if (window.TencentNews && window.TencentNews.getMainAccount) {
window.TencentNews.getMainAccount('alert');
} else {
alert("没有注册接口!");
}
}
var test_isAvailable = function () {
if (window.TencentNews && window.TencentNews.isAvailable) {
window.TencentNews.isAvailable('alert');
} else {
alert("没有注册接口!");
}
}
var test_setTitle = function () {
if (window.TencentNews && window.TencentNews.setTitle) {
window.TencentNews.setTitle("修改腾讯新闻标题");
} else {
alert("没有注册接口!");
}
}
var test_showNews = function () {
if (window.TencentNews && window.TencentNews.showNews) {
window.TencentNews.showNews('NEW2015061204090900', '');
} else {
alert("没有注册接口!");
}
}
var test_openApp = function () {
if (window.TencentNews && window.TencentNews.openApp) {
window.TencentNews.openApp("", "com.tencent.mobileqq");
} else {
alert("没有注册接口!");
}
}
var test_openNativeUrl_1 = function () {
if (window.TencentNews && window.TencentNews.openNativeUrl) {
window.TencentNews.openNativeUrl("com.tencent.mobileqq");
} else {
alert("没有注册接口!");
}
}
var test_openNativeUrl_2 = function () {
if (window.TencentNews && window.TencentNews.openNativeUrl) {
window.TencentNews.openNativeUrl("http://gdown.baidu.com/data/wisegame/15ac2322108492ab/tengxunxinwen_432.apk");
} else {
alert("没有注册接口!");
}
}
var test_openWebViewWithType = function () {
if (window.TencentNews && window.TencentNews.openWebViewWithType) {
window.TencentNews.openWebViewWithType('http://www.qq.com', '1');
} else {
alert("没有注册接口!");
}
}
var test_openNewWebView = function () {
if (window.TencentNews && window.TencentNews.openWebViewWithType) {
window.TencentNews.openWebViewWithType('file:///android_asset/test_js_api.html', '1');
} else {
alert("没有注册接口!");
}
}
var test_sendPayRequest = function () {
window["sendPayRequesteCallBack"] = function (Json) {
alert("支付后:" + Json);
};
var jsonObject = {
"qnbid": "10001",
"appid": "wx073f4a4daff0abe8",
"partnerid": "1217628601",
"prepayid": "11010000001408054f82907e84946a52",
"noncestr": "a8849b052492b5106526b2331e526138",
"timestamp": "1407233000",
"package": "Sign=Wxpay",
"sign": "d35ec7242bac16907fcbf52c630e077fdfb3ceb9"
};
if (window.TencentNews && window.TencentNews.sendPayRequest) {
window.TencentNews.sendPayRequest(JSON.stringify(jsonObject), "sendPayRequesteCallBack");
} else {
alert("没有注册接口!");
}
}
var test_getAppVersionName = function () {
window["getAppVersionNameCallBack"] = function (re) {
alert(re);
};
if (window.TencentNews && window.TencentNews.getAppVersionName) {
window.TencentNews.getAppVersionName("com.tencent.mobileqq", "getAppVersionNameCallBack");
} else {
alert("没有注册接口!");
}
}
var test_checkCanOpenNativeUrl = function () {
window["checkCanOpenNativeUrlCallBack"] = function (re) {
alert(re);
};
if (window.TencentNews && window.TencentNews.checkCanOpenNativeUrl) {
window.TencentNews.checkCanOpenNativeUrl("com.tencent.mobileqq", "checkCanOpenNativeUrlCallBack");
} else {
alert("没有注册接口!");
}
}
var test_downloadApp = function () {
if (window.TencentNews && window.TencentNews.downloadApp) {
window.TencentNews.downloadApp("http://gdown.baidu.com/data/wisegame/15ac2322108492ab/tengxunxinwen_432.apk", 'com.tencent.news', '腾讯新闻');
} else {
alert("没有注册接口!");
}
}
var test_downloadAppByLocal = function () {
if (window.TencentNews && window.TencentNews.downloadAppByLocal) {
window.TencentNews.downloadAppByLocal('999925258',
'http://dlied5.myapp.com/myapp/1105562722/hlxq/10002369_com.tencent.tmgp.hlxq_a121_1.2.31.0.apk',
'com.tencent.tmgp.hlxq',
'欢乐球吃球',
'1.2.31.0',
"透传字段"
);
} else {
alert("没有注册接口!");
}
}
var test_downloadAppFromBrowser = function () {
if (window.TencentNews && window.TencentNews.downloadAppFromBrowser) {
window.TencentNews.downloadAppFromBrowser("http://gdown.baidu.com/data/wisegame/15ac2322108492ab/tengxunxinwen_432.apk");
} else {
alert("没有注册接口!");
}
}
var test_getCurrentLocationInfo = function () {
if (window.TencentNews && window.TencentNews.getCurrentLocationInfo) {
window.TencentNews.getCurrentLocationInfo({
onCallback: function (res) {
alert(JSON.stringify(res))
}
});
} else {
alert("没有注册接口!");
}
}
var test_getCurrentSubChannelCityInfo = function () {
if (window.TencentNews && window.TencentNews.getCurrentSubChannelCityInfo) {
window.TencentNews.getCurrentSubChannelCityInfo({
channelID: "news_news_auto",
onCallback: function (res) {
alert(JSON.stringify(res))
}
});
} else {
alert("没有注册接口!");
}
}
var test_copy = function () {
if (window.TencentNews && window.TencentNews.copy) {
window.TencentNews.copy("test");
} else {
alert("没有注册接口!");
}
}
var bossJson = {"eventID":"boss_report_cross_detail_up_scroll", "params":{"currPage":"4"}};
var test_sendBoss = function () {
if (window.TencentNews && window.TencentNews.sendBoss) {
window.TencentNews.sendBoss(bossJson);
} else {
alert("没有注册接口!");
}
}
var test_zoomImageSrc = function () {
if (window.TencentNews && window.TencentNews.zoomImageSrc) {
window.TencentNews.zoomImageSrc('http://mat1.gtimg.com/www/newsapp/img/android/default_list_logo.png');
} else {
alert("没有注册接口!");
}
}
var test_playVideo = function () {
if (window.TencentNews && window.TencentNews.playVideo) {
window.TencentNews.playVideo("http://player.youku.com/embed/XNzQxMjg1OTQw");
} else {
alert("没有注册接口!");
}
}
var test_setTagSecondTitle_1 = function () {
if (window.TencentNews && window.TencentNews.setTagSecondTitle) {
window.TencentNews.setTagSecondTitle({"title":"英超 排名19"});
} else {
alert("没有注册接口!");
}
}
var test_setTagSecondTitle_2 = function () {
if (window.TencentNews && window.TencentNews.setTagSecondTitle) {
window.TencentNews.setTagSecondTitle({"title":""});
} else {
alert("没有注册接口!");
}
}
var test_setReturnBtnActionType_1 = function () {
if (window.TencentNews && window.TencentNews.setReturnBtnActionType) {
window.TencentNews.setReturnBtnActionType(1);
} else {
alert("没有注册接口!");
}
}
var test_setReturnBtnActionType_0 = function () {
if (window.TencentNews && window.TencentNews.setReturnBtnActionType) {
window.TencentNews.setReturnBtnActionType(0);
} else {
alert("没有注册接口!");
}
}
var test_getWeixinUserInfo = function () {
if (window.TencentNews && window.TencentNews.getWeixinUserInfo) {
window.TencentNews.getWeixinUserInfo('alertInfo');
} else {
alert("没有注册接口!");
}
}
var test_syncRedpacketUpdateInfo = function () {
if (window.TencentNews && window.TencentNews.syncRedpacketUpdateInfo) {
window.TencentNews.syncRedpacketUpdateInfo('1', '2');
} else {
alert("没有注册接口!");
}
}
var test_getUserInfo = function () {
if (window.TencentNews && window.TencentNews.getUserInfo) {
window.TencentNews.getUserInfo('alertInfo');
} else {
alert("没有注册接口!");
}
}
var test_setSyncStatus_1 = function () {
if (window.TencentNews && window.TencentNews.setSyncStatus) {
window.TencentNews.setSyncStatus(true);
alert("同步成功")
} else {
alert("没有注册接口!");
}
}
var test_setSyncStatus_2 = function () {
if (window.TencentNews && window.TencentNews.setSyncStatus) {
window.TencentNews.setSyncStatus(false);
alert("同步失败")
} else {
alert("没有注册接口!");
}
}
var test_getAllInstalledApp = function () {
window["getAllInstalledAppCallBack"] = function (re) {
alert(re);
};
if (window.TencentNews && window.TencentNews.getAllInstalledApp) {
window.TencentNews.getAllInstalledApp("getAllInstalledAppCallBack");
} else {
alert("没有注册接口!");
}
}
var test_isAppInstalled = function (pkgName) {
if (window.TencentNews && window.TencentNews.isAppInstalled) {
var ret = window.TencentNews.isAppInstalled(pkgName);
alert("isInstalled:" + ret);
} else {
alert("没有注册接口!");
}
}
var test_setActionBtn_0 = function () {
if (window.TencentNews && window.TencentNews.setActionBtn) {
window.TencentNews.setActionBtn("0");
alert("设置的0")
} else {
alert("没有注册接口!");
}
}
var test_setActionBtn_1 = function () {
if (window.TencentNews && window.TencentNews.setActionBtn) {
window.TencentNews.setActionBtn("1");
alert("设置的1")
} else {
alert("没有注册接口!");
}
}
var test_setActionBtn_2 = function () {
if (window.TencentNews && window.TencentNews.setActionBtn) {
window.TencentNews.setActionBtn("2");
alert("设置的2")
} else {
alert("没有注册接口!");
}
}
var test_saveImageToLocal = function () {
if (window.TencentNews && window.TencentNews.saveImageToLocal) {
window.TencentNews.saveImageToLocal("http://inews.gtimg.com/newsapp_match/0/574349072/0","gif");
} else {
alert("没有注册接口!");
}
}
var json = {
"appId": "test123456",
"apkUrl": "http://dd.myapp.com/16891/CAAE58B9F18A454A4F2F0D9BF3430921.apk?fsname=com.yuyuetech.yuyue_2.2.3_7.apk",
"packageName": "com.yuyuetech.yuyue",
"appName": "寓悦家居",
"logoUrl": "http://pp.myapp.com/ma_icon/0/icon_12261780_1457414413/256",
"actionCode": 1,
"versionCode": 1,
"md5": "d4f73a30b8a225e53c0d56e3e1167685"
};
var test_checkAppStatus = function () {
if (window.TencentNews && window.TencentNews.checkAppStatus) {
window.TencentNews.checkAppStatus(JSON.stringify(json), "apkCallback");
} else {
alert("没有注册接口!");
}
}
var test_downloadApp_gdt = function () {
if (window.TencentNews && window.TencentNews.downloadApp_gdt) {
window.TencentNews.downloadApp_gdt(JSON.stringify(json), "apkCallback");
} else {
alert("没有注册接口!");
}
}
var test_installApp = function () {
if (window.TencentNews && window.TencentNews.installApp) {
window.TencentNews.installApp(JSON.stringify(json), "apkCallback");
} else {
alert("没有注册接口!");
}
}
var test_launchApp = function () {
if (window.TencentNews && window.TencentNews.launchApp) {
window.TencentNews.launchApp(JSON.stringify(json));
} else {
alert("没有注册接口!");
}
}
var apkCallback = function (status, progress) {
document.getElementById("callback").innerHTML = "status = " + status + ", progress = " + progress;
}
var test_syncSignPointUpdateInfo = function () {
if (window.TencentNews && window.TencentNews.syncSignPointUpdateInfo) {
window.TencentNews.syncSignPointUpdateInfo(1);
} else {
alert("没有注册接口!");
}
}
var test_loginOut = function () {
if (window.TencentNews && window.TencentNews.logoutMainAccount) {
window.TencentNews.logoutMainAccount();
} else {
alert("没有注册接口!");
}
}
function logoutCallback(status) {
console.log("logoutCallback status : "+status);
}
var test_loginOut_callBack = function () {
if (window.TencentNews && window.TencentNews.logoutMainAccount) {
window.TencentNews.logoutMainAccount("logoutCallback");
} else {
alert("没有注册接口!");
}
}
function buyDiamondCallback(success) {
console.log("buyDiamondCallback success:" + success);
}
var test_buyDiamond = function () {
if (window.TencentNews && window.TencentNews.buyDiamond) {
console.log("buyDiamondCallback test_buyDiamond()");
window.TencentNews.buyDiamond("title1", "subtitle1", "99", "buyDiamondCallback");
} else {
alert("没有注册接口!");
}
}
var imagesJson = {
"imagelist": [
{
"url": "http://inews.gtimg.com/newsapp_bt/0/2300973818/1000",
"desc": "四川工程职业技术学院15级艺术系学前教育一班是个比较特殊的班级,他们班总共51人,其中50人都是女生,仅有1名男生。由于明年将毕业,近日他们拍摄了一组毕业照,这名男"
},
{
"url": "http://inews.gtimg.com/newsapp_bt/0/2300973616/641",
"desc": "班长杜泓颖介绍说,这组毕业照是由学院的“影璀摄影工作室”帮忙拍摄的。在列队组合时,作为班上的唯一例外,这名男生成为“班花”,享受特别优待,其他女生心甘情愿作为绿叶。"
},
{
"url": "http://inews.gtimg.com/newsapp_bt/0/2300973914/1000",
"desc": "男生名叫李先强,他性格活泼开朗,虽然平时显得有些“孤单”,但跟同学们相处很融洽。李先强说:“当初报考这个专业的时候,估计男生会比较少,但入学后才发现居然只有自己一个"
},
{
"url": "http://inews.gtimg.com/newsapp_bt/0/2300973615/641",
"desc": "四川工程职业技术学院15级艺术系学前教育一班是个比较特殊的班级,他们班总共51人,其中50人都是女生,仅有1名男生。由于明年将毕业,近日他们拍摄了一组毕业照,这名男生成为绝对的焦点:以他为中心,"
},
{
"url": "http://inews.gtimg.com/newsapp_bt/0/2300973813/1000",
"desc": "班长杜泓颖介绍说,这组毕业照是由学院的“影璀摄影工作室”帮忙拍摄的。在列队组合时,作为班上的唯一例外,这名男生成为“班花”,享受特别优待,其他女生心甘情愿作为绿叶。"
},
{
"url": "http://inews.gtimg.com/newsapp_bt/0/2300973885/641",
"desc": "男生名叫李先强,他性格活泼开朗,虽然平时显得有些“孤单”,但跟同学们相处很融洽。李先强说:“当初报考这个专业的时候,估计男生会比较少,但入学后才发现居然只有自己一个"
}
]
};
var test_previewDetailImage = function () {
if (window.TencentNews && window.TencentNews.previewDetailImage) {
window.TencentNews.previewDetailImage(3,JSON.stringify(imagesJson));
} else {
alert("没有注册接口!");
}
}
var test_setBottomBarVisibility_true = function () {
if (window.TencentNews && window.TencentNews.setBottomBarVisibility) {
window.TencentNews.setBottomBarVisibility(true);
} else {
alert("没有注册接口!");
}
}
var test_setBottomBarVisibility_false = function () {
if (window.TencentNews && window.TencentNews.setBottomBarVisibility) {
window.TencentNews.setBottomBarVisibility(false);
} else {
alert("没有注册接口!");
}
}
var test_getAdInfo = function () {
if (window.TencentNews && window.TencentNews.getAdInfo) {
alert(window.TencentNews.getAdInfo());
} else {
alert("没有注册接口!");
}
}
var test_appUsedSceonds = function () {
if (window.TencentNews && window.TencentNews.appUsedSceonds) {
window.TencentNews.appUsedSceonds('alertInfo');
} else {
alert("没有注册接口!");
}
}
function pluginRequestCallBack(result){
console.log("pluginRequestCallBack :" + result);
window.TencentNews.showWarningTips("pluginRequestCallBack :" + result);
}
var jsonParams = '{"mid":"123456","isShow":true,"double":12.345}';
var test_pluginRequest = function () {
if (window.TencentNews && window.TencentNews.pluginRequest) {
window.TencentNews.pluginRequest("com.tencent.news.main", "request_news_monetary",jsonParams,"pluginRequestCallBack");
} else {
alert("没有注册接口!");
}
}
var invokeJsonParams = '{"sports_ext":{"type":"20001","param":{"columnId":"100000","searchKey":"NBA","title":"NBA","tab":"1"}}}';
var test_pluginInvoke = function () {
if (window.TencentNews && window.TencentNews.pluginInvoke) {
window.TencentNews.pluginInvoke("com.tencent.news.sports", "206",invokeJsonParams);
} else {
alert("没有注册接口!");
}
}
var test_adjustWebViewInfo = function () {
if (window.TencentNews && window.TencentNews.adjustWebViewInfo) {
var params = '{"aspectRatio":1.2}';
window.TencentNews.adjustWebViewInfo(params);
alert("调整宽高比:1.2");
} else {
alert("没有注册接口!");
}
}
var jsonReadingParams = '{"STR_MSG_COMIC_BOOK_ID":"542861", "STR_MSG_COMIC_TITLE":"宅妖记"}'
var test_openReadingPage = function () {
if (window.TencentNews && window.TencentNews.pluginRequest) {
window.TencentNews.pluginRequest("com.tencent.news.comic", "open_reading_page", jsonReadingParams, "pluginRequestCallBack");
} else {
alert(' 没有注册接口!')
}
}
var test_openBookShelfPage = function () {
if (window.TencentNews && window.TencentNews.pluginRequest) {
window.TencentNews.pluginRequest("com.tencent.news.comic", "open_bookshelf_page", "", "pluginRequestCallBack");
} else {
alert(' 没有注册接口!')
}
}
var test_openClassifyPage = function () {
if (window.TencentNews && window.TencentNews.pluginRequest) {
window.TencentNews.pluginRequest("com.tencent.news.comic", "open_classify_page", "", "pluginRequestCallBack");
} else {
alert(' 没有注册接口!')
}
}
var jsonWebParams = '{"WEBVIEW_H5_URL_FLAG":"file:///android_asset/test_js_api_1.html", "WEBVIEW_H5_TITLE_FLAG":"测试页面"}'
var test_openWebViewPage = function () {
if (window.TencentNews && window.TencentNews.pluginRequest) {
window.TencentNews.pluginRequest("com.tencent.news.comic", "open_webview_page", jsonWebParams, "pluginRequestCallBack");
} else {
alert(' 没有注册接口!')
}
}
var test_adVideoBeginPlay = function () {
if (window.TencentNews && window.TencentNews.adVideoBeginPlay) {
window.TencentNews.adVideoBeginPlay();
} else {
alert(' 没有注册接口!')
}
}
var refreshTokenCallback = function(a) {
alert(' ret:' + a);
}
var test_refreshWxAccessToken = function () {
if (window.TencentNews && window.TencentNews.refreshWxAccessToken) {
window.TencentNews.refreshWxAccessToken("refreshTokenCallback");
} else {
alert(' 没有注册接口!')
}
}
var test_gotoPushHistoryPage = function () {
if (window.TencentNews && window.TencentNews.gotoPushHistoryPage) {
window.TencentNews.gotoPushHistoryPage();
} else {
alert(' 没有注册接口!')
}
}
var test_getSecurityRequestCheckCode = function() {
if (window.TencentNews && window.TencentNews.getSecurityRequestCheckCode) {
var before = "1537339526";
window.TencentNews.getSecurityRequestCheckCode({
content:before,
onCallback:function (after) {
alert("before:" + before + " after:" + JSON.stringify(after));
}
});
} else {
alert(' 没有注册接口!')
}
}
var test_writeLog = function() {
if (window.TencentNews && window.TencentNews.writeLog) {
var myDate = new Date();
window.TencentNews.writeLog("签到-signlog","content:" + myDate.toLocaleTimeString());
} else {
alert(' 没有注册接口!')
}
}
var test_isAllPushClose = function() {
if (window.TencentNews && window.TencentNews.isAllPushClose) {
window.TencentNews.isAllPushClose({
onCallback:function (ret) {
alert("ret:" + JSON.stringify(ret));
}
});
} else {
alert(' 没有注册接口!')
}
}
var test_isNotificationEnabled = function() {
if (window.TencentNews && window.TencentNews.isNotificationEnabled) {
window.TencentNews.isNotificationEnabled({
onCallback:function (ret) {
alert("ret:" + JSON.stringify(ret));
}
});
} else {
alert(' 没有注册接口!')
}
}
var test_gotoPushSwitchSettingPage = function () {
if (window.TencentNews && window.TencentNews.gotoPushSwitchSettingPage) {
window.TencentNews.gotoPushSwitchSettingPage();
} else {
alert(' 没有注册接口!')
}
}
var test_enableLocalPush = function () {
if (window.TencentNews && window.TencentNews.enableLocalPush) {
window.TencentNews.enableLocalPush();
} else {
alert(' 没有注册接口!')
}
}
var test_changeTitleColorBlack = function () {
if (window.TencentNews && window.TencentNews.launchApp) {
window.TencentNews.setStatusBarColor(0);
} else {
alert("没有注册接口!");
}
}
var test_changeTitleColorWhite = function () {
if (window.TencentNews && window.TencentNews.launchApp) {
window.TencentNews.setStatusBarColor(1);
} else {
alert("没有注册接口!");
}
}
var test_closeWebview = function () {
if (window.TencentNews && window.TencentNews.launchApp) {
window.TencentNews.closeWebview();
} else {
alert("没有注册接口!");
}
}
var test_isMethodSupport = function () {
if (window.TencentNews && window.TencentNews.isMethodSupport) {
window.TencentNews.isMethodSupport('share');
} else {
alert("没有注册接口!");
}
}
var test_share = function () {
window.TencentNews.setShareArticleInfo('分享测试标题', '分享测试长标题',
'分享测试内容', 'http://www.qq.com',
'http://mat1.gtimg.com/www/newsapp/img/android/default_list_logo.png');
if (window.TencentNews) {
window.TencentNews.invoke('share','qqFriend');
} else {
alert("没有注册接口!");
}
}
var test_abc = function(){prompt("{\"method\":\"getUserInfo\",\"types\":[\"string\"],\"types\":[\"string\"],\"args\":[\"alertInfo\"],\"instanceName\":\"TencentNews\"}","");};
var test_webview_bug = function() {
setTimeout(test_abc,80);
location.href='https://www.qq.com/hhhhhhhhhhhhh';
}
// <!--console.log("window.DeviceMotionEvent");-->
// <!--var deviceMotionHandler = function () {-->
// <!--console.log("disableDeviceMonitor window.deviceMotionHandler");-->
// <!--}-->
// <!--var deviceMotionHandler2 = function () {-->
// <!--console.log("disableDeviceMonitor window.deviceorientation");-->
// <!--}-->
// <!--var deviceMotionHandler3 = function () {-->
// <!--console.log("disableDeviceMonitor window.compassneedscalibration");-->
// <!--}-->
// <!--if (window.DeviceMotionEvent) {-->
// <!--window.addEventListener('devicemotion', deviceMotionHandler, false);-->
// <!--}-->
// <!--window.addEventListener('deviceorientation', deviceMotionHandler2, false);-->
// <!--window.addEventListener('compassneedscalibration', deviceMotionHandler3, false);-->
</script>
</body>
</html>
原文地址:https://www.cnblogs.com/wangRong-smile/p/12058422.html
时间: 2024-10-25 07:00:49