如果在瑞吉外卖短信验证码最初阶段遇到点击获取验证码没有响应或者没有发送/sendMsg地址的时候可以通过以下操作
修改login.html中getCode方法
this.msgFlag = false
//注释这段代码 这段是自动生成数字的代码
// this.form.code = (Math.random()*1000000).toFixed(0)
//新增方法 在方法里实现响应
sendMsgApi({phone:this.form.phone})
然后添加sendMsgApi方法在login.js中(front/api/login.js)
function sendMsgApi(data) {
return $axios({
'url': '/user/sendMsg', //请求的路径
'method': 'post', //请求的方式
data //参数
})
}
然后修改login.html中btnLogin()方法
this.loading = true
//注释掉这个 因为这里只传一个参数 后台应该需要两个
//const res = await loginApi({phone:this.form.phone})
//添加这个 form里面包括了phone和code
const res = await loginApi(this.form)
this.loading = false
然后跟着老师写UserController中的代码即可
如果还不行,请检查一下后台对应的路径代码,以及是否有注释没加