|
|
|
@ -165,7 +165,18 @@ |
|
|
|
</view> |
|
|
|
|
|
|
|
</view> |
|
|
|
</uni-popup> |
|
|
|
</uni-popup> |
|
|
|
<view v-if="isTake" style="position: fixed;width: 100%;height: 100%;z-index: 100;top: 0;"> |
|
|
|
<camera device-position="back" flash="off" style="width: 100%; height: 100%;"></camera> |
|
|
|
<view style="width: 100%;height: 120rpx;position: fixed;bottom:200rpx;"> |
|
|
|
<view @tap="takePhoto" style="width: 120rpx;height: 120rpx;border-radius: 120rpx;background: #fff;margin: 0 auto;border: 2px solid #eee;"> |
|
|
|
<view style="width: 116rpx;height: 116rpx;border-radius: 116rpx;background: #fff;margin: 0 auto;border: 1px solid #fff;"></view> |
|
|
|
</view> |
|
|
|
<view @tap="isTake = false" style="position: absolute;top: 20rpx;left: 100rpx;"> |
|
|
|
<uni-icons type="close" color="#777" size="40"></uni-icons> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
|
@ -193,7 +204,8 @@ |
|
|
|
size:"", |
|
|
|
keyBoardHeight:0, |
|
|
|
name:'', |
|
|
|
nameText:'' |
|
|
|
nameText:'', |
|
|
|
isTake:false |
|
|
|
} |
|
|
|
}, |
|
|
|
onShow() { |
|
|
|
@ -369,15 +381,15 @@ |
|
|
|
let that = this; |
|
|
|
uni.getSystemInfo({ |
|
|
|
success: function (res) { |
|
|
|
if(res.osName == 'ios'){ |
|
|
|
that.upLoadImg('ios') |
|
|
|
}else if(res.osName == 'android'){ |
|
|
|
// if(res.osName == 'ios'){ |
|
|
|
// that.upLoadImg('ios') |
|
|
|
// }else if(res.osName == 'android'){ |
|
|
|
that.$refs.popup.open('bottom') |
|
|
|
} |
|
|
|
// } |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
upLoadImg(type) { |
|
|
|
async upLoadImg(type) { |
|
|
|
uni.showLoading({ |
|
|
|
title: '加载中...', |
|
|
|
mask:true |
|
|
|
@ -396,28 +408,42 @@ |
|
|
|
} |
|
|
|
}) |
|
|
|
}else if(type == 'pai'){ |
|
|
|
uni.chooseMedia({ |
|
|
|
count: 1, |
|
|
|
mediaType: ['image'], |
|
|
|
sourceType: ['camera'], |
|
|
|
camera: 'back', |
|
|
|
success(res) { |
|
|
|
console.log('拍照',res) |
|
|
|
setTimeout(res=>{ |
|
|
|
uni.chooseMedia({ |
|
|
|
count: 1, |
|
|
|
mediaType: ['image'], |
|
|
|
sourceType: ['album'], |
|
|
|
success(res1) { |
|
|
|
console.log('选图',res1) |
|
|
|
that.upLoadFile(res1.tempFiles[0].tempFilePath) |
|
|
|
} |
|
|
|
}) |
|
|
|
},1000) |
|
|
|
},fail(){ |
|
|
|
uni.hideLoading(); |
|
|
|
uni.authorize({ |
|
|
|
scope: 'scope.writePhotosAlbum', |
|
|
|
success() { |
|
|
|
that.isTake = true |
|
|
|
uni.hideLoading(); |
|
|
|
},fail(){ |
|
|
|
that.tui.toast("您未授权,AI入库功能可能会出现错误") |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
// uni.authorize({ |
|
|
|
// scope: 'scope.writePhotosAlbum', |
|
|
|
// success() { |
|
|
|
// uni.chooseMedia({ |
|
|
|
// count: 1, |
|
|
|
// mediaType: ['image'], |
|
|
|
// sourceType: ['camera'], |
|
|
|
// sizeType:['original', 'compressed'], |
|
|
|
// camera: 'back', |
|
|
|
// success(res) { |
|
|
|
// console.log('拍照成功',res) |
|
|
|
// uni.saveImageToPhotosAlbum({ |
|
|
|
// filePath: res.tempFiles[0].tempFilePath, |
|
|
|
// success: function () { |
|
|
|
// that.cameraUpload() |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// },fail(err){ |
|
|
|
// console.log('错误',err) |
|
|
|
// uni.hideLoading(); |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// },fail(){ |
|
|
|
// that.tui.toast("您未授权,AI入库功能可能会出现错误") |
|
|
|
// } |
|
|
|
// }) |
|
|
|
}else if(type == 'xuan'){ |
|
|
|
uni.chooseMedia({ |
|
|
|
count: 1, |
|
|
|
@ -430,9 +456,47 @@ |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
this.$refs.popup.close() |
|
|
|
await this.$refs.popup.close() |
|
|
|
// uni.hideLoading(); |
|
|
|
}, |
|
|
|
async takePhoto(){ |
|
|
|
let that = this; |
|
|
|
const ctx = uni.createCameraContext(); |
|
|
|
await ctx.takePhoto({ |
|
|
|
quality: 'high', |
|
|
|
success: (res) => { |
|
|
|
let ttt = that |
|
|
|
uni.saveImageToPhotosAlbum({ |
|
|
|
filePath: res.tempImagePath, |
|
|
|
success: function () { |
|
|
|
ttt.cameraUpload() |
|
|
|
} |
|
|
|
}); |
|
|
|
},fail(err){ |
|
|
|
console.log('原相机',err) |
|
|
|
that.isTake = false |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
cameraUpload(){ |
|
|
|
let that = this; |
|
|
|
uni.chooseMedia({ |
|
|
|
count: 1, |
|
|
|
mediaType: ['image'], |
|
|
|
sourceType: ['album'], |
|
|
|
success(res1) { |
|
|
|
that.isTake = false |
|
|
|
console.log('选图',res1) |
|
|
|
that.upLoadFile(res1.tempFiles[0].tempFilePath) |
|
|
|
},fail(){ |
|
|
|
that.isTake = false |
|
|
|
uni.hideLoading(); |
|
|
|
},complete(res){ |
|
|
|
console.log('拍照',res) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
async upLoadFile(path){ |
|
|
|
let that = this; |
|
|
|
uni.showLoading({ |
|
|
|
|