operations.payment.Index.js
4.85 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
webpackJsonp([120],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
var $ = __webpack_require__(1),
common = __webpack_require__(2);
var ENUM = {
recommendOrderPage: ["否","是"],
displayFirstSight: ["否","是"]
};
var sortNumberList = []; //前端展示排序数组,用于校验前端排序是否重复
var g = new common.grid({
el: '#payment-list',
columns: [
{display: '支付名称', render:function(item){
return item.payName;
//if(item.id=='4'){
// return "Apple Pay(北京银联)";
//}else if(item.id=='5'){
// return "银联支付(北京银联)";
//}else if(item.id=='24'){
// return "Apple Pay(江苏银联)";
//}else if(item.id=='26'){
// return "银联支付(江苏银联)";
//}else{
// return item.payName;
//}
}},
{display: "前端显示排序", name: "sortNumber"},
{display: "推荐语", name: "recommendText1"},
{display:"未开通文案",name:"noOpenText"},
//{display: "推荐语2", name: "recommendText2"},
{display: '操作', render: function (item) {
var HtmArr = [];
HtmArr.push('<a href="javascript:" class="btn btn-info btn-xs edit-btn" data-index="'+item.__index+'">编辑</a>');
if(item.status == 1){
HtmArr.push('<a href="javascript:" class="btn btn-danger btn-xs close-btn" data-index="'+item.__index+'">关闭</a>');
}else{
HtmArr.push('<a href="javascript:" class="btn btn-success btn-xs open-btn" data-index="'+item.__index+'">开启</a>');
}
return HtmArr.join('');
}}
],
complete: function () {
$.each(g.rows, function (index, item) {
sortNumberList.push(item.sortNumber+'');
});
}
});
g.init("/Payment/findPayManageList");
//编辑
$(document).on("click", ".edit-btn", function () {
var _index = $(this).data("index");
var data = g.rows[_index];
var d = new common.dialog({
title: "支付方式编辑",
width: "50%",
content: common.util.__template2($("#template").html(), data),
button: [
{value: "确认", css:"btn-primary", callback: function () {
var dataArray = $('#paymentEdit').serializeArray();
var newData = {};
$.each(dataArray, function (index, item) {
newData[item.name] = item.value;
});
if(checkPaymentData(newData, data)){
savePaymentData(newData);
}else{
return false;
}
}},
{value: "取消", css:"btn-default"}
]
});
new common.edit("#paymentEdit").init();
});
//保存支付方式数据
function savePaymentData(data) {
common.util.__ajax({
url: '/Payment/updatePayInfoById',
data: data
}, function () {
g.reload();
})
}
//校验支付方式数据
function checkPaymentData(data, oldData) {
//前端排序不能重复
if(data.sortNumber != oldData.sortNumber){
if(sortNumberList.indexOf(data.sortNumber) > -1){
common.util.__tip("前端排序已存在,不能重复填写!");
return false;
}
}
//推荐到订单页为'是',推荐文案不能为空!
if(data.recommendOrderPage == 1){
if($.trim(data.recommendWords) == ""){
common.util.__tip("推荐到订单页为'是',推荐文案不能为空!");
return false;
}
}
//提示语2不为空时,需要校验提示语1不能为空
if($.trim(data.recommendText2) != ""){
if($.trim(data.recommendText1) == ""){
common.util.__tip("提示语2填写,则提示语1也必须填写!");
return false;
}
}
return true;
}
//开启
$(document).on("click", ".open-btn", function () {
var _index = $(this).data("index");
var data = g.rows[_index];
common.dialog.confirm("温馨提示", "确认开启当前支付方式么?", function(){
common.util.__ajax({
url: '/Payment/openPayModeById',
data: {id: data.id}
}, function () {
g.reload();
})
});
});
//关闭
$(document).on("click", ".close-btn", function () {
var _index = $(this).data("index");
var data = g.rows[_index];
common.dialog.confirm("温馨提示", "确认关闭当前支付方式么?", function(){
common.util.__ajax({
url: '/Payment/closePayModeById',
data: {id: data.id}
}, function () {
g.reload();
})
});
});
/***/ }
]);