hxp
2025-06-09 6c3f6335c70859ded94a1ad8d218acb0ac34239c
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
var gt = new Gettext({ 'domain': 'gmtjs' });
 
// 选择邮件模板
function onChangeMailTemp(tempInfo, isChange) {
    var mailTempSelObj = document.getElementById("MailTemp");
    var tempIndex = mailTempSelObj.selectedIndex - 1;
    // if (tempIndex < 0) {
    //     return;
    // }
    //alert(JSON.stringify(tempInfo));
    var tempItems = 0;
    if (tempIndex >= 0) {
        var curTemp = tempInfo[tempIndex];
        if (isChange) {
            // alert("切换邮件模板: " + mailTempSelObj.options[mailTempSelObj.selectedIndex].text);
        }
 
        tempItems = curTemp.Items.length;
        document.getElementById("MailTempName").value = curTemp.Name;
        document.getElementById("EndDate").value = sumDateByDays(curTemp.EndDays);
        document.getElementById("Title").value = curTemp.Title;
        document.getElementById("Text").value = curTemp.Text;
        document.getElementById("Gold").value = curTemp.Gold;
        document.getElementById("GoldPaper").value = curTemp.GoldPaper;
        document.getElementById("Silver").value = curTemp.Silver;
 
        if (document.getElementById("pack_type").value == "GMT_AddEntireCompensation") {
            document.getElementById("PlayerLV").value = curTemp.PlayerLV;
            document.getElementById("LimitLVType").value = curTemp.LimitLVType + "";
            document.getElementById("CheckState").value = curTemp.CheckState + "";
        }
    } else {
        document.getElementById("MailTempName").value = "";
        document.getElementById("EndDate").value = sumDateByDays(7);
        document.getElementById("Title").value = "";
        document.getElementById("Text").value = "";
        document.getElementById("Gold").value = 0;
        document.getElementById("GoldPaper").value = 0;
        document.getElementById("Silver").value = 0;
 
        if (document.getElementById("pack_type").value == "GMT_AddEntireCompensation") {
            document.getElementById("PlayerLV").value = 30;
            document.getElementById("LimitLVType").value = "0";
            document.getElementById("CheckState").value = "1";
        }
    }
 
    // 修改物品 compensationitem.js 中的
    var itemdiff = tempItems - itemNumArray.length
    while (itemdiff > 0) {
        AddItemHtml();
        itemdiff -= 1;
    }
    while (itemdiff < 0) {
        DelItemHtml(itemNumArray[itemNumArray.length - 1]);
        itemdiff += 1;
    }
    for (let index = 0; index < tempItems; index++) {
        const itemInfo = curTemp.Items[index];
        const itemNum = itemNumArray[index];
        document.getElementById("ItemID" + itemNum).value = itemInfo[0];
        document.getElementById("ItemCnt" + itemNum).value = itemInfo[1];
        document.getElementById("IsBind" + itemNum).value = itemInfo[2] + "";
        onItemIDChange(itemNum, itemInfo[0]);
    }
}
 
function sumDateByDays(days) {
    var date = new Date();
    date.setDate(date.getDate() + days);
    var month = date.getMonth() + 1;
    var day = date.getDate();
    return date.format("yyyy-MM-dd")
    // return date.getFullYear() + '-' + month + '-' + day;
}
 
// 保存修改模板
function onSaveMailTemp(formName) {
    var mailTempSelObj = document.getElementById("MailTemp");
    var tempIndex = mailTempSelObj.selectedIndex - 1;
    if (tempIndex < 0) {
        alert(gt.gettext("需选中指定邮件模板后操作"));
        return false;
    }
    if (document.getElementById("MailTempName").value == "") {
        alert(gt.gettext("模板名称不能为空"));
        return false;
    }
    var curForm = document.forms[0];
    curForm.action = "CompensationTempMgr.php";
    curForm.submit();
    return true;
}
 
// 删除模板
function onDelMailTemp() {
    var mailTempSelObj = document.getElementById("MailTemp");
    var tempIndex = mailTempSelObj.selectedIndex - 1;
    if (tempIndex < 0) {
        alert(gt.gettext("需选中指定邮件模板后操作"));
        return false;
    }
    if (!confirm(gt.gettext("确定删除邮件模板") + ": " + mailTempSelObj.options[mailTempSelObj.selectedIndex].text)) {
        return false;
    }
    var curForm = document.forms[0];
    curForm.action = "CompensationTempMgr.php";
    curForm.submit();
    return true;
}
 
// 保存为新模板
function onSaveNewMailTemp() {
    if (document.getElementById("MailTempName").value == "") {
        alert(gt.gettext("模板名称不能为空"));
        return false;
    }
    var curForm = document.forms[0];
    curForm.action = "CompensationTempMgr.php";
    curForm.submit();
    return true;
}