Commit 7aa101da authored by 杨培's avatar 杨培

改进提交课程的体验

parent fc804553
...@@ -123,12 +123,13 @@ var vm = new Vue({ ...@@ -123,12 +123,13 @@ var vm = new Vue({
to = org; to = org;
} }
//绑定提示到元素上
if (text) { if (text) {
if (to.tipIndex) { if (to.tipIndex) {
layer.close(to.tipIndex); layer.close(to.tipIndex);
} }
to.tipIndex = layer.tips(text, to, { to.tipIndex = layer.tips(text, to, {
tips: 1, tips: org == form.name ? 3 : 2,
time: 0, time: 0,
tipsMore: true tipsMore: true
}); });
...@@ -140,13 +141,17 @@ var vm = new Vue({ ...@@ -140,13 +141,17 @@ var vm = new Vue({
success: function() {}, //添加 success 后,当表单验证成功时才会触发 errorPlacement,否则验证成功不触发 success: function() {}, //添加 success 后,当表单验证成功时才会触发 errorPlacement,否则验证成功不触发
submitHandler: function() { submitHandler: function() {
var data = $(form).serialize(); var data = $(form).serialize();
var idx = layer.msg("正在提交..", {icon:16, shade: [0.2,'#000'], time:0});
$.post("/my-course/submit", data, function(t) { $.post("/my-course/submit", data, function(t) {
layer.close(idx);
if (t.status) { if (t.status) {
location.replace("/my-course/result?id=" + t.data.course_id + "&action=publish"); location.replace("/my-course/result?id=" + t.data.course_id + "&action=publish");
} else { } else {
alert(t.message); alert(t.message);
} }
}, "json"); }, "json");
return false; return false;
} }
}); });
......
/**
* Created by pader on 16/9/30.
*
* 文件相关辅助函数
* 文件、路径、文件名称、文件大小等与文件相关的能用辅助函数
*/
module.exports = {
/**
* 根据输入的字节数显示可读形式的文件大小
*
* @param {int} bytes
* @returns {string}
*/
readableSize: function(bytes) {
var filesizeUnits = ['Bytes','KB','MB','GB','TB','PB','EB','ZB','YB'];
var base = 1024;
if (bytes) {
var i = 0;
if (bytes >= base) {
var a = bytes;
while(1) { a /= base; i++; if(a < base) break; }
}
return parseFloat((bytes/Math.pow(base,i)).toFixed(2)) + ' ' + filesizeUnits[i];
} else return '0 Byte';
}
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment