收藏
回答

微信小程序在我的iPhone6P上最新版微信里调用摄像头出现闪退

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

- 当前 Bug 的表现(可附上截图)

有个页面进去就要打开摄像头

- 预期表现

一打开就微信闪退,需要重复进去好几次才能打开摄像头

- 复现路径

每次进去都会重复出现,进好几次就好了

- 提供一个最简复现 Demo



<!--pages/examinfo/mainexaminfo.wxml-->

<view class='page'>

<view class='page-top'>

<camera device-position="front" mode="normal" flash="off" class="{{canExam==true?'on':'off'}}" binderror="cameraerror" style="width: 30%; height: 300rpx;"  wx:if="{{offical==1}}"  ></camera>

<view class='page-top-info' style="width:{{offical==1?'70%':'100%'}}">

<view class='examtitle'>

{{paper.p_name}}

</view>

时长:{{paper.p_duration}}分钟

</view>

</view>

<view class='page-content'>

<view class='examinfo'>

<text>考试日期:</text> {{paper.p_starttime}} 至 {{paper.p_endtime}}

</view>

<view class='examinfo'>

<text>成绩标准:</text> 满分 {{paper.p_total_score}} 分,合格 {{paper.p_pass_score}}分

</view>

<view class='examinfo'><text>考试题型</text> </view>

<view class='examinfo2'>1.单选题,共15题,每题3分</view>

<view class='examinfo2'>2.多选题,共10题,每题4分</view>

<view class='examinfo2'>3.判断题,共5题,每题4分</view>

<navigator url="../exam/exam?p_id={{paper.p_id}}&&offical={{offical}}" open-type="redirect">

<button class="weui-btn" type="primary" wx:if="{{!canExam &&  offical==1 }}" disabled="true">开始考试</button>

<button class="weui-btn" type="primary" wx:if="{{canExam || offical==0}}" >开始考试</button>

</navigator>

</view>

</view>



// pages/examinfo/mainexaminfo.js

var app = getApp();

Page({


/**

  * 页面的初始数据

  */

data: {

p_id:"",

canExam:false,

myi:0,

timeOutId:0

},


/**

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

  */

onLoad: function (options) {

wx.showLoading({

title: '获取试题信息中'

});

this.setData({

p_id: options.p_id,

offical: options.offical

});

var that = this;

wx.request({

url: app.url + 'system/paper/wxpaperinfo.thtml',

header: {

"Cookie": "JSESSIONID=" + wx.getStorageSync("sessionid"),

'content-type': 'application/x-www-form-urlencoded'

},

data:{

p_id: options.p_id

},

success: function (res) {

wx.hideLoading();

var timeOutId = 0;

if (that.data.offical == 1) {

timeOutId = setTimeout(function () {

that.matchFace();

}, 1500);

}

that.setData({ paper: res.data.data, timeOutId: timeOutId });

}, fail: function (err) {

wx.showToast({

title: '微信请求试卷失败',

image: '../../image/close.png'

})

}

});

},


/**

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

  */

onReady: function () {

},


/**

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

  */

onShow: function () {

},

matchFace:function(){

wx.showLoading({

title: '正在检测人脸'

});

const ctx = wx.createCameraContext();

var account = wx.getStorageSync("account");

var that = this;

ctx.takePhoto({

quality: 'high',

success: (res) => {

wx.uploadFile({

url: app.url + 'face/matchFace.do',

header: {

"Cookie": "JSESSIONID=" + wx.getStorageSync("sessionid"),

'content-type': 'application/x-www-form-urlencoded'

},

filePath: res.tempImagePath,

dataType: "json",

formData: {

'uid': account.uid

},

name: 'file',

success: function (res) {

console.log(res);

if (JSON.parse(res.data).result) {

that.setData({ canExam: true });

wx.hideLoading();

}else{

var myi = that.data.myi;

myi+=1;

if(myi%4==0){

wx.showToast({

title: '人脸检测失败',

icon: 'loading',

duration: 2000

});

}

var timeOutId = 0;

timeOutId = setTimeout(function(){

that.matchFace();

}, 1000);

that.setData({ myi: myi, timeOutId: timeOutId });

}

},

fail: (e) => {

console.log(e, 999)

if (e.errMsg === "request:fail abort") return;

wx.showModal({

title: '提示',

content: '请求失败,请检查网络',

showCancel: false,

confirmColor: '#0f77ff',

success: (res) => { }

})

}

})

},

fail: (e) => {

console.log(e, 999)

console.log(e.detail);

wx.request({

url: app.url + 'user/paper/saveError.thtml',

header: {

"Cookie": "JSESSIONID=" + wx.getStorageSync("sessionid"),

'content-type': 'application/x-www-form-urlencoded'

},

data: {

error: e.detail

}

});

wx.showModal({

title: '提示',

content: '拍照失败',

showCancel: false,

confirmColor: '#0f77ff',

success: (res) => { }

})

}

})

}

})


回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容