|
|
@@ -30,7 +30,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { uploadImage, currentOpenId } from '@/utils/request.js'
|
|
|
+import { request, uploadImage, currentOpenId } from '@/utils/request.js'
|
|
|
|
|
|
const MAX_COUNT = 9
|
|
|
|
|
|
@@ -89,9 +89,21 @@ export default {
|
|
|
this.images = failedPaths
|
|
|
this.showResult(successCount, failedPaths.length)
|
|
|
},
|
|
|
+ // 两步:1) uni.uploadFile 传图换 attach_id 2) 带着 openId + attach_id 调 report&action=add 登记
|
|
|
async uploadOne(filePath) {
|
|
|
- const res = await uploadImage(filePath, { openId: currentOpenId() })
|
|
|
- return res.code === 200
|
|
|
+ const uploadRes = await uploadImage(filePath)
|
|
|
+ // TODO-DIAG: 确认第一步返回结构(attach_id 在哪个字段)的临时日志,确认后删除
|
|
|
+ console.log('UPLOAD_DEBUG step1 result=', JSON.stringify(uploadRes))
|
|
|
+ if (uploadRes.notJson || uploadRes.code !== 200) return false
|
|
|
+ const data = uploadRes.data
|
|
|
+ const attachId = data && (data.id || data.attach_id)
|
|
|
+ if (!attachId) return false
|
|
|
+ const addRes = await request('report', 'add', {
|
|
|
+ openId: currentOpenId(),
|
|
|
+ attach_id: attachId,
|
|
|
+ })
|
|
|
+ console.log('UPLOAD_DEBUG step2 result=', JSON.stringify(addRes))
|
|
|
+ return addRes.code === 200
|
|
|
},
|
|
|
showResult(successCount, failCount) {
|
|
|
let title
|