operations.activitytemplate.Edit.js
2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
webpackJsonp([97],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Created by ty on 2016/7/4.
* 活动模板编辑
*/
var $ = __webpack_require__(1),
common = __webpack_require__(2);
var Template = {},
type = $("#wrap-content").attr("role"),
url = $("#wrap-content").attr("url"),
id = $("#wrap-content").data("id");
var edit = new common.edit2("#wrap-content");
if(type == "edit") {
common.util.__ajax({
async: false,
url: "/activityTemplate/getTemplate",
data: {id: id}
}, function (res) {
Template = res.data;
},true);
}
$("#wrap-content").html(common.util.__template2($("#template").html(), Template));
$("#uploadBox").ajaxfileupload({
'action': '/ajax/upload',
'params': {
bucket: "yhb-img01",
__type: "upload"
},
onComplete: function (response) {
if (response.status && response.code == 200) {
if(response.data){
common.util.__tip(response.message, "success");
$("#image").val(response.data);
Template.image = response.data;
}
} else {
common.util.__tip(response.message);
}
}
});
$(document).on("click", "#addUrl", function () {
var urlIndex = '","url":"';
var val = $("#url").val();
var action = val.substring('{"action":"'.length, val.indexOf(urlIndex));
console.log(action);
var url = val.substring(val.indexOf(urlIndex) + urlIndex.length, val.length - 2);
common.dialog.confirm("添加链接", common.util.__template2($("#template2").html(), {action: action, url: url}), function () {
var url = JSON.stringify({
action: $("#goTo").val(),
url: $("#goToUrl").val()
});
$("#url").val(url);
Template.url = url;
});
new common.edit2("#action-row").init();
});
//绑定更改时间
$(document).on("change", ".observe", function () {
Template[$(this).data("field")] = $(this).val();
});
//保存
$(document).on("click", "#save_btn", function () {
if(edit.validate()) {
if(checkShareId()){
common.util.__ajax({
url: url,
data: Template
}, function () {
setTimeout(function () {
location.href = "/operations/activitytemplate/index";
}, 600);
});
}
}
});
function checkShareId() {
var value = $('input[name="share_id"]').val();
if(isNaN(value)){
common.util.__tip("分享ID必须为数字!");
return false;
}else{
return true;
}
}
$(document).on("click", "#chooseFile", function () {
$("#uploadBox").click();
});
/***/ }
]);