uni.scanCode({
scanType: ['qrCode'],
success: (res) => {
console.log(res);
let deviceId=res.result;
REQUEST_UTIL.post('getDeviceForSet',{deviceId:deviceId},function(res){
let result=res.data;
if(result.code==200){
try {
let curDevice=result.data;
if(curDevice){
if(curDevice['deviceType'].indexOf("-")>0){
uni.setStorageSync(APP_CONSTANT.DEVICE_LEVEL,2);
}else{
uni.setStorageSync(APP_CONSTANT.DEVICE_LEVEL,1);
}
uni.setStorageSync(APP_CONSTANT.KEY_DEVICE,JSON.stringify(curDevice));
that.deviceService.setMac(curDevice['deviceMac']);
yyppSqlite.selectCourseByType(1).then(function(_courseList) {
console.log(_courseList);
for(let tempCourse of _courseList){
yyppSqlite.deleteCourse(tempCourse['id']).then(function(){});
}
}, function(error) {
console.log(error);
});
uni.showToast({
title: '二维码识别成功',
icon: 'none'
});
setTimeout(function(){
that.changeCourseType(1);
},2000)
}else{
uni.showToast({
title: '二维码识别异常',
icon: 'none'
});
}
}catch(err) {
console.log(err);
}
}else{
uni.showToast({
title: '系统错误',
icon: 'none'
});
}
},function(){
uni.showToast({
title: '系统错误',
icon: 'none'
});
})
},
fail: (err) => {
// 需要注意的是小程序扫码不需要申请相机权限
}
});