|
@@ -14,7 +14,8 @@
|
14
|
14
|
|
15
|
15
|
<dialog open id="modalAdd" class="x-body layui-anim layui-anim-up" hidden=true style = "center;">
|
16
|
16
|
<form action="exchangecode" method="post" class="layui-form layui-form-pane">
|
17
|
|
- <input id="pcode" name="pcode" placeholder="兑换码" type="text" lay-verify="required" class="layui-input" disabled="disabled">
|
|
17
|
+ 兑换码
|
|
18
|
+ <input id="pcode" name="pcode" placeholder="兑换码" type="text" lay-verify="required" class="layui-input">
|
18
|
19
|
<br>
|
19
|
20
|
<input class="layui-btn" type="button" onclick="randCode()" value=随机>
|
20
|
21
|
<hr class="hr15">
|
|
@@ -49,13 +50,23 @@
|
49
|
50
|
<dialog open id="modalModify" class="x-body layui-anim layui-anim-up" hidden=true style = "center;">
|
50
|
51
|
<form action="exchangecode" method="put" class="layui-form layui-form-pane">
|
51
|
52
|
<input id="pcode_modify" hidden=true type="text">
|
52
|
|
- <input id="awardTimes_modify" name="awardTimes_modify" placeholder="渠道" type="text" lay-verify="required" class="layui-input">
|
|
53
|
+ 剩余领奖次数
|
|
54
|
+ <input id="awardTimes_modify" name="awardTimes_modify" placeholder="剩余领奖次数" type="text" lay-verify="required" class="layui-input">
|
53
|
55
|
<br>
|
54
|
|
- <input id="expireTime_modify" name="expireTime_modify" placeholder="版本" type="text" lay-verify="required" class="layui-input">
|
55
|
|
- <br>
|
56
|
|
- <input id="items_modify" name="items_modify" placeholder="下载地址" type="text" lay-verify="required" class="layui-input">
|
|
56
|
+ 过期时间
|
|
57
|
+ <input id="expireTime_modify" name="expireTime_modify" placeholder="过期时间" type="text" lay-verify="required" class="layui-input">
|
|
58
|
+ <hr class="hr15">
|
|
59
|
+ 随机物品列表
|
|
60
|
+ <table class="radio-table" border="1" id="tb_item_modify">
|
|
61
|
+ <thead>
|
|
62
|
+ <th style="width:100px;">物品ID</th>
|
|
63
|
+ <th style="width:100px;">物品数量</th>
|
|
64
|
+ <th style="width:100px;">权重</th>
|
|
65
|
+ <th style="width:256px;">操作</th>
|
|
66
|
+ </thead>
|
|
67
|
+ </table>
|
57
|
68
|
<br>
|
58
|
|
- <input class="layui-btn" type="button" onclick="modalModifyItem()" value=修改>
|
|
69
|
+ <input class="layui-btn" type="button" onclick="modalAddItem()" value=新增道具>
|
59
|
70
|
<hr class="hr15">
|
60
|
71
|
<input value="修改" class="layui-btn" style="width:100%;" type="button" onclick="modifyExchangeCode()">
|
61
|
72
|
<br>
|
|
@@ -106,7 +117,7 @@
|
106
|
117
|
{{range .infoList}}
|
107
|
118
|
<tr>
|
108
|
119
|
<td style = "text-align:center;">
|
109
|
|
- <input class="layui-btn" type="button" onclick="OpenModifyItem({{.Pcode}}, {{.AwardTimes}}, {{.ExpireTime}}), {{.Items}}" value=修改>
|
|
120
|
+ <input class="layui-btn" type="button" onclick="OpenModifyItem({{.Pcode}}, {{.AwardTimes}}, {{.ExpireTime}}, {{.Items}})" value=修改>
|
110
|
121
|
{{" | "}}
|
111
|
122
|
<input class="layui-btn" type="button" onclick="clickDelete({{.Pcode}})" value=删除>
|
112
|
123
|
</td>
|
|
@@ -140,10 +151,13 @@
|
140
|
151
|
return res;
|
141
|
152
|
}
|
142
|
153
|
|
|
154
|
+ var isModelAdd = true
|
143
|
155
|
var codeItems = [];
|
144
|
156
|
// 刷新物品列表
|
145
|
157
|
function refreshTableItem() {
|
146
|
|
- var obj = document.getElementById("tb_item")
|
|
158
|
+ var key = "tb_item"
|
|
159
|
+ if (isModelAdd == false){key = "tb_item_modify"}
|
|
160
|
+ var obj = document.getElementById(key)
|
147
|
161
|
var tbody = obj.getElementsByTagName("tbody")[0];
|
148
|
162
|
if (tbody) {
|
149
|
163
|
if (-[1,]) {
|
|
@@ -185,8 +199,6 @@
|
185
|
199
|
}
|
186
|
200
|
// 物品弹窗
|
187
|
201
|
function modalAddItem() {
|
188
|
|
- console.log("modalAddItem codeItems:"+codeItems)
|
189
|
|
-
|
190
|
202
|
refreshTableItem()
|
191
|
203
|
|
192
|
204
|
document.getElementById("modalItem").hidden = false;
|
|
@@ -247,6 +259,7 @@
|
247
|
259
|
document.getElementById("pcode").value = generateMixed(6);
|
248
|
260
|
}
|
249
|
261
|
function OpenAddItem() {
|
|
262
|
+ isModelAdd = true
|
250
|
263
|
document.getElementById("pcode").value = generateMixed(6);
|
251
|
264
|
document.getElementById("awardTimes").value = 100;
|
252
|
265
|
|
|
@@ -266,9 +279,29 @@
|
266
|
279
|
var expireTime = document.getElementById("expireTime").value;
|
267
|
280
|
|
268
|
281
|
if (pcode.length != 6){
|
269
|
|
- alert("兑换码错误!请设置6位大写字母");
|
|
282
|
+ alert("兑换码长度错误!6位大写字母");
|
|
283
|
+ return;
|
|
284
|
+ }
|
|
285
|
+ // 兑换码字符检查
|
|
286
|
+ var isMatch = true
|
|
287
|
+ for (var i = 0; i < pcode.length; i ++){
|
|
288
|
+ for (var j = 0; j < randChats.length; j ++) {
|
|
289
|
+ if (pcode[i] == randChats[j]){
|
|
290
|
+ console.info("兑换码字符检查 i:"+i+";"+pcode[i])
|
|
291
|
+ console.info("兑换码字符检查 j:"+j+";"+randChats[j])
|
|
292
|
+ isMatch = false;
|
|
293
|
+ break;
|
|
294
|
+ }
|
|
295
|
+ }
|
|
296
|
+ if (isMatch == false) {
|
|
297
|
+ break;
|
|
298
|
+ }
|
|
299
|
+ }
|
|
300
|
+ if (isMatch == false){
|
|
301
|
+ alert("兑换码错误!请使用大写字母");
|
270
|
302
|
return;
|
271
|
303
|
}
|
|
304
|
+
|
272
|
305
|
if (awardTimes <= 0){
|
273
|
306
|
alert("请正确设置领奖次数");
|
274
|
307
|
return;
|
|
@@ -309,25 +342,40 @@
|
309
|
342
|
});
|
310
|
343
|
}
|
311
|
344
|
|
312
|
|
- function OpenModifyItem(id, channel, version, addr, filesize) {
|
313
|
|
- document.getElementById("modify_id").value = id;
|
314
|
|
- document.getElementById("channelmodify").value = channel;
|
315
|
|
- document.getElementById("versionmodify").value = version;
|
316
|
|
- document.getElementById("addrmodify").value = addr;
|
317
|
|
- document.getElementById("filesizemodify").value = filesize;
|
|
345
|
+ function closeModalItem() {
|
|
346
|
+ document.getElementById("modalItem").hidden = true;
|
|
347
|
+ }
|
|
348
|
+
|
|
349
|
+ function OpenModifyItem(pcode, awardTimes, expireTime, items) {
|
|
350
|
+ isModelAdd = false;
|
|
351
|
+
|
|
352
|
+ codeItems = []
|
|
353
|
+ for (var i = 0; i < items.length; i ++) {
|
|
354
|
+ codeItems.push({'id':items[i].id, 'count':items[i].count, 'weight':items[i].weight});
|
|
355
|
+ }
|
|
356
|
+
|
|
357
|
+ document.getElementById("pcode_modify").value = pcode;
|
|
358
|
+ document.getElementById("awardTimes_modify").value = awardTimes;
|
|
359
|
+ var dateTime = new Date(expireTime*1000);
|
|
360
|
+ document.getElementById("expireTime_modify").value = formaData(dateTime);
|
|
361
|
+ refreshTableItem()
|
|
362
|
+
|
318
|
363
|
document.getElementById("modalModify").hidden = false;
|
319
|
364
|
}
|
320
|
|
- function closeModifyItem() {
|
|
365
|
+ function closeModalModify() {
|
321
|
366
|
document.getElementById("modalModify").hidden = true;
|
322
|
367
|
}
|
323
|
368
|
|
324
|
|
- function modifyItem () {
|
325
|
|
- var id = document.getElementById("modify_id").value;
|
326
|
|
- var channel = document.getElementById("channelmodify").value;
|
327
|
|
- var version = document.getElementById("versionmodify").value;
|
328
|
|
- var addr = document.getElementById("addrmodify").value;
|
329
|
|
- var filesize = document.getElementById("filesizemodify").value;
|
330
|
|
- var text = "channel=" + encodeURI(channel) + "&version=" + encodeURI(version) + "&addr=" + encodeURI(addr) + "&filesize=" + encodeURI(filesize) + "&id=" + encodeURI(id) + "&action=modify";
|
|
369
|
+ function modifyExchangeCode () {
|
|
370
|
+ var pcode = document.getElementById("pcode_modify").value;
|
|
371
|
+ var awardTimes = document.getElementById("awardTimes_modify").value;
|
|
372
|
+ var expireTime = document.getElementById("expireTime_modify").value;
|
|
373
|
+
|
|
374
|
+ var text = "token=" + encodeURI(token);
|
|
375
|
+ text += "&pcode=" + encodeURI(pcode);
|
|
376
|
+ text += "&awardTimes=" + encodeURI(awardTimes);
|
|
377
|
+ text += "&expireTime=" + encodeURI(expireTime);
|
|
378
|
+ text += "&items=" + encodeURI(JSON.stringify(codeItems));
|
331
|
379
|
|
332
|
380
|
$.ajax({
|
333
|
381
|
type:"put",
|
|
@@ -347,8 +395,9 @@
|
347
|
395
|
});
|
348
|
396
|
}
|
349
|
397
|
|
350
|
|
- function clickDelete (id) {
|
351
|
|
- var text = "id=" + encodeURI(id) + "&action=delete";
|
|
398
|
+ function clickDelete (pcode) {
|
|
399
|
+ var text = "token=" + encodeURI(token);
|
|
400
|
+ text += "&pcode=" + encodeURI(pcode);
|
352
|
401
|
|
353
|
402
|
$.ajax({
|
354
|
403
|
type:"delete",
|