Authored by biao

update for delete img

@@ -14,6 +14,8 @@ var phoneReg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/; @@ -14,6 +14,8 @@ var phoneReg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
14 14
15 var validate = require('./order/validation'); 15 var validate = require('./order/validation');
16 16
  17 +var imgBoxTpl = require('../../tpl/me/thumbnail.hbs');
  18 +
17 var validateMap = { 19 var validateMap = {
18 user: { 20 user: {
19 sl: '#user', 21 sl: '#user',
@@ -400,6 +402,17 @@ function initAddr(areaCode) { @@ -400,6 +402,17 @@ function initAddr(areaCode) {
400 } 402 }
401 } 403 }
402 404
  405 +function bindImgDeleteEvent() {
  406 + $('.operation-box .delete').off('click').on('click', function() {
  407 + var $thumb = $(this).closest('.thumb-box');
  408 + var $t = $thumb.siblings('.img-up-tip');
  409 + var number = $('.thumb-box').length - 1;
  410 +
  411 + $t.text(number + '/4');
  412 + $thumb.remove();
  413 + });
  414 +}
  415 +
403 function bindUploadEvent() { 416 function bindUploadEvent() {
404 var $tip = $('.img-up-tip'); 417 var $tip = $('.img-up-tip');
405 418
@@ -419,12 +432,13 @@ function bindUploadEvent() { @@ -419,12 +432,13 @@ function bindUploadEvent() {
419 var $t; 432 var $t;
420 433
421 if (result.code === 200) { 434 if (result.code === 200) {
422 - img = '<img class="envidence" src="' + result.data + '" alt="凭证图片">'; 435 + img = imgBoxTpl({src: result.data});
423 $t = $(that).next('.img-up-tip'); 436 $t = $(that).next('.img-up-tip');
424 437
425 $(that).before(img); 438 $(that).before(img);
426 number += 1; 439 number += 1;
427 $t.text(number + '/4'); 440 $t.text(number + '/4');
  441 + bindImgDeleteEvent();
428 } else { 442 } else {
429 new _alert(result.message).show(); 443 new _alert(result.message).show();
430 } 444 }
@@ -21,6 +21,36 @@ @@ -21,6 +21,36 @@
21 } 21 }
22 } 22 }
23 23
  24 + .thumb-box {
  25 + position: relative;
  26 + float: left;
  27 +
  28 + .operation-box {
  29 + display: none;
  30 + width: 60px;
  31 + padding: 5px 0;
  32 + position: absolute;
  33 + top: 0;
  34 + background-color: rgba(0, 0, 0, 0.6);
  35 + text-align: center;
  36 + font-size: 12px;
  37 +
  38 + .delete {
  39 + cursor: pointer;
  40 + }
  41 +
  42 + * {
  43 + color: #fff !important;
  44 + }
  45 + }
  46 +
  47 + &:hover {
  48 + .operation-box {
  49 + display: block;
  50 + }
  51 + }
  52 + }
  53 +
24 .iconfont { 54 .iconfont {
25 &.checkbox { 55 &.checkbox {
26 position: relative; 56 position: relative;
@@ -178,6 +208,5 @@ @@ -178,6 +208,5 @@
178 width: 60px; 208 width: 60px;
179 height: 60px; 209 height: 60px;
180 margin-right: 10px; 210 margin-right: 10px;
181 - float: left;  
182 } 211 }
183 } 212 }
  1 +<div class="thumb-box">
  2 + <img class="envidence" src="{{src}}" alt="凭证图片">
  3 + <div class="operation-box">
  4 + <a href="{{src}}" target="_blank">查看</a>
  5 + <span class="delete">删除</span>
  6 + </div>
  7 +</div>