收藏
回答

camera 实现扫码枪功能 IOS 调用不了扫码功能 急急急急!

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug camera 客户端 7.0.3 v1.02.1902010

- 当前 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 个回答

  • 灵芝
    灵芝
    2019-04-18

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

    2019-04-18
    有用
    回复 15
    • ￴
      2019-04-18

      https://developers.weixin.qq.com/s/DdKuGIm67V7k


      2019-04-18
      回复
    • 灵芝
      灵芝
      2019-04-18回复

      这边测试是正常的


      2019-04-18
      回复
    • ￴
      2019-04-18回复灵芝

      我单页测试也是正常的  但是把项目编译后   IOS 的  两个机型   都不能  调起canCode方法

      2019-04-18
      回复
    • ￴
      2019-04-18回复灵芝

      我  单页 、   真机 、 都是正常的;  安卓机型   都是可以的   ;

      但是

      在项目打包之后  、  在IOS  机型下、  不起作用;安卓机型  没有问题

      2019-04-18
      回复
    • 灵芝
      灵芝
      2019-04-18回复

      麻烦提供一下日志:我->设置->帮助与反馈右上角有个上报日志的入口
      提供一下出现问题的微信号,出现问题的时间点(精确到分钟)

      2019-04-18
      回复
    查看更多(10)
登录 后发表内容