exchange-detail.page.js
2.23 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
var $ = require('yoho-jquery'),
Confirm = require('../plugins/dialog').Confirm,
lazyLoad = require('yoho-jquery-lazyload');
var id = $('.exchange-detail-page').data('id');
var $mainWrap = $('.exchange-detail-page'),
$submitExpress = $mainWrap.find('.submit-express'),
$showExpress = $mainWrap.find('.show-content'),
$editExpress = $mainWrap.find('.edit-content');
var $expressCompany = $('.express-company'),
$expressCode = $('.express-code');
var expressList = $editExpress.data(),
remark = $('.reason-info').find('span').text().length;
lazyLoad($('.banner-img'));
function cancelExchangeApply() {
$.ajax({
type: 'POST',
url: '/me/return/cancel',
data: {
id: id,
type: 'exchange'
},
success: function(data) {
if (data.code === 200) {
location.reload();
$('.exchange-detail').html('<p class="state">您已取消成功</p>');
}
}
});
}
$('.cancel-btn').click(function() {
new Confirm({
content: '<h1>取消申请</h1><p>您确定要取消申请么?</p>',
cb: cancelExchangeApply
}).show();
});
function setExchangeEepress(eid, num) {
$.ajax({
type: 'POST',
url: '/me/return/setEepress',
data: {
id: id,
type: 'exchange',
companyId: eid,
companyName: expressList[eid],
number: num
},
success: function(data) {
// console.log(data);
if (data.code === 200) {
location.reload();
}
}
});
}
$submitExpress.click(function() {
var companyId = $expressCompany.val(),
code = parseInt($expressCode.val(), 10);
if (!companyId || !code) {
$submitExpress.siblings('.error-tip').removeClass('hide');
return;
}
setExchangeEepress(companyId, code);
});
$showExpress.on('click', '.reset-express', function() {
var expressId = $showExpress.data('id');
$expressCompany.val(expressId);
$showExpress.addClass('hide');
$editExpress.removeClass('hide');
});
// console.log($('.reason-info').find('span').text().length);
if (remark <= 5) {
$('.reason-info').hide();
}