首页 新闻 会员 周边 捐助

腾讯 是怎么实现JS包装的 想调用里面的方法 如何实现 有兴趣的一起讨论

0
悬赏园豆:50 [已关闭问题] 关闭于 2016-04-28 17:34

地址是这个 https://www.tenpay.com/v2/account/receive/index.shtml

收款里面有个按钮的事件被注释了 请问 我怎么才能调用 ?

id:receive_next_btn

 

 

var DEFAULT_CONF = {
'accept_uin': '支持QQ号/Email/手机号码',
'fee': '单笔限额2千',
'receive_memo': '对方会看到收款理由,可不填写'
};
YUI({'combine' : true}).use('until', 'md5', 'datavalid', 'substitute', function(Y){
var Receive = {
uin: null,
valid: null,
ISQQ: true,
para : null,
timer: null,
queryAcceptInfoResult: function (ioId, o) {
var data = Y.until.parseJson(o.responseText),
retcode = +data.retcode,
retmsg = data.retmsg;
switch(retcode){
case 0:
var token_key = data.token_key || "";
//更新token_key,还没写
//this.para[5] = 'token_key=' + token_key;
Receive.redirectToConfirmPage();
break;
case 1012: //对方未注册财付通
Receive.valid.output('accept_uin', "对方未注册财付通,不能向其收款");
break;
case 51016401: //对方账户被冻结
Receive.valid.output('accept_uin', "对方账户被冻结,不能向其收款");
break;
case 51016404: //不是好友,不是7天好友
case 51001038: //查询好友失败
Receive.valid.output('accept_uin', Y.until.formatMsg(retmsg));
break;
case 51016405: //收款金额超出单笔上限
Receive.valid.output('fee', Y.until.formatMsg(retmsg));
break;
case 51001000: // 超时
case 51001001:
top.YUI({combine: true}).use('login', function (Y) {
Y.Login.pop();
});
break;
default:
Y.until.showError(retmsg, retcode);
Y.until.request.end('#receive_next_btn_wrap');
}
},
// 查询接收方信息
queryAcceptInfo: function () {
var loadingBtn = "#receive_next_btn_wrap";
var notify_flag = Y.one('#msg_notify').get('checked');
var memo = Y.one("#receive_memo").get('value');
memo = memo == DEFAULT_CONF.receive_memo ? "" : memo;
var data = this.para = [
'amount=' + Y.one('#fee').get('value'),
'pay_uin=' + Y.one('#accept_uin').get('value'),
'remark=' + encodeURIComponent(memo),
'send_pay_mobile=' + (notify_flag ? "1" : "0"),
'pay_mobile=' + (notify_flag ? Y.one('#mobile').get('value') : ""),
'token_key=' + Y.one('#token_key').get('value')
];

var url = '/app/v1.0/ask_money.cgi',
cfg = {
method: 'post',
data: data.join("&"),
context: this,
on: {
success: this.queryAcceptInfoResult,
complete : Y.until.request.complete
},
arguments: {
node: loadingBtn
}
};
Y.io(url, cfg);
},
//转去确认页
redirectToConfirmPage : function(){
var data = this.para;
/* 参数完整性规则 [[ */
var qlskey = Y.Cookie.get('qlskey'), md5 = Y.MD5(qlskey + encodeURIComponent(decodeURIComponent(data.join('&'))));
data.push('md5=' + md5);
/* 参数完整性规则 ]] */
window.location.replace('https://www.tenpay.com/v2/account/receive/confirm.shtml?' + data.join('&'));
},
queryQQFriendResult: function (ioId, o) {
var data = Y.until.parseJson(o.responseText),
retcode = +data.retcode,
retmsg = data.retmsg;
if (0 == retcode) {
var friend_list = data['friendlist'],
group_list = data['grouplist'];
this.CACHE_QQ_FRIEND = {
"friendlist": friend_list,
"grouplist": group_list
};
Y.one('#contact .linkman-qq').removeClass('loading');
this.buildQQFriend();
} else {
Y.one('#contact .linkman-qq .tips-info').setContent('<span class="ico-info-s"><!-- 图标 --></span>&nbsp;系统繁忙,请稍候再试').removeClass('hide').get('parentNode').removeClass('loading');
Y.one('#qq_friend').addClass('hide');
}
},
// 查询QQ好友信息
queryQQFriend: function () {
var url = '/app/v1.0/qryfriends.cgi',
cfg = {
method: 'get',
data: 'OutPutType=JSON',
context: this,
on: {
success: this.queryQQFriendResult
}
};
Y.io(url, cfg);
},
queryHistoryInfoResult: function (ioId, o) {
var data = Y.until.parseJson(o.responseText),
retcode = +data.retcode,
retmsg = data.retmsg;
if (0 == retcode) {
var list = data['pay_friend_list'] || [];
this.CACHE_HISTORY_PAYEE = list;
if (list.length > 0) {
this.buildHistoryPayee();
} else {
if (this.ISQQ) {
this.switchFriendQQ();
} else {
// 记录为空的时候处理
Y.one('#contact .linkman-history').removeClass('loading');
Y.one('#contact .linkman-history .tips-info').removeClass('hide');
Y.one('#contact_man').addClass('hide');
this.isShowHistory = true;
}
}
} else {
Y.one('#contact .linkman-history .tips-info').setContent('<span class="ico-info-s"><!-- 图标 --></span>&nbsp;系统繁忙,请稍候再试').removeClass('hide').get('parentNode').removeClass('loading');
Y.one('#contact_man').addClass('hide');
}
},
// 查询历史付款信息
queryHistoryInfo: function () {
var url = '/app/v1.0/qry_pay_friend.cgi',
cfg = {
method: 'post',
data: 'actionid=3',
context: this,
on: {
success: this.queryHistoryInfoResult
}
};
Y.io(url, cfg);
},
queryBaseInfoResult: function (ioId, o) {
var data = Y.until.parseJson(o.responseText),
retcode = +data.retcode,
retmsg = data.retmsg;
if (0 == retcode) {
// 成功
var token_key = data['token_key'], // 收款单号
limit = data['uplimit'] || "2000.00";
Y.one('#token_key').set('value', token_key);
Y.one('#limit').set('value', limit);
Y.one('#limit_txt').setContent(limit);
this.validInit();
} else {
Y.until.showError(retmsg, retcode);
}
},
deleteContactResult: function (ioId, o) {
var data = Y.until.parseJson(o.responseText),
retcode = +data.retcode,
retmsg = data.retmsg,
str = '';
if (0 == retcode) {
var cfg = {
'ico': 'ok',
'msgTitle': '联系人删除成功'
};
top.TBox.showMsgBox(cfg);
Y.one('#d_' + this.uin).get('parentNode').remove();
var nodes = Y.all('#contact_man li');
if (nodes.size() < 1) {
Y.one('#contact .linkman-history .tips-info').removeClass('hide');
Y.one('#contact_man').addClass('hide');
}
} else {
Y.until.showError(retmsg, retcode);
}
},
deleteContact: function () {
var url = '/app/v1.0/qry_pay_friend.cgi',
cfg = {
method: 'post',
data: 'actionid=2&friend_uin=' + this.uin,
context: this,
on: {
success: this.deleteContactResult
}
};
Y.io(url, cfg);
},
deleteConfirm: function () {
var cfg = {
'ico': 'info',
'msgTitle': '确认删除此联系人吗?',
'btns': [['确 认', this.deleteContact, this], ['取 消', function () {top.TBox.hideMsgBox();}]]
};
if (top.TBox) {
top.TBox.showMsgBox(cfg);
} else {
YUI({'combine': true}).use('tbox', function () {
top.TBox.showMsgBox(cfg);
});
}
},
filterContact: function (s) {
var o = this.CACHE_QQ_FRIEND,
TMP_HTML = '<li><a id="q_{qq}" href="#"><strong>{nick}</strong><em>{uin}</em></a></li>';
s = s.replace(/\s/g, '');
if (o) {
if ('' == s || !/\d+/.test(s)) {
Y.one('#filter_contact').addClass('hide');
return false;
}
var list = o['friendlist'] || [],
re = new RegExp('^(.*?)(' + s + ')(.*)$', ''),
MAX = 5,
result = [];
for (var i = 0, len = list.length; i < len; i++) {
var name = Y.until.htmlEncode(list[i]['nick']),
uin = list[i]['uin'];
if (re.test(uin)) {
if (!RegExp.$1) {
result.unshift(Y.substitute(TMP_HTML, {'nick': name, 'qq': uin, 'uin': uin.replace(re, '<span class="bold">$2</span>$3')}));
} else {
result.push(Y.substitute(TMP_HTML, {'nick': name, 'qq': uin, 'uin': uin.replace(re, '$1<span class="bold">$2</span>$3')}));
}
}
}
result = result.slice(0, MAX);
if (result.length > 0) {
Y.one('#filter_contact').setContent(result.join('')).removeClass('hide');
Y.all('#filter_contact a').on('click', function (e) {
e.preventDefault();
var node = e.currentTarget;
this.autoFill(node.get('id').replace(/^q_/, ''));
this.valid.output('accept_uin');
}, this);
} else {
Y.one('#filter_contact').addClass('hide');
}
} else {
if (this.ISQQ) {
this.queryQQFriend();
}
}
},
// 查询基本信息,包括单笔限额,收款单号等
queryBaseInfo: function () {
var url = '/app/v1.0/show_ask_money.cgi',
cfg = {
method: 'post',
data: '',
context: this,
on: {
success: this.queryBaseInfoResult
}
};
Y.io(url, cfg);
},
bindContactPanelTab: function () {
var nodes = Y.all('#contact .linkman-option a');
nodes.on('click', function (e) {
e.preventDefault();
nodes.removeClass('on');
var str = e.currentTarget.addClass('on').get('innerHTML'),
re = /好友$/,
node = Y.one('#contact'),
node_his = node.one('.linkman-history'),
node_qq = node.one('.linkman-qq');
if (!re.test(str)) {
this.buildHistoryPayee();
node_his.removeClass('hide');
node_qq.addClass('hide');
} else {
this.buildQQFriend();
node_qq.removeClass('hide');
node_his.addClass('hide');
}
e.stopPropagation();
}, this);
},
switchFriendQQ: function () {
this.buildQQFriend();
var nodes = Y.all('#contact .linkman-option a'),
node = Y.one('#contact');
nodes.removeClass('on');
nodes.item(1).addClass('on');
node_his = node.one('.linkman-history'),
node_qq = node.one('.linkman-qq');
node_qq.removeClass('hide');
node_his.addClass('hide');
},
buildQQFriend: function () {
var obj = this.CACHE_QQ_FRIEND;
if (!obj) {
this.queryQQFriend();
return false;
}
var friendlist = obj["friendlist"] || [],
grouplist = obj["grouplist"] || [],
friend_map = {},
len = friendlist.length,
str = '',
group_str = '';
Y.each(friendlist, function (v, k) {
var groupno = v['qq_groupno'];
if (!friend_map[groupno]) {
friend_map[groupno] = {
'count': 0,
'content': ''
};
}
friend_map[groupno]['count']++;
/*xss过滤 slarkzhang*/
var remark = Y.until.htmlEncode(v['remark']);
var nick = Y.until.htmlEncode(v['nick']);
friend_map[groupno]['content'] += '<li><a id="qq_' + v['uin'] + '" href="#"><span class="ico-people"><!-- 头像 --></span><span class="nick-name">' + (remark || nick) + '</span></a></li>';
}, this);
Y.each(grouplist, function (v, k) {
var cnt = 0;
str = '';
if (k in friend_map) {
str = '<ul>' + friend_map[k]['content'] + '</ul>';
cnt = friend_map[k]['count'];
}
str = '<h3><span id="g_' + k + '" class="ico-shrink"><!-- 收缩图标 --></span><span>' + v + '(' + cnt + ')</span></h3>' + str;
group_str += '<li>' + str + '</li>';
}, this);
Y.one('#qq_friend').setContent(group_str);
Y.all('#qq_friend h3').on('click', function (e) {
e.currentTarget.get('parentNode').toggleClass('on');
e.stopPropagation();
}, this);
Y.all('#qq_friend a').on('click', function (e) {
e.preventDefault();
var node = e.currentTarget;
this.autoFill(node.get('id').replace(/^qq_/, ''));
}, this);
},
// 生成常用联系人列表
buildHistoryPayee: function () {
var list = this.CACHE_HISTORY_PAYEE,
TMP_HTML = '<li><a class="btn-close" id="d_{friend_uin}" href="#" title="删除">删除</a><strong>{friend_nick}</strong><em>{friend_uin}</em></li>',
str = '';
if (!list) {
this.queryHistoryInfo();
return false;
}
if (this.isShowHistory) { // 面板生成后,直接显示
return false;
}
Y.each(list, function (v, k) {
v['friend_nick'] = (v['friend_nick'] == '' || (v['friend_nick'] == '未知')) ? '财付通用户' : v['friend_nick'];
str += Y.substitute(TMP_HTML, v);
}, this);
Y.one('#contact .linkman-history').removeClass('loading');
if ("" != str) { // 有记录
Y.one('#contact_man').setContent(str);
var nodes = Y.one('#contact_man').all('li');
if (Y.UA.ie && Y.UA.ie < 7) {
nodes.on('mouseover', function (e) {
e.currentTarget.addClass('hover');
});
nodes.on('mouseout', function (e) {
e.currentTarget.removeClass('hover');
});
}
nodes.on('click', function (e) {
var node = e.currentTarget;
this.valid.output('accept_uin');
this.autoFill(node.one('em').get('innerHTML'), node.one('strong').get('innerHTML'));
}, this);
nodes = Y.all('#contact_man a');
nodes.on('click', function (e) {
e.preventDefault();
this.uin = e.currentTarget.get('id').replace(/^d_/, '');
this.deleteConfirm();
e.stopPropagation();
}, this);
} else {
// 记录为空的时候处理
Y.one('#contact .linkman-history .tips-info').removeClass('hide');
Y.one('#contact_man').addClass('hide');
}
this.isShowHistory = true;
},
autoFill: function (u, n) {
Y.one('#accept_uin').set('value', u).removeClass('gray');
},
chkMobileNum: function () {
var node = Y.one('#mobile');
if (node.get('parentNode').get('parentNode').hasClass('click')) {
var v = node.get('value');
if ("" == v) {
return "null";
}
return (this.valid.validator.isMobile(v)) ? true : "error";
} else {
return true;
}
},
validData: function () {
var valid = this.valid;
valid.valid();
if (valid.RESULT) {
// 提交
this.queryAcceptInfo();
Y.until.request.start('#receive_next_btn_wrap');
}
return false;
},
validInit: function () {
this.valid = new Y.DataValid();
var valid = this.valid,
limit = Y.one('#limit').get('value') || "2000.00",
MSG = {
accept_uin: {
"null": "[09020001]请输入付款方财付通账户",
"error": "[09020002]付款人账户输入错误,请重新输入",
"noallow": "[09020003]收款方和付款方账户名相同,不能收款"
},
fee: {
"null": "[09020004]请输入收款金额",
"error": "[09020005]收款金额必须为整数或小数,小数点后不超过2位",
"above": "[09020006]单笔金额不能超过" + limit + "元",
"below": "[09020007]收款金额必须为整数或小数,小数点后不超过2位"
},
mobile: {
"null": "[09020008]请输入付款人手机号",
"error": "[09020009]付款人手机号错误,请重新输入"
},
receive_memo: {
"long": "[09020010]收款理由超过140字,请重新输入"
}
};
valid.config({
isNull: false,
changeBind: true,
report: {
'trans': 'pay',
'name': '/account/receive/index.js',
'url': '/v2/res/js/errorinfo/account/receive/index.js'
},
rules: [
{id: 'accept_uin', type: 'account', black_list: [G_userInfo['uin'], G_userInfo['uin'] + '@qq.com'], msg: MSG['accept_uin'], defaultValue: DEFAULT_CONF['accept_uin']},
{id: 'fee', type: 'amount', feature: "limit:(0, " + limit + "]", msg: MSG['fee'], defaultValue: DEFAULT_CONF['fee']},
{id: 'receive_memo', isNull: true, feature: "length:[0,140]", msg: MSG['receive_memo']},
{id: 'mobile', isNull: true, handle: this.chkMobileNum, context: this, msg: MSG['mobile']}
]
});
},
defaultValue: function () {
function focusEvent(e) {
var target = e.currentTarget,
key = target.get('id');
if (target.get('value') == DEFAULT_CONF[key]) {
target.set('value', '');
target.removeClass('gray');
}
}
function blurEvent(e) {
var target = e.currentTarget,
key = target.get('id');
if (target.get('value') == '') {
target.set('value', DEFAULT_CONF[key]);
target.addClass('gray');
}
}
Y.each(DEFAULT_CONF, function (v, k) {
var n = Y.one('#' + k);
n.on('focus', focusEvent);
n.on('blur', blurEvent);
});
},
initializer: function () {
this.queryBaseInfo();
var _valid = new Y.DataValid();
this.ISQQ = (G_userInfo['uin'] && _valid.validator.isQQ(G_userInfo['uin']));
this.defaultValue();
Y.one('form[name="receive-form"]').on('submit', function (e) {
e.preventDefault();
});
/*Y.one('#receive_next_btn').on('click', function (e) {
this.validData();
}, this);*/
Y.one('#accept_uin').on('keyup', function (e) {
this.filterContact(e.currentTarget.get('value'));
}, this);
Y.one('#contact_link').on('click', function (e) {
e.preventDefault();
var region = e.currentTarget.get('region');
node = Y.one('#contact');
e.currentTarget.addClass('on');
if (!this.ISQQ) {
Y.one('#contact a.js-qqfirend').addClass('hide');
}
node.removeClass('hide');
node.setXY([region.left - 150, region.top + 26]);
if (!this.CACHE_HISTORY_PAYEE) {
this.bindContactPanelTab();
}
this.buildHistoryPayee();
e.stopPropagation();
}, this);
Y.one('#msg_notify').on('click', function (e) {
var node = e.currentTarget,
pNode = node.get('parentNode').get('parentNode');
pNode.toggleClass('click');
e.stopPropagation();
node.set('checked', pNode.hasClass('click'));
if (pNode.hasClass('click')) {Y.one('#mobile').focus();}
this.valid.output('mobile');
}, this);
Y.one('body').on('click', function (e) {
Y.one('#contact').addClass('hide');
Y.one('#contact_link').removeClass('on');
Y.one('#filter_contact').addClass('hide');
});

/*显示默认值 modify chauvetxiao*/
var url = Y.until.url;
var obj = {
pay_uin: url.getPara('pay_uin'),
amount: url.getPara('amount'),
remark: decodeURIComponent(url.getPara('remark'))
};
if( _valid.validator.isQQ(obj.pay_uin)){
var uin = Y.one("#accept_uin");
if(uin){
uin.removeClass('gray');
uin.set('value',obj.pay_uin);
}
}

var amount = +obj.amount;
if(!isNaN(amount)){
amount = amount>2000?2000:amount;
var fee = Y.one("#fee");
if(fee && amount>0){
fee.set('value',amount);
fee.removeClass('gray');
}
}

var remark = Y.one('#receive_memo');
if(remark && (obj.remark!='null') && obj.remark!=""){
remark.removeClass('gray');
remark.set('value',obj.remark);
}

//判断金额是否校验通过
/* 先不显示短信通知收款人
Y.one("#fee").on("keyup", function(e){
var showFlag = false;
var fee = Y.one("#fee").get("value");
if("" != fee){
fee = this.valid.util.formatAmount(fee);
if(fee && 0 != fee){
fee = parseFloat(fee, 10);
if(fee >= 1){
showFlag = true;
}
}
}
if(this.timer != null){
clearTimeout(this.timer);
}
this.timer = setTimeout(function(){
var node = Y.one("#msg_notify"),
pNode = node.get('parentNode').get('parentNode');
if(showFlag){
node.set("disabled", false);
}else{
pNode.removeClass("click");
node.set("checked", false);
node.set("disabled", true);
}
}, 300);
}, this);
*/
this.validInit();
}
};
Receive.initializer();
});

skin33的主页 skin33 | 初学一级 | 园豆:110
提问于:2016-04-20 14:29
< >
分享
所有回答(2)
0

这么长的代码啊,看完也不容易

飞翔の金雕 | 园豆:364 (菜鸟二级) | 2016-04-21 18:00

其实看页面很简单 就是TX 把一个按钮禁止了  我想调用

支持(0) 反对(0) skin33 | 园豆:110 (初学一级) | 2016-04-22 10:09
0

好吧 我自己结贴 还是没写好

skin33 | 园豆:110 (初学一级) | 2016-04-28 17:34
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册