invitation.js
6.68 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
define('admin/invitation', function(require, exports)
{
var box = require('admin/box'); // 提示框
var $ = require("jquery");
var common = require("common");
var upload = require('admin/upload');
var form_html = $("#form_pan").html() + '';
$("#form_pan").remove();
$("#add_index").click(function()
{
box.confirm
(
form_html, submit,
{
title: '添加' + $(".active").eq(1).children().text(),
width: '770px',
autoClose: false
}
);
});
$(".apply").click(function()
{
var id = $(this).attr('data-id');
var status = $(this).attr('status');
box.confirm((status > 0 ? "确定要取消显示在申请列表中吗?" : "确定要显示在申请列表中吗?"), function()
{
$.ajax
({
type: "post",
url: '/admin/invitation/showinapply',
data: "id=" + id + '&status=' + (status > 0 ? 0 : 1),
success: function(data)
{
if (data.code == 200)
{
window.location.reload();
}
else
{
box.alert(data.message);
}
}
});
});
});
$(".pass").click(function()
{
var id = $(this).attr('data-id');
var status = $(this).attr('status');
box.confirm((status > 0 ? "确定要取消显示在通过列表中吗?" : "确定要显示在通过列表中吗?"), function()
{
$.ajax
({
type: "post",
url: '/admin/invitation/showinpass',
data: "id=" + id + '&status=' + (status > 0 ? 0 : 1),
success: function(data)
{
if (data.code == 200)
{
window.location.reload();
}
else
{
box.alert(data.message);
}
}
});
});
});
//提交index
function submit()
{
var type = $('#type').val();
var d = $('#myTabContent > div.active');
var category = d.find('input[name=category]').val();
var sub = d.find('input[name$=sub]:checked').val();
var name = d.find('input[name=name]').val();
var contacter = d.find('input[name=contacter]').val();
var phone = d.find('input[name=phone]').val();
var email = d.find('input[name=email]').val();
if (type == "")
{
alert("必须选择一个类型!");
return;
}
if (/^\s*$/.test(name))
{
alert("名称不能为空!");
return;
}
if (/^\s*$/.test(contacter))
{
alert("联系人不能为空!");
return;
}
if (phone == "")
{
alert("联系电话不能为空!");
return;
}
//if (!/^(\d{3,4}[-]?)?\d{7,8}(-\d{3,4})?$/.test(phone) && !/^(13|15|17)[0-9]{9}$/.test(phone))
if (!/^((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)$/.test(phone))
{
alert("联系电话格式错误!");
return;
}
if (email == "")
{
alert("邮箱不能为空!");
return;
}
//if (!/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(email))
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
{
alert("邮箱格式错误!");
return;
}
$.ajax
({
type: "post",
url: '/admin/invitation/submit',
data: "type=" + type +
"&category=" + category +
"&sub=" + sub +
"&name=" + encodeURIComponent(name) +
"&contacter=" + encodeURIComponent(contacter) +
"&phone=" + encodeURIComponent(phone) +
"&email=" + encodeURIComponent(email),
success: function(data)
{
if (data.code == 200)
{
window.location.reload();
}
else
{
box.alert(data.message);
}
}
});
}
});