/** * Created by TT on 2018/1/30. */ ; spa_define(function () { return $.use(["spa", "util", "form"], function (spa, util, fb) { return { modal: function (data) { var root = spa.findInModal(".sys_question_edit"); var form = fb.build(root.find(".newForm")); root.find(".modal-ctrl .icon-times").on("click", function () { spa.closeModal(); }); form.val({cnt: data.data.cnt,title:data.data.title}); var saveBtn = root.find(".opt-save"), save = function () { var img = []; $('#fileList').find('img').each(function () { img.push($(this).attr("name")); }); util.post("../ajax/qa/question/modify", { img: img.join(","), title: form.val().title, cnt: form.val().cnt, id: data.data.id }, function () { spa.closeModal(); if (data.hand) { data.hand(); } }, {}); }; var $list = $('#fileList'), ratio = window.devicePixelRatio || 1, thumbnailWidth = 100 * ratio, thumbnailHeight = 100 * ratio, uploader; uploader = WebUploader.create({ auto: true, server: 'http://www.ekexiu.com/ajax/question/upload', pick: { id: "#filePicker", multiple: false }, duplicate: true, // fileNumLimit:5, // fileSingleSizeLimit: 2*1024*1024, accept: { title: 'Images', extensions: 'gif,jpg,jpeg,bmp,png', mimeTypes: 'image/jpg,image/jpeg,image/png' } }); uploader.on('fileQueued', function (file) { if ($(".file-item").length < 3) { var $li = $( '
') .appendTo($li) .find('span'); } $percent.css('width', percentage * 100 + '%'); $('#filePicker').hide(); saveBtn.unbind("click"); }); uploader.on('error', function (type) { switch (type) { case 'Q_EXCEED_NUM_LIMIT': alert("错误:上传文件数量过多!"); break; case 'Q_EXCEED_SIZE_LIMIT': alert("错误:文件总大小超出限制!"); break; case 'F_EXCEED_SIZE': alert("错误:文件大小超出限制!"); break; case 'Q_TYPE_DENIED': alert("错误:禁止上传该类型文件!"); break; default: alert('错误代码:' + type); break; } }); if (data.data.img) { var image = split1(data.data.img); for (var i = 0; i < image.length; i++) { var $li = $( '