bugfix
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { request, uploadFile, NOT_LOGIN_CODE } from '../../utils/request'
|
||||
import { ProcessStatus } from '../../utils/config'
|
||||
import { logger } from '../../utils/logger'
|
||||
|
||||
// 日志模块名
|
||||
const LOG = 'upload'
|
||||
|
||||
Page({
|
||||
data: {
|
||||
@@ -17,7 +21,7 @@ Page({
|
||||
const sourceType: Array<'camera' | 'album'> = res.tapIndex === 0 ? ['camera'] : ['album']
|
||||
this.chooseImage(sourceType)
|
||||
},
|
||||
fail: () => {}, // 取消选择属正常操作,不必抛错日志
|
||||
fail: (e) => logger.debug(LOG, '取消选择图片, err=', e && e.errMsg),
|
||||
})
|
||||
},
|
||||
|
||||
@@ -28,8 +32,10 @@ Page({
|
||||
sourceType,
|
||||
success: (res) => {
|
||||
const file = res.tempFiles[0]
|
||||
logger.debug(LOG, '已选择图片, 来源=', sourceType.join(','))
|
||||
this.startUpload(file.tempFilePath)
|
||||
},
|
||||
fail: (e) => logger.warn(LOG, '选择图片失败, err=', e && e.errMsg),
|
||||
})
|
||||
},
|
||||
|
||||
@@ -38,11 +44,13 @@ Page({
|
||||
|
||||
uploadFile<{ clothes_uuid: string; image_process_status: number }>(filePath)
|
||||
.then((res) => {
|
||||
logger.info(LOG, '衣物上传成功, uuid=', res.clothes_uuid)
|
||||
this.setData({ clothesUuid: res.clothes_uuid })
|
||||
this.askNextAction()
|
||||
})
|
||||
.catch((e: any) => {
|
||||
this.setData({ state: 'idle' })
|
||||
logger.warn(LOG, '衣物上传失败, code=', e && e.code)
|
||||
if (e && e.code === 80000) {
|
||||
this.showQuotaModal()
|
||||
return
|
||||
@@ -66,14 +74,22 @@ Page({
|
||||
success: (res) => {
|
||||
this.clearTimer()
|
||||
if (res.confirm) {
|
||||
logger.debug(LOG, '选择继续上传,重置状态')
|
||||
this.setData({ state: 'idle', imagePath: '', clothesUuid: '', step: 0, failReason: '' })
|
||||
} else {
|
||||
wx.navigateBack({
|
||||
delta: 1,
|
||||
fail: () => wx.switchTab({ url: '/pages/wardrobe/wardrobe' }),
|
||||
fail: (e) => {
|
||||
logger.warn(LOG, 'navigateBack 失败,改跳衣橱, err=', e && e.errMsg)
|
||||
wx.switchTab({
|
||||
url: '/pages/wardrobe/wardrobe',
|
||||
fail: (e2) => logger.warn(LOG, 'switchTab 衣橱失败, err=', e2 && e2.errMsg),
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: (e) => logger.warn(LOG, '上传完成弹窗失败, err=', e && e.errMsg),
|
||||
})
|
||||
},
|
||||
|
||||
@@ -96,13 +112,15 @@ Page({
|
||||
this.clearTimer()
|
||||
} else if (status === ProcessStatus.FAILED) {
|
||||
this.clearTimer()
|
||||
logger.warn(LOG, 'AI 识别失败, 原因=', res.fail_reason)
|
||||
this.setData({ state: 'failed', failReason: res.fail_reason || '识别失败' })
|
||||
}
|
||||
})
|
||||
.catch(() => {})
|
||||
.catch((e: any) => logger.warn(LOG, '状态轮询失败, code=', e && e.code))
|
||||
|
||||
if (count >= 60) {
|
||||
this.clearTimer()
|
||||
logger.warn(LOG, 'AI 处理超时(90s)')
|
||||
this.setData({ state: 'failed', failReason: '处理超时,请重试' })
|
||||
}
|
||||
}, 1500)
|
||||
@@ -127,8 +145,14 @@ Page({
|
||||
confirmText: '去购买',
|
||||
cancelText: '取消',
|
||||
success: (res) => {
|
||||
if (res.confirm) wx.navigateTo({ url: '/pages/mall/mall' })
|
||||
if (res.confirm) {
|
||||
wx.navigateTo({
|
||||
url: '/pages/mall/mall',
|
||||
fail: (e) => logger.warn(LOG, 'navigateTo 商城失败, err=', e && e.errMsg),
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: (e) => logger.warn(LOG, '额度弹窗失败, err=', e && e.errMsg),
|
||||
})
|
||||
},
|
||||
|
||||
@@ -138,6 +162,9 @@ Page({
|
||||
|
||||
onManualEdit() {
|
||||
if (!this.data.clothesUuid) return
|
||||
wx.redirectTo({ url: `/pages/clothes-detail/clothes-detail?uuid=${this.data.clothesUuid}` })
|
||||
wx.redirectTo({
|
||||
url: `/pages/clothes-detail/clothes-detail?uuid=${this.data.clothesUuid}`,
|
||||
fail: (e) => logger.warn(LOG, 'redirectTo 衣物详情失败, err=', e && e.errMsg),
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user