const base64 = require("../../utils/base64.js");
var app = getApp();
Page({
data:{
banquan: app.globalData.banquan,
ip: '',
show_r: '',
show_img: 'yes',
imageBase64Str: '',
location: '',
height: '100%',
},
banquan: function () {
},
queryIp: function (res,options) {
let that = this;
// 允許從相機和相冊掃碼
wx.scanCode({
success(res) {
console.log(res);
var location_text = "";
if (res.result == "*" || res.result == ""){
location_text = "【解碼后內容】:" + base64.decode(res.rawData);
}else{
location_text = "【解碼后內容】:" + res.result;
}
location_text = location_text + "\r\n\n【解碼型別】:" + res.scanType;
if (res.scanType == "QR_CODE" || res.scanType == "DATA_MATRIX" || res.scanType == "PDF_417"){
location_text = location_text+"(二維碼)";
} else if (res.scanType == "WX_CODE"){
location_text = location_text + "(小程式碼)";
}else{
location_text = location_text + "(一維碼)";
}
location_text = location_text + "\r\n\n【字符集】:" + res.charSet;
if (res.path != "undefined" && res.path != "" && res.path != null ){
location_text = location_text + "\r\n\n【Path】:" + res.path;
}
location_text = location_text + "\r\n\n【貨架號】:" + getNo;
that.setData({
show_r: 'yes',
show_img: '',
location: location_text,
})
},
//取當前頁面的值
fail(res) {
console.log(res);
/*that.setData({
show_r: 'yes',
show_img: '',
location: "識別錯誤:\r\n" + res.errMsg
})*/
},
complete(res) {
},
})
},
請教各位大牛,我如何在當前頁面取掃碼后的結果,就是將“ res.result”當做變數,取到后進行云資料庫的查詢。
uj5u.com熱心網友回復:
通過http或者ajax請求 將你掃描的結果傳遞到后臺server,再通過后臺sever和你的云端資料庫互動 查詢,查詢完將結果回傳給前端頁面顯示uj5u.com熱心網友回復:
原理是這么回事,怎么在頁面取資料呢?將res.result的結果生成一個新的物件?轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/195488.html
標籤:微信開發
