Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
王水玲
9 years ago
Commit
9bb673231d00a840db925ec28ead2bee94e377b2
1 parent
c2c270ba
有货分期
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
141 deletions
public/js/home/repayment-list.page.js
public/js/home/repayment.js
public/js/home/repayment-list.page.js
View file @
9bb6732
...
...
@@ -5,162 +5,65 @@
*/
var
$
=
require
(
'yoho-jquery'
),
Repayment
=
require
(
'./repayment'
),
tip
=
require
(
'../plugin/tip'
);
var
$currAmt
=
$
(
'.repayment-bottom'
).
find
(
'.curr-amt'
),
$currFee
=
$
(
'.repayment-bottom'
).
find
(
'.curr-fee'
),
$servePrice
=
$
(
'.serve-price'
);
var
CHECKBOX_SELECTOR
=
'.repay-list input'
;
var
repayment
=
new
Repayment
({
onGetSelection
:
function
()
{
var
ret
=
[];
require
(
'./overdue-notice'
);
// 选择分期统计
function
totalChecked
(
index
)
{
var
total
=
0
;
// 按时间顺序选择还款,不可以跨期
$
(
'.repay-list input'
).
each
(
function
(
key
,
item
)
{
if
(
key
<
index
&&
$
(
item
).
is
(
':checked'
))
{
total
++
;
}
});
return
total
;
}
// 取消分期统计
function
totalCancelChecked
(
index
)
{
var
total
=
0
;
$
(
'.repay-list input'
).
each
(
function
(
key
,
item
)
{
if
(
key
>
index
&&
$
(
item
).
is
(
':checked'
))
{
total
++
;
}
});
return
total
;
}
$
(
'.repay-list label'
).
on
(
'click'
,
function
()
{
var
li
=
$
(
this
).
parents
(
'li'
),
index
=
li
.
index
(),
$input
=
$
(
this
).
prev
(),
currAmt
=
+
$currAmt
.
html
(),
currFee
=
+
$currFee
.
html
(),
amt
=
+
li
.
attr
(
'data-curramt'
),
fee
=
+
li
.
attr
(
'data-currfee'
),
count
=
0
,
total
=
0
;
$
(
`
$
{
CHECKBOX_SELECTOR
}
:
checked
`
).
each
(
function
(
key
,
item
)
{
var
li
=
$
(
item
).
parents
(
'li'
);
if
(
$input
.
is
(
':checked'
))
{
total
=
totalCancelChecked
(
index
);
var
data
=
{
index
:
li
.
index
(),
orderCode
:
li
.
attr
(
'data-billno'
),
termNo
:
li
.
attr
(
'data-termNo'
),
amount
:
parseFloat
(
li
.
attr
(
'data-currNoFeeAmt'
)),
fee
:
parseFloat
(
li
.
attr
(
'data-currfee'
))
+
0
};
if
(
total
===
0
)
{
$currAmt
.
html
((
currAmt
-
amt
).
toFixed
(
2
));
$currFee
.
html
((
currFee
-
fee
).
toFixed
(
2
));
}
else
{
tip
.
show
(
'请按时间顺序取消选择,不可以跨期'
);
return
false
;
}
}
else
{
total
=
totalChecked
(
index
);
if
(
total
===
index
)
{
$currAmt
.
html
((
amt
+
currAmt
).
toFixed
(
2
));
$currFee
.
html
((
fee
+
currFee
).
toFixed
(
2
));
}
else
{
tip
.
show
(
'请按时间顺序添加还款,不可以跨期'
);
return
false
;
}
}
ret
.
push
(
data
);
});
if
(
parseFloat
(
$currFee
.
html
())
>
0
)
{
$servePrice
.
show
();
}
else
{
$servePrice
.
hide
();
return
ret
;
},
onDeselectAll
:
function
()
{
$
(
`
$
{
CHECKBOX_SELECTOR
}
:
checked
`
).
prop
(
'checked'
,
false
);
return
[];
},
onSelectAll
:
function
()
{
$
(
`
$
{
CHECKBOX_SELECTOR
}
:
not
(
:
checked
)
`
).
prop
(
'checked'
,
true
);
return
this
.
getSelection
();
}
setTimeout
(
function
()
{
count
=
$
(
'.repay-list input:checked'
).
length
;
$
(
'#repayment-total'
).
prop
(
'checked'
,
count
===
$
(
'.repay-list li'
).
length
);
},
0
);
});
// 全选||全不选
$
(
'.repayment-bottom label'
).
on
(
'click'
,
function
()
{
var
totalAmt
=
0
;
var
totalFee
=
0
;
if
(
$
(
this
).
prev
().
is
(
':checked'
))
{
$
(
'.repay-list input'
).
prop
(
'checked'
,
false
);
$currAmt
.
html
(
'0.00'
);
$currFee
.
html
(
'0.00'
);
$servePrice
.
hide
();
}
else
{
$
(
'.repay-list input'
).
prop
(
'checked'
,
true
);
$
(
'.repay-list li'
).
each
(
function
()
{
totalAmt
+=
(
+
$
(
this
).
attr
(
'data-curramt'
));
totalFee
+=
(
+
$
(
this
).
attr
(
'data-currfee'
));
});
require
(
'./overdue-notice'
);
$currAmt
.
html
(
totalAmt
.
toFixed
(
2
));
$currFee
.
html
(
totalFee
.
toFixed
(
2
));
$
(
CHECKBOX_SELECTOR
+
':checkbox'
).
click
(
function
()
{
var
selection
=
repayment
.
getSelection
();
var
isSkipped
=
false
;
var
lastIndex
=
0
;
var
self
=
this
;
if
(
parseFloat
(
$currFee
.
html
())
>
0
)
{
$servePrice
.
show
();
selection
.
forEach
(
function
(
sel
)
{
if
((
sel
.
index
+
1
)
-
lastIndex
>
1
)
{
isSkipped
=
true
;
}
else
{
$servePrice
.
hide
();
}
}
});
$
(
'.repayment-btn'
).
on
(
'click'
,
function
()
{
var
path
=
location
.
pathname
;
var
list
=
[];
$
(
'.repay-list li'
).
each
(
function
(
key
,
item
)
{
if
(
$
(
item
).
find
(
'input'
).
is
(
':checked'
))
{
list
.
push
({
index
:
key
,
// 分期列表序号
orderCode
:
$
(
item
).
attr
(
'data-billno'
),
// 订单号
termNo
:
$
(
item
).
attr
(
'data-termNo'
)
// 第几期还款
});
lastIndex
=
sel
.
index
+
1
;
}
});
$
(
this
).
attr
(
'href'
,
path
+
'?openby:yohobuy={"action":"go.instalmentRepayment","params":{"list":'
+
encodeURIComponent
(
JSON
.
stringify
(
list
))
+
',"amount":'
+
(
+
$currAmt
.
html
())
+
'}}'
);
});
// const repayment = new Repayment({
// onGetSelection: function() {
// const ret = [];
// $(`${CHECKBOX_SELECTOR}:checked`).each(function(key, item) {
// const li = $(item).parents('li');
// const data = {
// index: key,
// orderCode: li.attr('data-billno'),
// termNo: li.attr('data-termNo'),
// amount: parseFloat(li.attr('data-currNoFeeAmt')),
// fee: parseFloat(li.attr('data-currfee')) + 0
// };
// ret.push(data);
// });
if
(
isSkipped
)
{
setTimeout
(
function
()
{
tip
.
show
(
$
(
self
).
is
(
':checked'
)
?
'请按时间顺序取消选择,不可以跨期'
:
'请按时间顺序添加还款,不可以跨期'
);
},
0
);
return
false
;
}
// return ret;
// },
// onDeselectAll: function() {
// $(`${CHECKBOX_SELECTOR}:checked`).prop('checked', false);
// return [];
// },
// onSelectAll: function() {
// $(`${CHECKBOX_SELECTOR}:not(:checked)`).prop('checked', true);
// return this.getSelection();
// }
// });
repayment
.
update
();
});
// 跳转到还款详情
window
.
jumpDetail
=
function
(
id
)
{
...
...
public/js/home/repayment.js
View file @
9bb6732
...
...
@@ -28,7 +28,7 @@ var Repayment = function(options) {
var
params
=
{
action
:
'go.instalmentRepayment'
,
list
:
self
.
getSelection
(),
list
:
self
.
setParams
(),
amount
:
self
.
total
};
...
...
@@ -92,6 +92,23 @@ Repayment.prototype.setFee = function(fee) {
this
.
currFee
.
text
(
this
.
_formatCurrency
(
this
.
fee
));
};
// 获取立即付款的传参
Repayment
.
prototype
.
setParams
=
function
()
{
var
values
=
this
.
getSelection
();
var
formatValues
=
[];
if
(
values
&&
values
.
length
)
{
values
.
forEach
(
function
(
value
)
{
formatValues
.
push
({
index
:
value
.
index
,
orderCode
:
value
.
orderCode
,
termNo
:
value
.
termNo
});
});
}
return
formatValues
;
};
Repayment
.
prototype
.
getSelection
=
function
()
{
return
this
.
settings
.
onGetSelection
();
...
...
@@ -99,6 +116,7 @@ Repayment.prototype.getSelection = function() {
Repayment
.
prototype
.
update
=
function
()
{
var
values
=
this
.
getSelection
();
var
$repaymentBottom
=
$
(
'.repayment-bottom'
);
var
self
=
this
;
this
.
total
=
0
;
...
...
@@ -112,6 +130,12 @@ Repayment.prototype.update = function() {
});
}
if
(
values
.
length
===
0
)
{
$repaymentBottom
.
slideUp
();
}
else
{
$repaymentBottom
.
slideDown
();
}
this
.
setTotal
(
this
.
total
);
this
.
setFee
(
this
.
fee
);
...
...
Please
register
or
login
to post a comment