//扫码条形码
sanstock: function () {
const that = this;
wx.scanCode({
onlyFromCamera: true,
success: (res) => {
//通过正则判断是否条形码返回的是否为一个数字
var re = /^[0-9]+.?[0-9]*$/;
if(!re.test(res.result)){
wx.showToast({
title:'请扫描条形码'
})
return
}
// wx.navigateTo({
// url: '/packageThirst/pages/cacher/addstock/index?shopcode=' + res.result
// })
that.clearShopInfo();
that.setData({
shopcode: res.result
})
//根据条形码获取平台的商品数据
that.getgoodsbycode(res.result)
}
})
}