小程序
小游戏
企业微信
微信支付
扫描小程序码分享
oneplus 5 手机调用相机,退出小程序
预期:希望和其他Andriod手机一样正常调用相机功能
- 复现路径
- 提供一个最简复现 Demo
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
手机oneplus 5系统安卓8.1.0微信版本6.6.7
代码片段
wxml
<view class="page__img">
<view class="section section_gap" >
<view class="section__ctn">
<view wx:for="{{srcarr}}" wx:key="key" class='imgblock'>
<image wx:if="{{index==srclength-1}}" catchtap="bindaddimg" style="width: 105rpx; height: 105rpx;margin-right:14rpx;margin-left:14rpx; background-color: #eeeeee; display:{{srclength<6?'block':'none'}}" src="{{item}}"></image>
<image wx:else="{{index!==srclength}}" catchtouchstart="start" catchtouchend="touchend" data-index="{{index}}" style="width: 105rpx; height: 105rpx;margin-right:14rpx;margin-left:14rpx; background-color: #eeeeee;" src="{{item}}"></image>
<image class="deleteimg" wx:for-index="deleteIndex"style="display:{{imgIndex[index]==true?'block':'none'}}" bindtap="shutimg" wx:if="{{index!==srclength-1}}" data-id="{{index}}" src='../../images/checkimg.png'></image>
</view>
sxcss:
.currentImgNumber{
font-size:24rpx;
position:absolute;
right:0;
bottom:-6px;
color: #b9b9b9;
}
.imgblock{
display: inline-block;
position: relative;
.deleteimg{
position: absolute;
right: -15rpx;
top:-15rpx;
font-size: 24rpx;
z-index: 1000;
width:46rpx;
height: 46rpx;
border: 0rpx solid #dcdddd!important;
js:
bindaddimg: function (e) { //添加图片
var imgs = this.data.srcarr;
var c = this.data.srcarr;
var that = this;
var nowCount = this.data.srclength - 1;
wx.chooseImage({
count: 5 - nowCount, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
var tempFilePaths = res.tempFilePaths;
for (var i = 0; i < tempFilePaths.length; i++) {
http.uploadFile('/miniApp/uploadImg', tempFilePaths[i],
function (data) {
var data = JSON.parse(data)
var imgs = that.data.srcarr;
var image = [data[0].url];
var c = image.concat(imgs);
if (image) {
that.data.currentImgNumber = that.data.currentImgNumber + 1;
var len = that.data.currentImgNumber;
that.setData({
currentImgNumber: len,
srcarr: c,
srclength: c.length,
selectImg: [],
imgIndex: { //选择要删除的图片的下标默认全是false
0: true,
1: true,
2: true,
3: true,
4: true
});
}, function (res) {
})
},
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
手机oneplus 5
系统安卓8.1.0
微信版本6.6.7
代码片段
wxml
<view class="page__img">
<view class="section section_gap" >
<view class="section__ctn">
<view wx:for="{{srcarr}}" wx:key="key" class='imgblock'>
<image wx:if="{{index==srclength-1}}" catchtap="bindaddimg" style="width: 105rpx; height: 105rpx;margin-right:14rpx;margin-left:14rpx; background-color: #eeeeee; display:{{srclength<6?'block':'none'}}" src="{{item}}"></image>
<image wx:else="{{index!==srclength}}" catchtouchstart="start" catchtouchend="touchend" data-index="{{index}}" style="width: 105rpx; height: 105rpx;margin-right:14rpx;margin-left:14rpx; background-color: #eeeeee;" src="{{item}}"></image>
<image class="deleteimg" wx:for-index="deleteIndex"style="display:{{imgIndex[index]==true?'block':'none'}}" bindtap="shutimg" wx:if="{{index!==srclength-1}}" data-id="{{index}}" src='../../images/checkimg.png'></image>
</view>
</view>
</view>
</view>
sxcss:
.currentImgNumber{
font-size:24rpx;
position:absolute;
right:0;
bottom:-6px;
color: #b9b9b9;
}
.imgblock{
display: inline-block;
position: relative;
}
.deleteimg{
position: absolute;
right: -15rpx;
top:-15rpx;
font-size: 24rpx;
z-index: 1000;
width:46rpx;
height: 46rpx;
border: 0rpx solid #dcdddd!important;
}
js:
bindaddimg: function (e) { //添加图片
var imgs = this.data.srcarr;
var c = this.data.srcarr;
var that = this;
var nowCount = this.data.srclength - 1;
wx.chooseImage({
count: 5 - nowCount, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
var tempFilePaths = res.tempFilePaths;
for (var i = 0; i < tempFilePaths.length; i++) {
http.uploadFile('/miniApp/uploadImg', tempFilePaths[i],
function (data) {
var data = JSON.parse(data)
var imgs = that.data.srcarr;
var image = [data[0].url];
var c = image.concat(imgs);
if (image) {
that.data.currentImgNumber = that.data.currentImgNumber + 1;
}
var len = that.data.currentImgNumber;
that.setData({
currentImgNumber: len,
srcarr: c,
srclength: c.length,
selectImg: [],
imgIndex: { //选择要删除的图片的下标默认全是false
0: true,
1: true,
2: true,
3: true,
4: true
}
});
}, function (res) {
})
}
}
})
},
提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。