Commit adaa7a9a by wangyalan-git

扫码测试

parent b1e5167b
...@@ -57,7 +57,7 @@ export default { ...@@ -57,7 +57,7 @@ export default {
methods: { methods: {
init () { init () {
window.qing.config({ window.qing.config({
debug: true, debug: false,
// 声明需要调用的API // 声明需要调用的API
jsApiList: ['scanQRCode'] jsApiList: ['scanQRCode']
// 声明需要监听的事件,声明后可通过 document.addEventListener 绑定监听函数 // 声明需要监听的事件,声明后可通过 document.addEventListener 绑定监听函数
...@@ -70,50 +70,31 @@ export default { ...@@ -70,50 +70,31 @@ export default {
window.qing.call('scanQRCode', { window.qing.call('scanQRCode', {
needResult: 1, needResult: 1,
success: function (result) { success: function (result) {
alert('成功' + result.data.qrcode_str)
const data = JSON.parse(result.data.qrcode_str) const data = JSON.parse(result.data.qrcode_str)
checkQcode(data).then(res => { checkQcode(data).then(res => {
console.log('校验结果', res) console.log('校验结果', res)
alert('校验结果' + res)
getMemberInfo({ memberId: data.memberId }).then(res => { getMemberInfo({ memberId: data.memberId }).then(res => {
console.log('userId', res) console.log('userId', res)
that.userInfo = res.data that.userInfo = res.data
alert('userInfo' + res.data)
}) })
}) })
alert('数据2' + that.userInfo)
console.log('成功', result)
}, },
error: function (res) { error: function (res) {
alert('失败' + res) console.log('res', res)
} }
}) })
// const result = '{"onlyId":"056e3cf540194041bd5a2eadf91301b6","memberId":36}'
// const data = JSON.parse(result)
// checkQcode(data).then(res => {
// console.log('校验结果', res)
// getMemberInfo({ memberId: data.memberId }).then(res => {
// this.userInfo = res.data
// console.log('userId', this.userInfo)
// })
// })
// console.log('成功', result)
}, },
// 物品条形码扫描 // 物品条形码扫描
scanBarCode () { scanBarCode () {
/* eslint-disable */ /* eslint-disable */
// if (JSON.stringify(this.userInfo) == '{}') { if (JSON.stringify(this.userInfo) == '{}') {
// this.$toast.fail('请先扫描员工二维码') this.$toast.fail('请先扫描员工二维码')
// return return
// } }
let that = this
window.qing.call('scanQRCode', { window.qing.call('scanQRCode', {
needResult: 1, needResult: 1,
success: function (result) { success: function (result) {
alert('物品'+ result.data.qrcode_str)
// const data = JSON.parse(result.data.qrcode_str)
// result.data = '{"barCode":"f7c3af254e5a40caaf7dab1b06fd7a1c","memberId":53}'
// const data = JSON.parse(result.data)
getGoodsInfo({ barCode: result.data.qrcode_str }).then(res => { getGoodsInfo({ barCode: result.data.qrcode_str }).then(res => {
let data = res.data let data = res.data
let params = { let params = {
...@@ -125,40 +106,20 @@ export default { ...@@ -125,40 +106,20 @@ export default {
goodsNum: 1, goodsNum: 1,
maxNum: data.goodsNum maxNum: data.goodsNum
} }
let isExist = this.list.findIndex(item => let isExist = that.list.findIndex(item =>
item.id === data.id item.id === data.id
) )
if (isExist === -1) { if (isExist === -1) {
this.list.push(params) that.list.push(params)
} else { } else {
this.list[isExist].goodsNum = this.list[isExist].goodsNum + 1 that.list[isExist].goodsNum = that.list[isExist].goodsNum + 1
} }
console.log('要出库的商品', this.list) console.log('要出库的商品', that.list)
}) })
} }
}) })
// getGoodsInfo({ barCode: result.data.qrcode_str}).then(res => {
// let data = res.data
// let params = {
// id: data.id,
// name: data.name,
// goodsNo: data.goodsNo,
// goodsCategoryId: data.goodsCategoryId,
// goodsCategoryName: data.goodsCategoryName,
// goodsNum: 1,
// maxNum: data.goodsNum
// }
// let isExist = this.list.findIndex(item =>
// item.id === data.id
// )
// if (isExist === -1) {
// this.list.push(params)
// } else {
// this.list[isExist].goodsNum = this.list[isExist].goodsNum + 1
// }
// console.log('要出库的商品', this.list)
// })
}, },
// 数量修改 // 数量修改
changeNum (value, id) { changeNum (value, id) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment