官方社群在线客服官方频道防骗查询货币工具

BBS论坛(六)

BBS论坛(六)路遥
2025年01月14日📖 4 分钟
LIKE.TG 社交媒体链接LIKE.TG 社交媒体链接LIKE.TG 社交媒体链接LIKE.TG 社交媒体链接
Fansoso粉丝充值系统

LIKE.TG | 发现全球营销软件&服务汇聚顶尖互联网营销和AI营销产品,提供一站式出海营销解决方案。唯一官网:www.like.tg

6.1.优化json数据的返回

(1)新建utils/restful.py

代码语言:javascript
复制
# utils/restful.py from flask import jsonify class HttpCode(object): ok = 200 unautherror = 401 paramserror = 400 servererror = 500 def restful_result(code,message,data): return jsonify({"code":code,"message":message,"data":data or {}}) def success(message="",data=None): return restful_result(code=HttpCode.ok,message=message,data=data) def unauth_error(message=""): return restful_result(code=HttpCode.unautherror,message=message,data=None) def params_error(message=""): return restful_result(code=HttpCode.paramserror,message=message,data=None) def server_error(message=""): return restful_result(code=HttpCode.servererror,message=message or "服务器内部错误",data=None)

(2)cms/views.py

代码语言:javascript
复制
class ResetPwdView(views.MethodView): . . . . if user.check_password(oldpwd): user.password = newpwd db.session.commit() return restful.success() else: return restful.params_error("旧密码错误") else: return restful.params_error(form.get_error())

6.2.sweetalert优化修改密码结果反馈

(1)把sweetalert文件夹放到static/common下面

(2)在cms/cms_base.html中引用

代码语言:javascript
复制
<link rel="stylesheet" href="{{ static("common/sweetalert/sweetalert.css") }}"> <script src="{{ static("common/sweetalert/sweetalert.min.js") }}"></script> <script src="{{ static("common/sweetalert/zlalert.js") }}"></script>

(3)cms/js/resetpwd.js

代码语言:javascript
复制
/** * Created by derek on 2018/6/3. */ $(function () { $("#submit").click(function (event) { //阻止按钮的提交表单的事件 event.preventDefault(); //分别获取三个标签 var oldpwdE = $("input[name=oldpwd]"); var newpwdE = $("input[name=newpwd]"); var newpwd2E = $("input[name=newpwd2]"); var oldpwd = oldpwdE.val(); var newpwd = newpwdE.val(); var newpwd2 = newpwd2E.val(); //1.要在模板的meta标签中渲染一个csrf-token //2.在ajax请求的头部汇总设置X-CSRFtoken zlajax.post({ 'url':'/cms/resetpwd', 'data':{ 'oldpwd':oldpwd, 'newpwd':newpwd, 'newpwd2':newpwd2 }, 'success':function (data) { if (data['code'] == 200){ zlalert.alertSuccessToast("恭喜!密码修改成功!"); oldpwd.val(''); newpwd.val(''); newpwd2.val(''); }else { var message = data['message']; zlalert.alertInfo(message); } }, 'fail':function (error) { zlalert.alertNetworkError(error); } }); }); });

修改密码弹出的信息

旧密码输错的提示信息

官方客服

LIKE.TG汇集全球营销软件&服务,助力出海企业营销增长。提供最新的“私域营销获客”“跨境电商”“全球客服”“金融支持”“web3”等一手资讯新闻。

点击【联系客服】 🎁 免费领 1G 住宅代理IP/proxy, 即刻体验 WhatsApp、LINE、Telegram、Twitter、ZALO、Instagram、signal等获客系统,社媒账号购买 & 粉丝引流自助服务或关注【LIKE.TG出海指南频道】【LIKE.TG生态链-全球资源互联社区】连接全球出海营销资源。


Banner广告
Banner广告
Banner广告
Banner广告
全球峰会
Server deployment