BBS论坛(十六)
2025年01月14日 02:16:47

LIKE.TG | 发现全球营销软件&服务汇聚顶尖互联网营销和AI营销产品,提供一站式出海营销解决方案。唯一官网:www.like.tg
16.登录功能完成
(1)front/forms.py
class SigninForm(BaseForm):
telephone = StringField(validators=[Regexp(r'1[3578]\d{9}', message='请输入正确格式的手机号码')])
password = StringField(validators=[Regexp(r'[0-9a-zA-Z_\.]{6,15}', message='请输入正确格式的密码')])
remember=StringField()
(2)config.py
FRONT_USER_ID = 'FFFF'
(3)front/views.py
class SigninView(views.MethodView):
def get(self):
return_to = request.referrer
if return_to and return_to != request.url and return_to != url_for('front.signup') and safeutils.is_safe_url(
return_to):
return render_template('front/signin.html', return_to=return_to)
else:
return render_template('front/signin.html')
def post(self):
form = SigninForm(request.form)
if form.validate():
telephone = form.telephone.data
password = form.password.data
remember = form.remember.data
user = FrontUser.query.filter_by(telephone=telephone).first()
if user and user.check_password(password):
session[config.FRONT_USER_ID] = user.id
if remember:
session.permanent = True
return restful.success()
else:
return restful.params_error(message='手机号或密码错误')
else:
return restful.params_error(message=form.get_error())
(4)front_signin.js
/**
* Created by Administrator on 2018/6/9.
*/
$(function(){
$('#submit-btn').on('click',function(event){
event.preventDefault();
var telephone_input=$('input[name=telephone]');
var password_input=$('input[name=password]');
var remember_input=$('input[name=remember]');
var telephone=telephone_input.val();
var password=password_input.val();
var remember=remember_input.checked?1:0;
zlajax.post({
'url':'/signin/',
'data':{
'telephone':telephone,
'password':password,
'remember':remember
},
'success':function(data){
if(data['code']==200){
var return_to=$('#return-to-span').text();
if(return_to){
window.location=return_to;
}else{
window.location='/'
}
}else{
zlalert.alertInfo(data['message']);
}
}
});
});
});
(5)signin.html
<script src="{{ static('front/js/front_signin.js') }}"></script>

LIKE.TG:汇集全球营销软件&服务,助力出海企业营销增长。提供最新的“私域营销获客”“跨境电商”“全球客服”“金融支持”“web3”等一手资讯新闻。
点击【联系客服】 🎁 免费领 1G 住宅代理IP/proxy, 即刻体验 WhatsApp、LINE、Telegram、Twitter、ZALO、Instagram、signal等获客系统,社媒账号购买 & 粉丝引流自助服务或关注【LIKE.TG出海指南频道】、【LIKE.TG生态链-全球资源互联社区】连接全球出海营销资源。
本文由LIKE.TG编辑部转载自互联网并编辑,如有侵权影响,请联系官方客服,将为您妥善处理。
This article is republished from public internet and edited by the LIKE.TG editorial department. If there is any infringement, please contact our official customer service for proper handling.
Server deployment全球论坛人工智能论坛全球峰会发展论坛战略论坛开放论坛程序员论坛互联网峰会科技峰会