- 当前 Bug 的表现(可附上截图)
async imageOrLocation (index, cameraOnly) { let item = this.picture[index] if (item.restrictiveConditionDto.requireGeographyInfo) { this.getLocationRequired(index, cameraOnly) } else { this.chooseImage(index, cameraOnly) } }, chooseImage (index, cameraOnly) { let vue = this // let sourceType = cameraOnly ? ['camera'] : ['album', 'camera'] wechatlib.chooseImage({ count: 1, sizeType: ['compressed'], sourceType: ['camera'], success: async function (res) { vue.$set(vue.picture[index], 'src', res.localIds[0]) vue.uploadImage(res.localIds[0], index) }, fail: function () { vue.toast('选择图片失败') } }) }, getLocalImageDate (localID, index) { let vue = this wechatlib.getLocalImgData({ localId: localID, success: function (res) { vue.picture[index].src = res.localData }, fail: function () { vue.toast('获取本地图片失败') } }) }, async getLocationRequired (index, cameraOnly) { this.indicator('地理位置获取中') let vue = this let indicator = true setTimeout(() => { if (indicator) { Indicator.close() vue.messageBoxB() } }, 5000) await wechatlib.getLocation({ type: 'wgs84', success: function (res) { vue.picture[index].location = res.latitude.toString() + ',' + res.longitude.toString() Indicator.close() indicator = false vue.chooseImage(index, cameraOnly) }, fail: function (res) { alert(JSON.stringify(res)) vue.messageBoxB() Indicator.close() indicator = false }, cancel: function () { vue.messageBoxA() Indicator.close() indicator = false } }) }, async uploadImage (localId, index) { let vue = this vue.indicator('上传中') await wechatlib.uploadImage({ localId: localId, isShowProgressTips: 0, success: async function (res) { vue.picture[index].value = await api.postImage(vue.$route.params.id, res.serverId) let u = navigator.userAgent let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) if (isIOS) { vue.getLocalImageDate(localId, index) } Indicator.close() }, fail: function () { vue.toast('图片上传失败,请重试') Indicator.close() } }) },
|
- 预期表现
点击拍照先获取地理位置,重复点击拍照,拍照完成,点击使用照片的时候,偶尔会出现页面刷新的情况。
- 复现路径
- 提供一个最简复现 Demo
<div v-for="(item, index) in picture" :key="item.id" class="img_container">
<div class="pic">
<div class="img" @click="imageOrLocation(index, item.restrictiveConditionDto.cameraOnly)">
<img v-show="item.src" :src="item.src">
</div>
<p class="title">{{item.name}}</p>
</div>
</div>
JS在上面。
你好,请提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),ios系统版本是?
出现问题的机型有: iphone6plus(系统版本12.0.1, 12.0), iphone8(系统版本12.1),IOS系统11以及以下版本未出现此问题。
能复现问题的简单代码片段:
<
div
v-for
=
"(item, index) in picture"
:key
=
"item.id"
class
=
"img_container"
>
<
div
class
=
"pic"
>
<
div
class
=
"img"
@
click
=
"chooseImage (index, item.restrictiveConditionDto.cameraOnly)"
>
<
img
v-show
=
"item.src"
:src
=
"item.src"
>
</
div
>
<
p
class
=
"title"
>{{item.name}}</
p
>
</
div
>
</
div
>
chooseImage (index, cameraOnly) {
let vue =
this
let sourceType = cameraOnly ? [
'camera'
] : [
'album'
,
'camera'
]
wechatlib.chooseImage({
count: 1,
sizeType: [
'compressed'
],
sourceType: sourceType,
success: async
function
(res) {
vue.$set(vue.picture[index],
'src'
, res.localIds[0])
vue.uploadImage(res.localIds[0], index)
},
fail:
function
() {
vue.toast(
'选择图片失败'
)
}
})
},
async uploadImage (localId, index) {
let vue =
this
vue.indicator(
'上传中'
)
await wechatlib.uploadImage({
localId: localId,
isShowProgressTips: 0,
success: async
function
(res) {
vue.picture[index].value = await api.postImage(vue.$route.params.id, res.serverId)
let u = navigator.userAgent
let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
if
(isIOS) {
vue.getLocalImageDate(localId, index)
}
Indicator.close()
},
fail:
function
() {
vue.toast(
'图片上传失败,请重试'
)
Indicator.close()
}
})
},
麻烦按照教程来提供下代码片段,微信版本都是6.7.4么?
对 微信版本是6.7.4 这个问题不是小程序中的 是移动端开发调微信的接口出现的问题。
查下是不是手机内存紧张导致的闪退问题吧
好的,谢谢。