Authored by liqingzhong

链接增加后缀

... ... @@ -8,7 +8,7 @@ e.on("render", function() {
});
// TODO 验证图片
// 验证图片
e.on("validate", function() {
var img1 = $("#wechat1_img").attr("value");
if (img1.length == 0) {
... ... @@ -26,7 +26,13 @@ e.init();
$('#add-btn').click(function(option) {
e.submit($('#add-form').attr('action'), function(option) {
option.data.contentData = buildToJSON(option.data);
var data = buildToObjects(option.data);
addSuffix(data);
option.data.contentData = JSON.stringify(data);
console.log(data);
option.beforeSend = function() {
$('#add-btn').addClass('disabled');
... ... @@ -63,11 +69,11 @@ $('#add-btn').click(function(option) {
"src":""
}
] */
function buildToJSON(data) {
function buildToObjects(data) {
var wechats = [];
wechats.push(Wechat(data.wechat_id1, data.wechat_name1, data.wechat1_img));
wechats.push(Wechat(data.wechat_id2, data.wechat_name2, data.wechat2_img));
return JSON.stringify(wechats);
return wechats;
}
function Wechat(id, name, src) {
... ... @@ -77,3 +83,16 @@ function Wechat(id, name, src) {
"src": src
};
}
var addSuffix = function (contentData) {
if (typeof contentData == "object") {
for (var i in contentData) {
if (i == "src" && contentData[i].indexOf("?") == -1) {
contentData[i] = contentData[i] + "?imageView2/{mode}/w/{width}/h/{height}";
} else {
addSuffix(contentData[i]);
}
}
}
return contentData;
};
... ...