Showing
1 changed file
with
23 additions
and
4 deletions
@@ -8,7 +8,7 @@ e.on("render", function() { | @@ -8,7 +8,7 @@ e.on("render", function() { | ||
8 | 8 | ||
9 | }); | 9 | }); |
10 | 10 | ||
11 | -// TODO 验证图片 | 11 | +// 验证图片 |
12 | e.on("validate", function() { | 12 | e.on("validate", function() { |
13 | var img1 = $("#wechat1_img").attr("value"); | 13 | var img1 = $("#wechat1_img").attr("value"); |
14 | if (img1.length == 0) { | 14 | if (img1.length == 0) { |
@@ -26,7 +26,13 @@ e.init(); | @@ -26,7 +26,13 @@ e.init(); | ||
26 | $('#add-btn').click(function(option) { | 26 | $('#add-btn').click(function(option) { |
27 | e.submit($('#add-form').attr('action'), function(option) { | 27 | e.submit($('#add-form').attr('action'), function(option) { |
28 | 28 | ||
29 | - option.data.contentData = buildToJSON(option.data); | 29 | + var data = buildToObjects(option.data); |
30 | + | ||
31 | + addSuffix(data); | ||
32 | + | ||
33 | + option.data.contentData = JSON.stringify(data); | ||
34 | + | ||
35 | + console.log(data); | ||
30 | 36 | ||
31 | option.beforeSend = function() { | 37 | option.beforeSend = function() { |
32 | $('#add-btn').addClass('disabled'); | 38 | $('#add-btn').addClass('disabled'); |
@@ -63,11 +69,11 @@ $('#add-btn').click(function(option) { | @@ -63,11 +69,11 @@ $('#add-btn').click(function(option) { | ||
63 | "src":"" | 69 | "src":"" |
64 | } | 70 | } |
65 | ] */ | 71 | ] */ |
66 | -function buildToJSON(data) { | 72 | +function buildToObjects(data) { |
67 | var wechats = []; | 73 | var wechats = []; |
68 | wechats.push(Wechat(data.wechat_id1, data.wechat_name1, data.wechat1_img)); | 74 | wechats.push(Wechat(data.wechat_id1, data.wechat_name1, data.wechat1_img)); |
69 | wechats.push(Wechat(data.wechat_id2, data.wechat_name2, data.wechat2_img)); | 75 | wechats.push(Wechat(data.wechat_id2, data.wechat_name2, data.wechat2_img)); |
70 | - return JSON.stringify(wechats); | 76 | + return wechats; |
71 | } | 77 | } |
72 | 78 | ||
73 | function Wechat(id, name, src) { | 79 | function Wechat(id, name, src) { |
@@ -77,3 +83,16 @@ function Wechat(id, name, src) { | @@ -77,3 +83,16 @@ function Wechat(id, name, src) { | ||
77 | "src": src | 83 | "src": src |
78 | }; | 84 | }; |
79 | } | 85 | } |
86 | + | ||
87 | +var addSuffix = function (contentData) { | ||
88 | + if (typeof contentData == "object") { | ||
89 | + for (var i in contentData) { | ||
90 | + if (i == "src" && contentData[i].indexOf("?") == -1) { | ||
91 | + contentData[i] = contentData[i] + "?imageView2/{mode}/w/{width}/h/{height}"; | ||
92 | + } else { | ||
93 | + addSuffix(contentData[i]); | ||
94 | + } | ||
95 | + } | ||
96 | + } | ||
97 | + return contentData; | ||
98 | +}; |
-
Please register or login to post a comment