function Scan() {
wx.scanQRCode({
needResult: 1,
// 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
scanType: [
"qrCode"
,
"barCode"
],
// 可以指定扫二维码还是一维码,默认二者都有
success: function (res) {
var
serialNumber = res.resultStr;
// 当needResult 为 1 时,扫码返回的结果
var
serial = serialNumber.split(
","
);
serialNumber = serial[serial.length-1];
$(
"#serialNumber"
).val(serialNumber);
$(
"#serialNumber"
).attr(
"readonly"
,
"readonly"
);
$(
"#serialNumber"
).removeAttr(
"readonly"
);
GetItemInstancesBySerialNumber(serialNumber);
}
});
}
https://www.cnblogs.com/yangfan5157/p/6030329.html
https://developers.weixin.qq.com/miniprogram/dev/api/device/scan/wx.scanCode.html
getScancode: function () {
var _this = this;
// 允许从相机和相册扫码
wx.scanCode({
success: (res) => {
var result = res.result;
var scanType = res.scanType;
var charSet = res.charSet;
var path = res.path;
_this.setData({
result: result,
scanType: scanType,
charSet: charSet,
path: path
})
}
})
}
---------------------
https://blog.csdn.net/qq_31984879/article/details/83991320
var _this = this;
// 允许从相机和相册扫码
wx.scanCode({
success: (res) => {
var result = res.result;
var scanType = res.scanType;
var charSet = res.charSet;
var path = res.path;
_this.setData({
result: result,
scanType: scanType,
charSet: charSet,
path: path
})
}
})
}
---------------------
https://blog.csdn.net/qq_31984879/article/details/83991320
success: function (res) {
var result = JSON.parse(res); //这里把json类型的res转换成对象 if(result.needResult == 1) { alert('nice!'); } }
First of all, your
res
data is and what type? If
json
format, use
JSON.parse
was further continued operation of the converter into an object.
With micro-channel debugger, console.log () print result numerical analysis
First of all, your
res
data is and what type? If
json
format, use
JSON.parse
was further continued operation of the converter into an object.