<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
<html>
|
<head>
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
<title>API测试</title>
|
</head>
|
<script type="text/javascript">
|
var ua = navigator.userAgent.toLowerCase();
|
var os = 0;
|
if (/iphone|ipad|ipod/.test(ua)) {
|
os = 2;
|
} else if (/android/.test(ua)) {
|
os = 1;
|
}
|
|
var accessToken;
|
|
function sleep(n) {
|
var start = new Date().getTime();
|
while (true)
|
if (new Date().getTime() - start > n)
|
break;
|
}
|
|
function wxpay(appId, partnerId, prepayId, packageValue, nonceStr,
|
timeStamp, sign) {//微信支付
|
if (os == 1)//Android
|
window.yestvapi.wxpay(appId, partnerId, prepayId, packageValue,
|
nonceStr, timeStamp, sign);
|
else if (os == 2)//IOS
|
{
|
YESTV_IOS_wxpay(appId, partnerId, prepayId, packageValue, nonceStr,
|
timeStamp, sign);
|
}
|
}
|
|
function toast(content) {
|
if (os == 1)//Android
|
window.yestvapi.toast(content);
|
else if (os == 2)//IOS
|
{
|
YESTV_IOS_toast(content);
|
}
|
}
|
|
function notifyAccessToken(content) {
|
//alert(content);
|
accessToken = content;
|
}
|
|
function getAccessToken() {
|
if (os == 1)//Android
|
{
|
accessToken = window.yestvapi.getAccessToken();
|
alert(accessToken);
|
return accessToken;
|
} else if (os == 2)//IOS
|
{
|
YESTV_IOS_getAccessToken();
|
sleep(1000);//停留1s等待回调
|
alert(accessToken);
|
return accessToken;
|
}
|
}
|
|
function finishView() {
|
if (os == 1)//Android
|
window.yestvapi.finishView();
|
else if (os == 2)//IOS
|
{
|
YESTV_IOS_finishView();
|
}
|
}
|
|
function jumpToLogin() {
|
if (os == 1)//Android
|
window.yestvapi.jumpToLogin();
|
else if (os == 2)//IOS
|
{
|
YESTV_IOS_jumpToLogin();
|
}
|
}
|
|
function showProcessDialog() {//显示进度框
|
if (os == 1)//Android
|
window.yestvapi.showProcessDialog();
|
else if (os == 2)//IOS
|
{
|
YESTV_IOS_showProcessDialog();
|
}
|
}
|
|
function closeProcessDialog() {//关闭进度框
|
if (os == 1)//Android
|
window.yestvapi.closeProcessDialog();
|
else if (os == 2)//IOS
|
{
|
YESTV_IOS_closeProcessDialog();
|
}
|
}
|
</script>
|
<body>
|
|
<input type="button" value="提示弹出" onclick="toast('123123123')">
|
<br />
|
<input type="button" value="获取AccessToken" onclick="getAccessToken()">
|
<br />
|
<input type="button" value="结束当前页面" onclick="finishView()">
|
<br />
|
<input type="button" value="跳转到登录页面" onclick="jumpToLogin()">
|
|
</body>
|
</html>
|