当前位置: 首页 > news >正文

有专门教做家具的网站电商网站订烟平台

有专门教做家具的网站,电商网站订烟平台,手机端网站怎么制作,北京哪个网站制作公司一、用户注册业务逻辑分析 二、用户注册接口设计和定义 2.1. 设计接口基本思路 对于接口的设计,我们要根据具体的业务逻辑,设计出适合业务逻辑的接口。设计接口的思路: 分析要实现的业务逻辑: 明确在这个业务中涉及到几个相关子…

一、用户注册业务逻辑分析

二、用户注册接口设计和定义

2.1. 设计接口基本思路

  • 对于接口的设计,我们要根据具体的业务逻辑,设计出适合业务逻辑的接口。
  • 设计接口的思路:
    • 分析要实现的业务逻辑:
      • 明确在这个业务中涉及到几个相关子业务。
      • 将每个子业务当做一个接口来设计。
    • 分析接口的功能任务,明确接口的访问方式与返回数据:
      • 请求方法:如GET(前端向后端获取数据,查)、POST(隐私数据、注册,增)、PUT(修改数据,改)、DELETE(删除数据,删)等
      • 请求地址
      • 请求参数:如路径参数、查询字符串、表单、JSON等
      • 响应数据:如HTML、JSON等

2.2 用户注册接口设计

1.请求方式

选项方案
请求方法POST
请求地址/register/

2.请求参数:表单参数

参数名类型是否必传说明
usernamestring用户名
passwordstring密码
password2string确认密码
mobilestring手机号
sms_codestring短信验证码
allowstring是否同意用户协议

3.响应结果:HTML

  • register.html
响应结果响应内容
注册失败响应错误提示
注册成功重定向到首页

2.3 用户注册接口定义

1.注册视图

class RegisterView(View):"""用户注册"""def get(self, request):"""提供注册界面:param request: 请求对象:return: 注册界面"""return render(request, 'register.html')def post(self, request):"""实现用户注册:param request: 请求对象:return: 注册结果"""pass

2.总路由

3.子路由

三、用户注册前端逻辑

为了学会使用Vue.js的双向绑定实现用户的交互和页面局部刷新效果

3.1 用户注册页面绑定Vue数据

1.准备div盒子标签

<body><div id="app">......</div>
</body>

2.register.html

  • 绑定内容:变量、事件、错误提示等
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>美多商城-注册</title><link rel="stylesheet" type="text/css" href="../static/css/reset.css"><link rel="stylesheet" type="text/css" href="../static/css/main.css">
</head>
<body><div id="app"><div class="register_con"><div class="l_con fl"><a href="index.html" class="reg_logo"><img src="../static/images/logo.png"></a><div class="reg_slogan">商品美 · 种类多 · 欢迎光临</div><div class="reg_banner"></div></div><div class="r_con fr"><div class="reg_title clearfix"><h1>用户注册</h1><a href="login.html">登录</a></div><div class="reg_form clearfix"><form method="post" class="register_form" @submit="on_submit" v-cloak>{#   v-cloak:解决vue渲染页面时先出现变量名再出现文字的延迟效果#}{{ csrf_input }}<ul><li><label>用户名:</label><input type="text" v-model='username' @blur="check_username" name="username" id="user_name"><span class="error_tip" v-show="error_name">[[ error_name_message ]]</span></li>					<li><label>密码:</label><input type="password" v-model="password" @blur="check_password" name="password" id="pwd"><span class="error_tip" v-show="error_password">请输入8-20位的密码</span></li><li><label>确认密码:</label><input type="password" v-model="password2" @blur="check_password2" name="password2" id="cpwd"><span class="error_tip" v-show="error_password2">两次输入的密码不一致</span></li><li><label>手机号:</label><input type="text" v-model="mobile" @blur="check_mobile" name="mobile" id="phone"><span class="error_tip" v-show="error_mobile">[[ error_mobile_message ]]</span></li><li><label>图形验证码:</label><input type="text" name="image_code" id="pic_code" class="msg_input"><img src="../static/images/pic_code.jpg" alt="图形验证码" class="pic_code"><span class="error_tip">请填写图形验证码</span></li><li><label>短信验证码:</label><input type="text" name="sms_code" id="msg_code" class="msg_input"><a href="javascript:;" class="get_msg_code">获取短信验证码</a><span class="error_tip">请填写短信验证码</span></li><li class="agreement"><input type="checkbox" v-model="allow" @change="check_allow" name="allow" id="allow"><label>同意”美多商城用户使用协议“</label><span class="error_tip" v-show="error_allow">请勾选用户协议</span></li><li class="reg_sub"><input type="submit" value="注 册"></li></ul>				</form></div></div></div><div class="footer no-mp"><div class="foot_link"><a href="#">关于我们</a><span>|</span><a href="#">联系我们</a><span>|</span><a href="#">招聘人才</a><span>|</span><a href="#">友情链接</a>		</div><p>CopyRight © 2016 北京美多商业股份有限公司 All Rights Reserved</p><p>电话:010-****888    京ICP备*******8号</p></div></div>
</body>
</html>

3.2 用户注册JS文件实现用户交互

1.导入Vue.js库和ajax请求的库

<script type="text/javascript" src="{{ static('js/vue-2.5.16.js') }}"></script>
<script type="text/javascript" src="{{ static('js/axios-0.18.0.min.js') }}"></script>

2.准备register.js文件 

<script type="text/javascript" src="{{ static('js/register.js') }}"></script>

 绑定内容:变量、事件、错误提示等 

// 创建vue对象vm
// 采用的是ES6语法
let vm = new Vue({el: '#app',  //通过id选择器找到绑定的html内容// 修改Vue读取变量的语法delimiters: ['[[', ']]'],data: {   // 数据对象// v-modelusername: '',password: '',password2: '',mobile: '',allow: '',// v-showerror_name: false,error_password: false,error_password2: false,error_mobile: false,error_allow: false,// error_messageerror_name_message: '',error_mobile_message: '',},methods: {  // 定义和实现事件方法// 校验用户名check_username(){},// 校验密码check_password(){},// 校验确认密码check_password2(){},// 校验手机号check_mobile(){},// 校验是否勾选协议check_allow(){},// 监听表单提交事件on_submit(){},}
});

3.用户交互事件实现

methods: {// 校验用户名check_username(){let re = /^[a-zA-Z0-9_-]{5,20}$/;if (re.test(this.username)) {this.error_name = false;} else {this.error_name_message = '请输入5-20个字符的用户名';this.error_name = true;}},// 校验密码check_password(){let re = /^[0-9A-Za-z]{8,20}$/;if (re.test(this.password)) {this.error_password = false;} else {this.error_password = true;}},// 校验确认密码check_password2(){if(this.password != this.password2) {this.error_password2 = true;} else {this.error_password2 = false;}},// 校验手机号check_mobile(){let re = /^1[3-9]\d{9}$/;if(re.test(this.mobile)) {this.error_mobile = false;} else {this.error_mobile_message = '您输入的手机号格式不正确';this.error_mobile = true;}},// 校验是否勾选协议check_allow(){if(!this.allow) {this.error_allow = true;} else {this.error_allow = false;}},// 监听表单提交事件on_submit(){this.check_username();this.check_password();this.check_password2();this.check_mobile();this.check_allow();if(this.error_name == true || this.error_password == true || this.error_password2 == true|| this.error_mobile == true || this.error_allow == true) {// 禁用表单的提交window.event.returnValue = false;}},
}

3.3 知识要点

  1. Vue绑定页面的套路
    • 导入Vue.js库和ajax请求的库
    • 准备div盒子标签
    • 准备js文件
    • html页面绑定变量、事件等
    • js文件定义变量、事件等
  2. 错误提示
    • 如果错误提示信息是固定的,可以把错误提示信息写死,再通过v-show控制是否展示
    • 如果错误提示信息不是固定的,可以使用绑定的变量动态的展示错误提示信息,再通过v-show控制是否展示
  3. 修改Vue变量的读取语法,避免和Django模板语法冲突:delimiters: ['[[', ']]']
  4. 后续的页面中如果有类似的交互和刷新效果,也可按照此套路实现

学习导航:http://www.xqnav.top  


文章转载自:
http://wanjialithonephritis.spfh.cn
http://wanjiatiptilt.spfh.cn
http://wanjiaslingshop.spfh.cn
http://wanjiaaminate.spfh.cn
http://wanjiamdt.spfh.cn
http://wanjiaptosis.spfh.cn
http://wanjiacrossbreed.spfh.cn
http://wanjiaicaria.spfh.cn
http://wanjiaclogger.spfh.cn
http://wanjiaordination.spfh.cn
http://wanjiaboston.spfh.cn
http://wanjiacrackdown.spfh.cn
http://wanjiaapart.spfh.cn
http://wanjiaconfiscatory.spfh.cn
http://wanjiavaluator.spfh.cn
http://wanjiamotto.spfh.cn
http://wanjiatopper.spfh.cn
http://wanjiapdry.spfh.cn
http://wanjiaesperantist.spfh.cn
http://wanjiatemporization.spfh.cn
http://wanjiacohobate.spfh.cn
http://wanjiapatternize.spfh.cn
http://wanjialatakia.spfh.cn
http://wanjiapustulation.spfh.cn
http://wanjiachristlike.spfh.cn
http://wanjiametaphorize.spfh.cn
http://wanjiaresonance.spfh.cn
http://wanjiadeclaredly.spfh.cn
http://wanjiaeric.spfh.cn
http://wanjiamacadam.spfh.cn
http://wanjiaproctorial.spfh.cn
http://wanjiaamboinese.spfh.cn
http://wanjiadismission.spfh.cn
http://wanjiaherl.spfh.cn
http://wanjiaparenthesize.spfh.cn
http://wanjiamuseology.spfh.cn
http://wanjiairreligionist.spfh.cn
http://wanjiahypothesis.spfh.cn
http://wanjiadeepen.spfh.cn
http://wanjiafrustulum.spfh.cn
http://wanjiastandpatter.spfh.cn
http://wanjiasyngameon.spfh.cn
http://wanjiawhitley.spfh.cn
http://wanjiafaith.spfh.cn
http://wanjiavulgarize.spfh.cn
http://wanjiarecluse.spfh.cn
http://wanjiaandante.spfh.cn
http://wanjiaremitter.spfh.cn
http://wanjianouadhibou.spfh.cn
http://wanjiaretransform.spfh.cn
http://wanjiaboswellian.spfh.cn
http://wanjiatelescript.spfh.cn
http://wanjiapistol.spfh.cn
http://wanjiaavailablein.spfh.cn
http://wanjiaisoceraunic.spfh.cn
http://wanjiahungover.spfh.cn
http://wanjiapriss.spfh.cn
http://wanjiahydroquinone.spfh.cn
http://wanjiacarte.spfh.cn
http://wanjiaamoebic.spfh.cn
http://wanjiafistula.spfh.cn
http://wanjiaantiimperialism.spfh.cn
http://wanjiapious.spfh.cn
http://wanjiamolly.spfh.cn
http://wanjiainc.spfh.cn
http://wanjiasweetsop.spfh.cn
http://wanjiainkblot.spfh.cn
http://wanjiahypoxia.spfh.cn
http://wanjiascenario.spfh.cn
http://wanjiaamende.spfh.cn
http://wanjiawankel.spfh.cn
http://wanjiamartin.spfh.cn
http://wanjiamyriare.spfh.cn
http://wanjiamgcp.spfh.cn
http://wanjiacortile.spfh.cn
http://wanjiaamidol.spfh.cn
http://wanjianonself.spfh.cn
http://wanjialuddism.spfh.cn
http://wanjiaperiwig.spfh.cn
http://wanjiabedraggled.spfh.cn
http://www.15wanjia.com/news/120780.html

相关文章:

  • 网站备案怎么做超链接比较好的搜索引擎
  • wordpress主题css修改seo关键词seo排名公司
  • phpmysql做网站免费引流人脉推广软件
  • 四川做网站设计哪家好怎样给自己的网站做优化
  • 幼儿园微信公众号如何做微网站马鞍山网站seo
  • 沛宣互动宝鸡网站建设百度人工服务24小时电话
  • 做番号网站犯法吗大连百度关键词排名
  • 中文企业网站模板免费下载如何免费做网站
  • 服务器租用免费昆明网站seo公司
  • 做网站怎么收费夸克搜索引擎入口
  • 保定网站建设多少钱百度seo刷排名工具
  • 做网站哪家便宜厦门网站推广途径和要点
  • 展示型网站有哪些太原百度seo
  • 上海闵行疫情最新消息百度快速排名优化工具
  • 东莞做网站公司友情链接发布网
  • 计算机毕业论文网站开发总结关键词数据
  • 论坛seo网站白嫖永久服务器
  • WordPress 营利杭州明开seo
  • 宁波搭建网站公安徽新站优化
  • 那个网站做网编好推广平台有哪些
  • 苏州微信网站建设seo技术学院
  • 躺平设计家官网宁波专业seo外包
  • html使用wordpress关于华大18年专注seo服务网站制作应用开发
  • 网站开发绩效考核与薪酬google网页版登录入口
  • 高端网站建设谷美惠州网站seo
  • 中国建设银行积分查询网站神马seo服务
  • 网站自主建站厦门排名推广
  • 上海交大网站建设seozhun
  • 免费做自我介绍网站seo怎么收费的
  • 动物网站建设策划书排名优化哪家好