<!DOCTYPE html>
|
<html>
|
<head>
|
<meta charset="utf-8">
|
<title>奖励铂金会员</title>
|
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
|
<script src="https://cdn.bootcss.com/vConsole/3.3.0/vconsole.min.js"></script>
|
<script>
|
window.onresize = function() {
|
document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
|
};
|
window.onresize();
|
</script>
|
<style>
|
body {
|
background: #F3F3F3;
|
margin: 0;
|
padding: 0;
|
font-family: Arial, "Microsoft YaHei";
|
}
|
|
button {
|
display: block;
|
}
|
</style>
|
|
</head>
|
<body>
|
<button onclick="toast()">toast</button>
|
<button onclick="dstoast()">showAwardAd</button>
|
<button onclick="jumpGoodsDetail()">jumpGoodsDetail</button>
|
<button onclick="showAd()">showAd</button>
|
<button onclick="jumpThirdPlatform()">jumpThirdPlatform</button>
|
<button onclick="buyVip()">buyVip</button>
|
<button onclick="vipPayFinish()">苹果内购支付结果通知</button>
|
<button onclick="getUid()">getUid</button>
|
<button onclick="getRequestBaseParams()">.getRequestBaseParams</button>
|
<button onclick="showLoading()">showLoading</button>
|
|
|
</body>
|
|
<script src="https://cdn.bootcdn.net/ajax/libs/dsbridge/3.1.4/dsbridge.min.js"></script>
|
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
|
</script>
|
|
<script>
|
function toast() {
|
bridge.call("yestv.toast", "123123");
|
}
|
|
function dstoast() {
|
bridge.call("yestv.showAwardAd", {
|
id: '123123'
|
}, function(res) {
|
yestv.toast("广告回调");
|
});
|
}
|
|
|
function jumpGoodsDetail() {
|
bridge.call("yestv.jumpGoodsDetail", {
|
id: '640225471587',
|
goodsType: 1,
|
from: 'test'
|
});
|
|
}
|
|
function showAd() {
|
// bridge.call("yestv.showAwardAd", {
|
// pid: '946119116',
|
// type: 'csj',
|
// }, function(res) {
|
// res=JSON.parse(res);
|
// if (res.code == 0) {
|
// yestv.toast("广告展示成功");
|
// }
|
// });
|
bridge.call("yestv.toastAwardSuccess", "成功获得1天铂金会员权益");
|
}
|
|
function jumpThirdPlatform() {
|
bridge.call("yestv.jumpThirdPlatform", {
|
sourceType: 2,
|
jumpLink: "https://u.jd.com/GfjARui",
|
wxxcxJumpInfo: {
|
path: "pages/union/proxy/proxy?spreadUrl=https%3A%2F%2Fu.jd.com%2FGfjARui",
|
userName: "gh_45b306365c3d"
|
}
|
});
|
}
|
|
function buyVip() {
|
bridge.call("yestv.buyVip", {
|
code: "ysdq_month",
|
orderNo: "213123"
|
}, function(auth) {
|
yestv.toast("支付凭证回调成功:" + auth)
|
});
|
}
|
|
function vipPayFinish() {
|
bridge.call("yestv.vipPayFinish", 1);
|
}
|
|
function getUid() {
|
var uid = bridge.call("yestv.getUid");
|
bridge.call("yestv.toast", "uid:" + uid);
|
}
|
|
function getRequestBaseParams() {
|
var result = bridge.call("yestv.getRequestBaseParams", {
|
id: 123
|
});
|
bridge.call("yestv.toast", "结果:" + result);
|
}
|
|
function showLoading() {
|
bridge.call("yestv.showLoading");
|
setTimeout(function() {
|
bridge.call("yestv.hideLoading");
|
}, 3000);
|
}
|
|
|
|
$(function() {
|
const formUtil = {
|
|
/**
|
* 将表单转为对象
|
* @param fileds
|
*/
|
formFieldsToJSON: function(fileds) {
|
var finalResult = {};
|
for (key in fileds) {
|
var obj = {};
|
obj[key] = fileds[key];
|
var tempResult = this.formFieldToJSON(obj);
|
var keys = new Array();
|
|
while (Object.prototype.toString.call(tempResult) === '[object Object]') {
|
var key = Object.keys(tempResult)[0];
|
keys.push(key);
|
tempResult = tempResult[key];
|
}
|
|
var temp = "finalResult";
|
for (var i = 0; i < keys.length; i++) {
|
temp += "['" + keys[i] + "']";
|
if (i != keys.length - 1) {
|
if (eval(temp + "==undefined") == true) {
|
eval(temp + "={}");
|
}
|
} else {
|
eval(temp + "=" + (isNaN(tempResult) ? "'" + tempResult + "'" : tempResult));
|
}
|
}
|
}
|
|
return finalResult;
|
},
|
formFieldToJSON: function(field) {
|
var key = Object.keys(field)[0];
|
var value = field[key];
|
var keys = key.split(".");
|
if (keys.length > 1) {
|
var newValue = {};
|
var k = keys[keys.length - 1];
|
keys.splice(keys.length - 1, 1);
|
newValue[k] = value;
|
var final = {};
|
final[keys.join(".")] = newValue;
|
return this.formFieldToJSON(final);
|
} else {
|
return field;
|
}
|
},
|
jsonToFormField: function(data) {
|
var result = {};
|
for (key in data) {
|
if (Object.prototype.toString.call(data[key]) === '[object Object]') {
|
for (ckey in data[key]) {
|
result[key + "." + ckey] = data[key][ckey];
|
}
|
} else {
|
result[key] = data[key];
|
}
|
}
|
return result;
|
}
|
};
|
|
var form = {
|
"app.id": 123,
|
"app.name": "测试",
|
"app.p.id": "id",
|
"app.p.key": "key",
|
id: 12312312,
|
name: "测试123"
|
};
|
|
var result = formUtil.formFieldsToJSON(form);
|
console.log(result)
|
|
var json = {
|
app: {
|
id: 123,
|
name: "测试"
|
},
|
id: 1
|
}
|
result = formUtil.jsonToFormField(json);
|
console.log(result)
|
})
|
</script>
|
|
|
|
|
</html>
|