card-detail.page.js
3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* 银行卡详情
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/10/25
*/
let $ = require('yoho-jquery');
let tip = require('plugin/tip');
let dialog = require('plugin/dialog');
let yohoApp = require('yoho-app');
let cardDetail = {
init: function() {
let self = this,
$relieveBtn = $('.relieve-btn'),
$changeBtn = $('.change-btn'),
asyncMode = yohoApp.isiOS;
self.asyncMode = asyncMode;
self.cardIdNo = $('.card-detail').data('cardId');
$('body').attr('ontouchstart', true);
$relieveBtn.on('click', function() {
self.dialogAction({
text: '你确定要解除绑定此卡吗?解除绑定后该银行卡将不出现在还款银行卡列表中。',
url: '/home/installment/delBankCard',
errorText: '解除失败',
successAction: function() {
tip.show('解除成功!');
setTimeout(function() {
if (asyncMode) {
yohoApp.invokeMethod('go.relieveCardSuccess');
} else {
window.location.href = location.href + '&openby:yohobuy={"action":"go.relieveCardSuccess"}';
}
}, 1000);
}
});
});
$changeBtn.on('click', function() {
self.dialogAction({
text: '你确定要设置该银行卡为主卡吗?确定设置后原主卡将自动修改为副卡。',
url: '/home/installment/setMasterCard',
errorText: '切换失败',
successAction: function() {
tip.show('切换成功!');
setTimeout(function() {
if (asyncMode) {
yohoApp.invokeMethod('go.instalmentMyCardList');
} else {
window.location.href = location.href +
'&openby:yohobuy={"action":"go.instalmentMyCardList"}';
}
}, 1000);
}
});
});
},
dialogAction: function(params) {
let self = this;
dialog.showDialog({
dialogText: params.text,
hasFooter: {
leftBtnText: '取消',
rightBtnText: '确定'
}
}, function() {
$.ajax({
type: 'GET',
url: params.url,
data: {
cardIdNo: self.cardIdNo
},
success: function(data) {
dialog.hideDialog();
if (data.code === 200) {
params.successAction();
} else {
tip.show(params.errorText);
}
self.flag = false;
},
error: function() {
tip.show(params.errorText);
self.flag = false;
}
});
});
}
};
require('common');
$(function() {
cardDetail.init();
});