returns-apply.js
2.1 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
/**
* 退换货申请
* @author: yyqing<yanqing.yang@yoho.cn>
* @date: 2016/2/29
*/
var $ = require('yoho.jquery'),
Addr = require('./common-address');
var $goosTable = $('#goods-table'),
$reasons = $goosTable.find('.return-reason'),
$file = $goosTable.find('input[type=file]');
var $exchange = $('.exchange-detail'),
defaultArea = $exchange.find('input[name="hide-area"]').val();
require('../../plugin/jquery.upload');
defaultArea = defaultArea ? defaultArea : '';
Addr.loadAllData(defaultArea, {
areaDomId: 'area'
});
$reasons.change(function() {
var $par = $(this).parent().parent(),
type = $(this).val() * 1;
if (type === 4 || type === 6 || type === 8) {
$par.next().show();
} else {
$par.next().hide();
}
});
$goosTable.find('.up-image-list li').on('click', '.btn-del', function() {
$(this).parent().empty();
});
$file.each(function(e) {
$('#upload-img-' + e).upload({
auto: true,
buttonClass: 'upload-img-btn',
fileType: 'image/*',
uploadScript: '/home/suggestimgUpload',
fileObjName: 'fileData',
fileSizeLimit: 5000,
buttonText: '上传图片',
height: 34,
width: 116,
multi: false,
onUploadComplete: function(file, data) {
var $par = $(this).closest('.problem-description'),
$imgList = $par.find('li'),
isShow = false,
img, _html;
img = JSON.parse(data).imgList[0];
_html = '<span class="btn-del" title="删除"></span>' +
'<img src="' + img.imgUrl + '" width="126" height="126">';
$imgList.each(function() {
if (!isShow && !$(this).find('img').length) {
isShow = true;
$(this).html(_html);
}
});
},
onError: function(info, fileType, data) {
var msg = '图片上传失败!';
if (info === 'FILE_SIZE_LIMIT_EXCEEDED') {
msg = '图片大小超出限制!';
}
alert(msg);
}
});
});