Showing
5 changed files
with
98 additions
and
10 deletions
@@ -332,8 +332,6 @@ const getRefundGoodsData = (orderCode, uid) => { | @@ -332,8 +332,6 @@ const getRefundGoodsData = (orderCode, uid) => { | ||
332 | refund: _setDefaultStatus('退货') || {} | 332 | refund: _setDefaultStatus('退货') || {} |
333 | }; | 333 | }; |
334 | 334 | ||
335 | - console.log(resData); | ||
336 | - | ||
337 | if (result.data) { | 335 | if (result.data) { |
338 | Object.assign(resData.returns.refund, _setRefundGoodList(result.data), { | 336 | Object.assign(resData.returns.refund, _setRefundGoodList(result.data), { |
339 | orderCode: orderCode | 337 | orderCode: orderCode |
@@ -12,13 +12,6 @@ | @@ -12,13 +12,6 @@ | ||
12 | <span class="red">*</span>上传凭证: | 12 | <span class="red">*</span>上传凭证: |
13 | </div> | 13 | </div> |
14 | <div class="left right-content"> | 14 | <div class="left right-content"> |
15 | - <div class="img-wrap"> | ||
16 | - <div class="img-opt"> | ||
17 | - <span>查看</span> | ||
18 | - <span>删除</span> | ||
19 | - </div> | ||
20 | - <div class="img-view"></div> | ||
21 | - </div> | ||
22 | <div class="img-upload"> | 15 | <div class="img-upload"> |
23 | <span class="iconfont"></span> | 16 | <span class="iconfont"></span> |
24 | </div> | 17 | </div> |
@@ -4,7 +4,9 @@ | @@ -4,7 +4,9 @@ | ||
4 | * @date: 2016/7/15 | 4 | * @date: 2016/7/15 |
5 | */ | 5 | */ |
6 | var $ = require('yoho-jquery'), | 6 | var $ = require('yoho-jquery'), |
7 | - lazyload = require('yoho-jquery-lazyload'); | 7 | + lazyload = require('yoho-jquery-lazyload'), |
8 | + handlebars = require('yoho-handlebars'), | ||
9 | + upload = require('../plugins/upload'); | ||
8 | 10 | ||
9 | var $refundTable = $('.refund-goods'), | 11 | var $refundTable = $('.refund-goods'), |
10 | $check = $('.check'), | 12 | $check = $('.check'), |
@@ -20,6 +22,15 @@ var orderCode = $('#order-code').val() || 0, | @@ -20,6 +22,15 @@ var orderCode = $('#order-code').val() || 0, | ||
20 | dom: $typeInfo.eq(0) | 22 | dom: $typeInfo.eq(0) |
21 | }; | 23 | }; |
22 | 24 | ||
25 | +var tpl = '<div class="img-wrap">' + | ||
26 | + '<div class="img-opt">' + | ||
27 | + '<span>查看</span>' + | ||
28 | + '<span>删除</span>' + | ||
29 | + '</div>' + | ||
30 | + '<div class="img-view"><img src="{{data}}"></div>' + | ||
31 | + '</div>', | ||
32 | + imgFn = handlebars.compile(tpl); | ||
33 | + | ||
23 | var checked; | 34 | var checked; |
24 | 35 | ||
25 | require('../plugins/check'); | 36 | require('../plugins/check'); |
@@ -128,8 +139,20 @@ $refundTable.on('change', '.refund-reason', function() { | @@ -128,8 +139,20 @@ $refundTable.on('change', '.refund-reason', function() { | ||
128 | $specialDom.slideUp(); | 139 | $specialDom.slideUp(); |
129 | } | 140 | } |
130 | $specialDom.siblings('.check').data({reason: val}); | 141 | $specialDom.siblings('.check').data({reason: val}); |
142 | +}).on('click', '.img-upload', function() { | ||
143 | + var $this = $(this); | ||
144 | + | ||
145 | + upload.up({ | ||
146 | + callback: function(result) { | ||
147 | + if (result && result.code === 200) { | ||
148 | + $this.before(imgFn(result)); | ||
149 | + } | ||
150 | + } | ||
151 | + }); | ||
131 | }); | 152 | }); |
132 | 153 | ||
154 | + | ||
155 | + | ||
133 | $refundType.on('click', '.type-item', function() { | 156 | $refundType.on('click', '.type-item', function() { |
134 | var $this = $(this), | 157 | var $this = $(this), |
135 | index; | 158 | index; |
public/js/plugins/upload.js
0 → 100644
1 | +var $ = require('yoho-jquery'), | ||
2 | + handlebars = require('yoho-handlebars'); | ||
3 | + | ||
4 | +var tpl = '<div style="width: 0px; height: 0px; overflow: hidden;">' + | ||
5 | + '<iframe id="yoho-upload-result" name="ajaxUpload" style="display:none"></iframe>' + | ||
6 | + '<form id="yoho-upload" method="post" enctype="multipart/form-data" ' + | ||
7 | + 'action="/api/uploadImg" target="ajaxUpload">' + | ||
8 | + '<input type="file" name="filename" class="file-name" />' + | ||
9 | + '<input type="hidden" name="bucket" value="goodsimg" />' + | ||
10 | + '</form>' + | ||
11 | + '</div>'; | ||
12 | + | ||
13 | +var uploadFn = handlebars.compile(tpl || ''); | ||
14 | + | ||
15 | +var $result, | ||
16 | + $upload, | ||
17 | + $filename; | ||
18 | + | ||
19 | +var num, | ||
20 | + inter, | ||
21 | + callback; | ||
22 | + | ||
23 | +$('body').append(uploadFn({})); | ||
24 | + | ||
25 | +$result = $('#yoho-upload-result'); | ||
26 | +$upload = $('#yoho-upload'); | ||
27 | +$filename = $upload.find('.file-name'); | ||
28 | + | ||
29 | +function up(opt) { | ||
30 | + $filename.click(); | ||
31 | + if (opt) { | ||
32 | + callback = opt.callback; | ||
33 | + } else { | ||
34 | + callback = ''; | ||
35 | + } | ||
36 | +} | ||
37 | + | ||
38 | +function getResponse(cb) { | ||
39 | + num = 0; | ||
40 | + inter = setInterval(function() { | ||
41 | + var res = $result[0].contentDocument.body.innerText || ''; | ||
42 | + | ||
43 | + if (res) { | ||
44 | + $result[0].contentDocument.body.innerText = ''; | ||
45 | + if (cb) { | ||
46 | + return cb($.parseJSON(res)); | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + if (num > 20 || res) { | ||
51 | + clearInterval(inter); | ||
52 | + } | ||
53 | + | ||
54 | + num++; | ||
55 | + }, 500); | ||
56 | +} | ||
57 | + | ||
58 | +$filename.change(function() { | ||
59 | + $upload.submit(); | ||
60 | + getResponse(callback); | ||
61 | +}); | ||
62 | + | ||
63 | +exports.up = up; |
1 | .refund-wrap { | 1 | .refund-wrap { |
2 | + .returns-status { | ||
3 | + margin-bottom: 40px; | ||
4 | + } | ||
5 | + | ||
2 | .refund-goods { | 6 | .refund-goods { |
3 | margin-bottom: 40px; | 7 | margin-bottom: 40px; |
4 | 8 | ||
@@ -79,6 +83,13 @@ | @@ -79,6 +83,13 @@ | ||
79 | line-height: 1.5; | 83 | line-height: 1.5; |
80 | text-align: left; | 84 | text-align: left; |
81 | } | 85 | } |
86 | + | ||
87 | + .refund-reason { | ||
88 | + width: 120px; | ||
89 | + height: 28px; | ||
90 | + padding: 0 5px; | ||
91 | + border: 1px solid #eee; | ||
92 | + } | ||
82 | } | 93 | } |
83 | } | 94 | } |
84 | 95 |
-
Please register or login to post a comment