vesh-cli
Version:
码农村nodejs版本VESH框架脚手架搭建器
136 lines (132 loc) • 7.1 kB
JavaScript
(function (V, W, $) {
V.registScript(function (path, vm) {
var _ = this, __ = {};
V.inherit.apply(_, [W.Control, [path || '<span style="display:none;"></span>', vm || {}]]);
__.onLoad = _.onLoad;
__.render = _.render;
_.fill = function () {
return {};
};
_.onLoad = function (node) {
V.forC(_.events, function (k, v) {
switch (k.toLowerCase()) {
case 'userinfo':
case 'operatecallback':
break;
case 'back':
if (v && !window.clickTitleBar) {
window[_.callClientMethod].isResponseClickBack();
window.clickTitleBar = function (params) {
var s = params.split('?');
if (s.length > 1) s = s[1].toLowerCase().split('&');
if (s.length > 1) {
if (s[0] == 'position=left') {
_.call('back');
}
}
};
}
break;
case 'pay':
if (v && !window.operateCallback) {
window.operateCallback = function (params) {
//yintaimobile://PayResult?orderId=125544
var s = params.split('?');
if (s.length > 1 && s[0].toLowerCase() == 'yintaimobile://payresult') {
s = s[1].toLowerCase().split('=');
_.render({ pageload: true });
setTimeout(function () {
_.render({ pageload: false });
_.call('pay', { paysuccess: true, value: s[1] });
}, 4000);
}
};
}
break;
default:
_.bindEvent(node, k, v);
break;
}
}, function () { __.onLoad(node); });
_.callClientMethod = "callYintaiMobileMethod";
}
_.render = function (data) {
data = __.render(data);
if (V.userAgent.pc) {
} else {
if (!window[_.callClientMethod]) return false;
}
V.forC(data, function (k, v) {
switch (k.toLowerCase()) {
case 'userid'://getUserInfo {"os":"android","cps":"","userid":"",
console.log("AppObject.getUserInfo");
var userInfo = {};
if (V.userAgent.android) {
userInfo = window[_.callClientMethod].getuserinfo();
userInfo = eval("(" + userInfo + ")");
} else if (V.userAgent.iphone) {
userInfo = localStorage["appiosuserinfo"] ? localStorage["appiosuserinfo"] : "{}";
userInfo = eval("(" + userInfo + ")");
} else if (V.userAgent.pc) {
userInfo.userid = "J8M5TQ6KuxslXvLPdjJGeRFT7KYic+FwAugjvkeBkZyhMjTnbiNsqXGvFevk4m/5j34MATD4NWI6BhrPra0wjg==";
}
console.log(userInfo);
if (!userInfo || !userInfo.userid) {
window[_.callClientMethod].jump("yintaimobile://Login"); return;
}
_.call("UserInfo", { userInfo: userInfo });
break;
case 'settitle':
window[_.callClientMethod].setTitleBar('yintaimobile://SetTitleBar?position=middle&isShow=true&value=' + v);
window[_.callClientMethod].isResponseClickBack();
break;
case 'setleftbutton':
window[_.callClientMethod].setTitleBar('yintaimobile://SetTitleBar?position=left&isShow=true&value=' + v);
break;
case 'setrightbutton':
window[_.callClientMethod].setTitleBar('yintaimobile://SetTitleBar?position=right&isShow=true&value=' + v);
break;
case 'shieldtopbottom':
window[_.callClientMethod].setTitleBar('yintaimobile://ShieldTopBottom?state=' + v);
break;
case 'isresponseclickback':
window[_.callClientMethod].isResponseClickBack();
break;
case 'settitlebar'://yintaimobile://SetTitleBar?position=right&isShow=false&value=首页
//yintaimobile://ShieldTopBottom?state=true 设置屏蔽顶部和底部的点击事件
window[_.callClientMethod].setTitleBar('yintaimobile://SetTitleBar?position=middle&isShow=true&value=' + v);
if (v.indexOf('isResponseClickBack') > -1) {
//v = v.replace('&isResponseClickBack', '');
window[_.callClientMethod].isResponseClickBack();
}
break;
case 'startpaynow'://yintaimobile://PayNow?orderId=125544&orderSource=1 1:电子小票支付、2:ERP订单支付
v = "yintaimobile://PayNow?orderId=" + v + "&orderSource=1";
window[_.callClientMethod].startPayNow(v);
break;
case 'scan'://yintaimobile://Scan
v = 'yintaimobile://Scan';
window[_.callClientMethod].jump(v);
break;
case 'showdialog':
v = "yintaimobile://ShowDialog?msg=" + v;
window[_.callClientMethod].showDialog(v);
break;
case 'close':
case 'closecurrentPage':
if (v) {
window[_.callClientMethod].closeCurrentPage();
}
break;
case 'pageload':
if (v) {//是否打开或关闭加载框
window[_.callClientMethod].pageloadopen();
} else {
window[_.callClientMethod].pageloadclose();
}
break;
}
});
}
});
})(VJ, VJ.view, jQuery);