operations.entrance.Index.js
5.7 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
webpackJsonp([106],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Created by ty on 2016/3/22.
*/
var $ = __webpack_require__(1),
common = __webpack_require__(2),
util = __webpack_require__(13);
new common.dropDown({el: "#entrance-platform"});
new common.dropDown({el: "#entrance-status"});
var platforms = ["手机", "ipad", "custom"];
var module = {};
var g = new common.grid({
el: "#entrance-list",
hash: false,
parms: function () {
return {
platform: common.util.__input('entrance-platform'),
status: common.util.__input('entrance-status')
};
},
columns: [
{display: "ID", name: "id"},
{display: "入口名称", name: "entryName"},
{display: "点击前的图片", name: "clickBeforeImg"},
{display: "点击后的图片", name: "clickAfterImg"},
{display: "ZIP图片包地址",name: "zipUrl"},
{display: "类别",name: "platform", render: function(item) {
if(item.platform == 1) {
return "手机";
} else if(item.platform == 2) {
return "ipad";
}
}},
{
display: "状态",name: "", render: function (item) {
if(item.status == 0) {
return "关闭";
} else if(item.status == 1) {
return "开启";
}
}
},
{display: "创建时间",name: "",render:function(item){
if (item.createTime) {
var date = new Date(item.createTime * 1000),
now = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
return now;
}
}},
{
display: "操作",name: "", render: function (item) {
var arr = [];
arr.push('<a class="btn btn-info btn-xs add2" data-index="' + item.__index + '">编辑</a>');
if(item.status == 0) {
arr.push('<a class="btn btn-success btn-xs change-status" data-index="' + item.__index + '">开启入口</a>');
} else {
arr.push('<a class="btn btn-danger btn-xs change-status" data-index="' + item.__index + '">关闭入口</a>');
}
return arr.join("");
}
}
]
});
g.init('/operations/entrance/selectEntranceList');
var Bll = {
toast:function(url, item, hint) {
var e = new common.edit2("#base-form", {bucket:"yhb-img01"});
var dialog = common.dialog.confirm(hint,
common.util.__template2($("#template-add").html(), item),
function() {
if(e.validate()) {
module.url = JSON.stringify({
action: $("#intent").val(),
url: $("#url").val()
});
//console.log(module);
common.util.__ajax({
url: url,
data: module
}, function () {
dialog.close();
g.reload();
});
}
return false;
});
e.__dropDownRender();
e.bind();
$("#zip").ajaxfileupload({
'action': '/ajax/upload',
'params': {
bucket: "yohobuyzip",
__type: "fileupload-upload"
},
onComplete: function (response) {
if (response.status && response.code == 200) {
if(response.data){
common.util.__tip(response.message, "success");
$("#zipUrl").val(response.data);
module.zipUrl = response.data;
}
} else {
common.util.__tip(response.message);
}
},
valid_extensions: ["zip"]
})
new common.dropDown({el: "#platform"});
new common.dropDown({el: "#gender"});
if(item.url && item.url.indexOf('"action"') != -1) {
var urlIndex = '","url":"';
$("#intent").val(item.url.substring('{"action":"'.length, item.url.indexOf(urlIndex)));
$("#url").val(item.url.substring(item.url.indexOf(urlIndex) + urlIndex.length, item.url.length - 2));
}
}
};
$(document).on("change", ".observe", function () {
var name = $(this).data("field");
module[name] = $(this).val();
});
$(document).on('click', '.change-status', function() {
var item = g.rows[$(this).data("index")];
if(item.status == 1) {
item.status = 0;
} else {
item.status = 1;
}
common.util.__ajax({
url: '/operations/entrance/publishEntrance',
data: {
id: item.id,
status: item.status
}
}, function() {
g.reload();
});
});
$(document).on('click', '#add-entry', function() {
module = {};
module.platform = 1;
module.gender = "1,3";
Bll.toast("/operations/entrance/insertEntrance", module, "添加入口信息");
});
$(document).on('click', '.add2', function() {
module = g.rows[$(this).data("index")];
Bll.toast("/operations/entrance/updateEntrance", module, "编辑入口信息");
});
$(document).on('click', '#filter-btn', function() {
g.reload(1);
});
//输入限制
$(document).on("keyup",".number", function() {
$(this).val($(this).val().replace(/\D/g, ''));
});
/***/ }
]);