//扫码点击事件
scanCode(){
var that = this
uni.scanCode({
scanType:['qrCode'],
success: function (response) {
console.log('条码类型:' + response.scanType);
//加入response.result是:https://fish2.ygostyle.com/uploads/discount/shaiyu_226.png
console.log('条码内容:' + response.result);
const index = response.result.lastIndexOf('/')
const imgName = response.result.substr(index + 1)
const xianIndex = imgName.indexOf('_')
const pointIndex = imgName.indexOf('.')
const id = imgName.slice(xianIndex + 1, pointIndex)
that.$request.post('/api/PlaceDiscount/writeoff', {
token:uni.getStorageSync('token'), id
}).then(res => {
uni.showToast({
icon:'none',
title:res.msg
})
})
},
fail(res) {
uni.showToast({
icon:'none',
title:'扫码失败'
})
}
});
}
小程序扫码识别
最新推荐文章于 2024-08-04 20:07:09 发布