wx.showToast 延时跳转~~~

本文介绍了一个使用微信小程序实现预约订单提交的例子。通过调用wx.request接口发送POST请求到指定URL,并传递订单数据。根据服务器返回的状态值判断预约是否成功,并利用wx.showToast和wx.switchTab进行反馈和页面跳转。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

另外,在内页做页面跳转需要用wx.switchTab。

Good luck!

转载于:https://www.cnblogs.com/pansidong/p/7651159.html

Page({ data: { src: '', base64: "", baidutoken: "", msg: null }, //拍照并编码 takePhoto() { var that = this; //拍照 const ctx = wx.createCameraContext() ctx.takePhoto({ quality: 'high', success: (res) => { that.setData({ src: res.tempImagePath }) //图片base64编码 wx.getFileSystemManager().readFile({ filePath: that.data.src, //选择图片返回的相对路径 encoding: 'base64', //编码格式 success: res => { //成功的回调 that.setData({ base64: res.data }) that.checkPhoto(); } }) } }) wx.showToast({ title: '请重试', icon: 'loading', duration: 500 }) }, error(e) { console.log(e.detail) }, checkPhoto() { var that = this; //acess_token获取 wx.request({ url: 'https://aip.baidubce.com/oauth/2.0/token', //真实的接口地址 data: { grant_type: 'client_credentials', client_id: 'xxxxxxxxxxxxxxxxxxxxxxxxxx', //用你创建的应用的API Key client_secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxx' //用你创建的应用的Secret Key }, header: { 'Content-Type': 'application/json' // 默认值 }, success(res) { that.setData({ baidutoken: res.data.access_token //获取到token }) that.validPhoto(); } }) }, validPhoto() { var that = this; //上传人脸进行 比对 wx.request({ url: 'https://aip.baidubce.com/rest/2.0/face/v3/search?access_token=' + that.data.baidutoken, method: 'POST', data: { image: this.data.base64, image_type: 'BASE64', group_id_list: 'xh_0713', //自己建的用户组id }, header: { 'Content-Type': 'application/json' // 默认值 }, success(res) { that.setData({ // msg: res.data.result.user_list[0].score msg: res.data.error_msg }) //做成功判断 if (that.data.msg == "pic not has face") { wx.showToast({ title: '未捕获到人脸', icon: 'error', }) } if (that.data.msg == 'SUCCESS') { if(res.data.result.user_list[0].score>80){ wx.showToast({ title: '人脸识别成功', icon: 'success', }) }else{ wx.showToast({ title: '人脸识别失败', icon: 'error', }) } } } }); } }) 增加识别成功后跳转至原页面的代码
04-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值