first commit

This commit is contained in:
renjianbo
2026-01-09 18:28:10 +08:00
parent 8ca573e948
commit 5cc088a210
134 changed files with 8730 additions and 0 deletions

View File

@@ -0,0 +1,133 @@
{% extends 'base.html' %}
{% block title %}成为机构{% endblock %}
{% block content %}
<div class="main-content container" style="background: url(../static/images/form-bg.jpg) no-repeat center top;" >
<div class="inner-content">
{% if is_company_user %}
<div class="container">
<div class="row">
<div class="span4">
<div class="alert alert-success">
<strong>您当前登录的用户已经是机构成员了,无需再注册</strong><a href="/bs/set{% if request.session.uid %}?uid={{ request.session.uid }}{% else %}{% endif %}"><b>点此</b></a>出题
<a onclick="history.back(-1)" style="float:right"> <span class="glyphicon glyphicon-menu-left"></span><strong>返回上一页</strong></a>
</div>
</div>
</div>
</div>
{% else %}
<div class="row" style="margin-top: 10%;" >
<div class="col-md-3"></div>
<div class="col-md-5" style="font-size:16px">
<div class="panel panel-info">
<div class="panel-heading"><h3 class="panel-title">注册成为机构</h3></div>
<div class="panel-body">
<form id="bizRegistry" class="form-group">
<label for="bizEmail">邮箱</label>
<input type="text" class="form-control" id="bizEmail" placeholder="填写机构邮箱" />
<label for="bizCompanyName">名称</label>
<input type="text" class="form-control" id="bizCompanyName" placeholder="填写机构名称" />
<label for="bizCompanyType">类型</label>
<select id="bizCompanyType" class="form-control">
{% for k, v in types.items %}
<option value="{{ k }}">{{ v }}</option>
{% endfor %}
</select>
<label for="bizUsername">联系人</label>
<input type="text" class="form-control" id="bizUsername" placeholder="填写机构联系人" />
<label for="bizPhone">手机号</label>
<input type="text" class="form-control" id="bizPhone" placeholder="填写联系人手机" />
<input type="submit" id="bizSubmit" class="btn btn-primary" value="注册机构" style="float: right;margin-top: 20px" />
</form>
</div>
</div>
</div>
<div class="col-md-4"></div>
</div>
{% endif %}
</div>
</div>
<script type="text/javascript">
$('#bizSubmit').click(function () {
var email = $('#bizEmail').val();
var name = $('#bizCompanyName').val();
var type = $('#bizCompanyType').val();
var username = $('#bizUsername').val();
var phone = $('#bizPhone').val();
if(!email.match('^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$')) {
$('#bizEmail').val('');
$('#bizEmail').attr('placeholder', '邮箱格式错误');
$('#bizEmail').css('border', '1px solid red');
return false;
}else{
$('#bizEmail').css('border', '1px solid #C1FFC1');
}
if(!(name.match('^[a-zA-Z0-9_\\u4e00-\\u9fa5]{4,20}$'))) {
$('#bizCompanyName').val('');
$('#bizCompanyName').attr('placeholder', '请填写4-20中文字母数字或者下划线机构名称');
$('#bizCompanyName').css('border', '1px solid red');
return false;
}else{
$('#bizCompanyName').css('border', '1px solid #C1FFC1');
}
if(!(username.match('^[\u4E00-\u9FA5A-Za-z]+$'))){
$('#bizUsername').val('');
$('#bizUsername').attr('placeholder', '联系人姓名应该为汉字或大小写字母');
$('#bizUsername').css('border', '1px solid red');
return false;
}else{
$('#bizUsername').css('border', '1px solid #C1FFC1');
}
if(!(phone.match('^1[3|4|5|8][0-9]\\d{4,8}$'))){
$('#bizPhone').val('');
$('#bizPhone').attr('placeholder', '手机号不符合规则');
$('#bizPhone').css('border', '1px solid red');
return false;
}else{
$('#bizPhone').css('border', '1px solid #C1FFC1');
}
$.ajax({
url: '/api/checkbiz',
type: 'get',
data: {
'email': email
},
dataType: 'json',
success: function (res) {
if(res.status === 200) {
if(res.data.bizaccountexists) {
alert('您的账户已存在,请直接登录');
window.location.href = '/index';
}
else if(res.data.userexists && !res.data.bizaccountexists) {
if(confirm('您的邮箱已被注册为普通用户,我们将会为您绑定该用户。')){
bizPost(email, name, type, username, phone, 1);
window.location.href = '/biz/notify?email=' + email + '&bind=1';
}else {
window.location.href = '/index{% if request.session.uid %}?uid={{ request.session.uid }}{% else %}{% endif %}';
}
}
else{
bizPost(email, name, type, username, phone, 2);
window.location.href = '/biz/notify?email=' + email;
}
}
}
});
function bizPost(email, name, type, username, phone, flag) {
$.ajax({
url: '/api/regbiz',
data: {
'email': email,
'name': name,
'type': type,
'username': username,
'phone': phone,
'flag': flag
},
type: 'post',
dataType: 'json'
})
}
});
</script>
{% endblock %}

View File

@@ -0,0 +1,103 @@
{% extends 'base.html' %}
{% block title %}注册结果{% endblock %}
{% block content %}
<div class="container">
{% if is_registered %}
{% if bind %}
<div class="row" style="min-height: 800px">
<div class="span4">
<div class="alert alert-success">
<strong>注册成功!</strong><br /><a href="/">点此</a>返回首页登录
</div>
</div>
</div>
{% else %}
<div class="row" style="min-height: 800px">
<div class="span4">
<div class="alert alert-success">
<strong>注册成功!</strong>还差一步,您需要创建一个密码
</div>
</div>
<div class="row">
<div class="col-md-4">
<form>
<div class="form-group">
<label for="bizResetId" class="control-label">邮箱</label>
<input type="text" class="form-control" id="bizResetId" placeholder="hugo.zhang@example.com">
</div>
<div class="form-group">
<label for="bizResetNewPassword" class="control-label">新密码</label>
<input type="password" class="form-control" id="bizResetNewPassword" placeholder="p@ssw0rd123">
</div>
<div class="form-group">
<label for="bizResetNewPasswordAgain" class="control-label">再次输入密码</label>
<input type="password" class="form-control" id="bizResetNewPasswordAgain" placeholder="p@ssw0rd123">
</div>
<div class="form-group">
<p style="color: red;float: left">邮件发送后,请在三十分钟之内登录邮箱确认!</p>
<button type="button" class="btn btn-primary" style="float: right" id="bizResetPost">发送邮件</button>
</div>
</form>
</div>
<div class="col-md-8">
</div>
</div>
</div>
{% endif %}
{% else %}
<div class="row">
<div class="span4">
<div class="alert alert-danger">
<strong>机构注册失败!</strong>注册过程貌似出现了问题,请您联系<a href="/bs/contact{% if request.session.uid %}?uid={{ request.session.uid }}{% else %}{% endif %}">管理员</a>以便找到解决办法。
</div>
</div>
</div>
{% endif %}
</div>
<script>
$('#bizResetPost').click(function () {
var email = $('#bizResetId').val();
var newPassword = $('#bizResetNewPassword').val();
var newPasswordAgain = $('#bizResetNewPasswordAgain').val();
if(!checkEmail(email)) {
$('#bizResetId').val('');
$('#bizResetId').attr('placeholder', '邮件格式错误');
$('#bizResetId').css('border', '1px solid red');
return false;
}else{
$('#bizResetId').css('border', '1px solid #C1FFC1');
}
if(!(newPassword === newPasswordAgain)){
$('#bizResetNewPasswordAgain').val('');
$('#bizResetNewPasswordAgain').attr('placeholder', '两次输入密码不一致');
$('#bizResetNewPassword').css('border', '1px solid red');
$('#bizResetNewPasswordAgain').css('border', '1px solid red');
return false;
}else{
$('#bizResetNewPassword').css('border', '1px solid #C1FFC1');
$('#bizResetNewPasswordAgain').css('border', '1px solid #C1FFC1');
}
$.ajax({
url: '/api/resetpasswd',
type: 'post',
data: {
'email': email,
'new_password': newPassword,
'new_password_again': newPasswordAgain,
'is_biz': 1
},
dataType: 'json',
success: function (res) {
if(res.status === 200) {
alert('发送成功!请您登录邮箱验证一下您的账户');
window.location.href = '/index'
}
if(res.status === 300005) {
alert('邮件正在发送中,请稍等...');
}
}
});
return false;
})
</script>
{% endblock %}