camera 实现扫码枪功能 IOS 调用不了扫码功能 急急急急!
发布于 6 年前 作者 ccao 8973 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)
  • 预期表现
  • 复现路径
  • 提供一个最简复现 Demo

安卓机上可以  正常调用 扫码功能

在IOS  上面 调用不起来 扫码功能    

而且  在真机测试的时候   也是可以调用的     单页编辑 是可以调用的

唯独在  项目打包情况下  调用不了    已经授权

<!–pages/moduleStandingBook/scanCode/scanCode.wxml–>

<camera

class=‘camera_class’

mode=“scanCode” flash=“off”

binderror=“error”

bindscancode=‘canCode’

style=“width: {{WindowWidth}}px; height: {{WindowHeight}}px;”

scan-area="[0,0,200, 200]">

<cover-view class=‘fcenter’ style=‘width:{{WindowWidth*0.8}}px; height: {{WindowHeight*0.9}}px;’>

<cover-view class=‘sYt’>

<cover-view class=‘flex-wf’>

<cover-view>

商品数量:{{reqData.number}}

</cover-view>

<cover-view>

扫码数量:{{textList.length}}

</cover-view>              

</cover-view>    

<!-- <cover-view class=‘flex-wf’ wx:for=’{{textList}}’>

       <cover-view style=‘flex:1’>{{item}}</cover-view>    

       <cover-view style=‘width:25%;padding:10rpx 0 10rpx 20rpx’ bindtap=‘Delete’ data-index=’{{index}}’ >删除</cover-view>    

     </cover-view> -->

</cover-view>

<!-- <cover-view class=‘delete’>

     <cover-view style=‘width:25%’ bindtap=‘empty’ class=‘empty’ wx:if=’{{textList.length!=0}}’>清空</cover-view>

     <cover-view style=‘flex:1’></cover-view>    

   </cover-view>     -->

<cover-view class=‘kang’>

</cover-view>

<cover-view class=‘btm’>

<cover-view class=‘btm-center’ bindtap=‘updata’>结束扫码</cover-view>

</cover-view>

</cover-view>

<!--   弹出层   -->

</camera>

// pages/moduleStandingBook/scanCode/scanCode.js

const app = getApp();

var demand = require(’…/…/…/utils/util.js’);

var innerAudioContext = wx.createInnerAudioContext();

innerAudioContext.src = app.globalData.videoTs + “/4204.mp3”;

Page({

data: {

WindowWidth: app.globalData.WindowWidth,

WindowHeight: app.globalData.WindowHeight,

textList:[],

lisn:false,

},

Delete(e){

console.log(‘清除单个’,e)

let index = e.currentTarget.dataset.index

let text = this.data.textList

text.splice(index,1)

this.setData({ textList: text})

},

empty(e){

console.log(‘清除数组’)

this.setData({ textList: []})

},

/**

  * 生命周期函数–监听页面加载

  */

onLoad: function (options) {

console.log(app.globalData.videoTs + “/4204.mp3”)

},

error(e){

console.log(e)

console.log(‘哦错了’)

},

canCode(e){

// innerAudioContext.play();

if (this.data.lisn == false) {

this.setData({ lisn: true })

let text = this.data.textList

console.log(‘运行了’,e)

innerAudioContext.play();

var str = e.detail.result

var temp = “”

var strusult = “”

var show = false

for (var i = 0; i < str.length; i++) {

if (str[i] >= “0” && str[i] <= “9”) {

temp += str[i]

if (temp.length == 32) {

strusult = temp

show = true

}

} else {

temp = “”

}

}

if (show) {

text.push({ code: strusult.substring(1, 7) })

} else {

text.push({ code: e.detail.result })

}

innerAudioContext.onEnded(()=>{

this.setData({

textList: text,

lisn: false

})

}

)

}else{

console.log(‘稍等’)

}

// e.detail.result

},

updata(e){

if (this.data.textList.length<3){

wx.showModal({

title: ‘提示’,

content: ‘扫码数量(1)小于商品数量(3),确定结束扫描’,

success(res){

if (res.confirm) {

console.log(‘用户点击确定’)

demand.jump(’…/purchasereturnlist/purchasereturnlist?type=’ + ‘stock’)

} else if (res.cancel) {

console.log(‘用户点击取消’)

}

}

})

}else{

let data = this.data.reqData

data.sweepcode = this.data.textList,

data.codenumber = this.data.textList.length

// demand.alertK(‘暂无对接接口’,‘none’)

demand.saveData(‘codelist’,this.data.textList)

demand.req(’/api/shop-stock/Instockorder’, ‘post’, data).then((res) => {

console.log(res)

if (res.code == 200) {

demand.alertK(‘成功’, ‘none’)

this.setData({

carList: [],

totalPrice: 0,

nums: 0,

codenumber: 0,

isCheckedAll:false,

orderid: res.element,                                 // 入库单id

})

demand.jump(’…/purchasereturnlist/purchasereturnlist?type=’ + ‘stock’)

} else {

demand.alertK(res.msg, ‘none’)

}

})

}

},

/**

    * 生命周期函数–监听页面初次渲染完成

    */

onReady: function () {

},

/**

    * 生命周期函数–监听页面显示

    */

onShow: function () {

let that = this

wx.getStorage({

key: ‘carlist’,

success: function(res) {

console.log(res)

that.setData({

reqData:res.data

})

},

})

},

/**

  * 生命周期函数–监听页面隐藏

  */

onHide: function () {

},

/**

  * 生命周期函数–监听页面卸载

  */

onUnload: function () {

},

/**

  * 页面相关事件处理函数–监听用户下拉动作

  */

onPullDownRefresh: function () {

},

/**

  * 页面上拉触底事件的处理函数

  */

onReachBottom: function () {

},

/**

  * 用户点击右上角分享

  */

onShareAppMessage: function () {

}

})

1 回复

麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部