需求背景
用戶掃碼二維碼,獲得了一串數字,彈框提示是否對這串數字操作
確認,調用2個接口,取消,不做操作
知識點
my.scan調用掃碼功能
res.code是掃碼結果
my.confirm還確認和取消的彈框
result.confirmtrue 用戶點擊了確認
esult.confirmfalse 用戶點擊了取消
源碼如下
scan() {
my.scan({
scanType: ['qrCode','barCode'],
success: (res) => {
my.confirm({
// title: '溫馨提示',
content: '您是否確認將'+res.code+"歸檔到您名下",
confirmButtonText: '確認',
cancelButtonText: '取消',
success: (result) => {
if(result.confirm==true){
var searchUrl = this.data.baseUrl+'/beauty/updateMobileInfo?owner=test111&mobileNo='+res.code;
this.getRequest(searchUrl);
this.getMobileListData(this.data.baseUrl+"/beauty/getMobile");
}else if (result.confirm==false){
console.log("用戶已取消"+result.confirm)
}
}
});
},
});
}