tnblog
首页
视频
资源
登录

微信小程序发送验证码

2707人阅读 2022/11/15 18:20 总访问:16926 评论:0 收藏:0 手机
分类: 技术


先在js中定义方法


post()的部分引入写好api



开始引入js的方法



获取验证码

绑定

 async getUserBind() {

var _this=this;

if(!_this.phoneNum){

_this.$yy.showToast('请输入手机号');

return;

}

if(!_this.verificationCode){

_this.$yy.showToast('请输入验证码');

return;

}

const retuMsg= await getBind({

  Phone:_this.phoneNum,WXOpenId:"",XCXOpenId:_this.xcxOpenId,Validate:_this.verificationCode

  }).catch((err)=>{

_this.$yy.showToast("绑定失败",err); 

  });

if(retuMsg){

_this.$yy.setStorage("USER", retuMsg);

uni.$u.route('/pages/index/home');

}

},

获取小程序的ID

getXCXOpenId() { //获取小程序OpenId

var _this = this;

wx.login({

success: async result => {·

if (result.code) {

console.log("xcxcode:" + result.code);


const res = await getXCXOpenId({

Code: result.code

}).catch((err) => {

console.log("请求失败:", err);

});

console.log(res);

if (res) {

_this.xcxOpenId = res.openid;

const retuRes= await selectSingleByWhere({

XCXOpenId: 'EQ|' + res.openid,

}).catch((err)=>{

console.log("onload Query xxOpenId Error",err);

});

if(retuRes){

_this.$yy.setStorage("USER", retuRes);

uni.$u.route('/pages/index/home');

}

}

}

}

});

},


评价
我没有个性,不需要那些花里胡哨的东东
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2024TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
欢迎加群交流技术