...
|
...
|
@@ -17,6 +17,8 @@ var validate = require('./order/validation'); |
|
|
var imgBoxTpl = require('../../tpl/me/thumbnail.hbs');
|
|
|
var changeTypeTpl = require('../../tpl/me/change-type.hbs');
|
|
|
|
|
|
var upload = require('../plugins/upload');
|
|
|
|
|
|
var validateMap = {
|
|
|
user: {
|
|
|
sl: '#user',
|
...
|
...
|
@@ -371,51 +373,64 @@ function bindImgDeleteEvent() { |
|
|
});
|
|
|
}
|
|
|
|
|
|
function bindUploadEvent() {
|
|
|
var $tip = $('.img-up-tip');
|
|
|
function doUpload(count, goodIndex) {
|
|
|
var $el = $('*[data-good-index=' + goodIndex + ']');
|
|
|
|
|
|
$tip.text('0/4');
|
|
|
if (count < 4) {
|
|
|
upload.up({
|
|
|
callback: function(result) {
|
|
|
var img;
|
|
|
var $t;
|
|
|
var o;
|
|
|
var n;
|
|
|
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
n = parseInt($el.siblings('.thumb-box').length, 10);
|
|
|
o = {src: result.data};
|
|
|
|
|
|
if (result.imgs && result.imgs.length) {
|
|
|
o.url = result.imgs[0];
|
|
|
}
|
|
|
|
|
|
$('.img-upload').on('click', function() {
|
|
|
var upload = require('../plugins/upload');
|
|
|
var that = this;
|
|
|
var n = parseInt($(that).siblings('.thumb-box').length, 10);
|
|
|
img = imgBoxTpl(o);
|
|
|
$t = $el.next('.img-up-tip');
|
|
|
$el.before(img);
|
|
|
|
|
|
n += 1;
|
|
|
$t.text(n + '/4');
|
|
|
bindImgDeleteEvent();
|
|
|
|
|
|
if (n >= 4) {
|
|
|
$el.hide();
|
|
|
}
|
|
|
|
|
|
if (n < 4) {
|
|
|
upload.up({
|
|
|
callback: function(result) {
|
|
|
var img;
|
|
|
var $t;
|
|
|
var o;
|
|
|
} else {
|
|
|
new _alert(result.message).show();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
n = parseInt($(that).siblings('.thumb-box').length, 10);
|
|
|
o = {src: result.data};
|
|
|
}
|
|
|
|
|
|
if (result.imgs && result.imgs.length) {
|
|
|
o.url = result.imgs[0];
|
|
|
}
|
|
|
function bindUploadEvent() {
|
|
|
var $tip = $('.img-up-tip');
|
|
|
|
|
|
img = imgBoxTpl(o);
|
|
|
$t = $(that).next('.img-up-tip');
|
|
|
$(that).before(img);
|
|
|
$tip.text('0/4');
|
|
|
|
|
|
n += 1;
|
|
|
$t.text(n + '/4');
|
|
|
bindImgDeleteEvent();
|
|
|
$('.img-upload').each(function(index, uploadBtn) {
|
|
|
$(uploadBtn).on('click', function() {
|
|
|
var that = this;
|
|
|
var n = parseInt($(that).siblings('.thumb-box').length, 10);
|
|
|
var goodIndex = $(that).data('good-index');
|
|
|
|
|
|
if (n >= 4) {
|
|
|
$(that).hide();
|
|
|
}
|
|
|
if (n > 4) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
new _alert(result.message).show();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
doUpload(n, goodIndex);
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
|