"use strict"; const common_vendor = require("../../common/vendor.js"); const common_config = require("../../common/config.js"); const _sfc_main = { data() { return { checkItems: [ { name: "左手手心", success: true, type: "left_palm", description: "展示完整的左手手掌" }, { name: "左手手背", success: true, type: "left_back", description: "展示完整的左手手背" }, { name: "左手握拳", success: true, type: "left_fist", description: "展示完整的左手握拳" }, { name: "右手手心", success: true, type: "right_palm", description: "展示完整的右手手掌" }, { name: "右手手背", success: true, type: "right_back", description: "展示完整的右手手背" }, { name: "右手握拳", success: true, type: "right_fist", description: "展示完整的右手握拳" } ], maxRetries: 3, currentRetry: 0, retryInterval: 3e3, // 3秒 applicationId: null, isAnalyzing: false // 添加分析状态标志 }; }, computed: { hasFailedItems() { return this.checkItems.some((item) => !item.success); }, failedItems() { return this.checkItems.filter((item) => !item.success); } }, onLoad(options) { this.applicationId = common_vendor.index.getStorageSync("appId"); this.fetchAnalysisResults(); }, methods: { async fetchAnalysisResults() { try { this.isAnalyzing = true; const response = await common_vendor.index.request({ url: `${common_config.apiBaseUrl}/api/system/job/get_visual_analysis_results?application_id=${this.applicationId}` }); console.log(response); if (response.data.code === 2001) { setTimeout(() => { this.fetchAnalysisResults(); }, this.retryInterval); return; } if (response.data.code === 2e3 && response.data.data && response.data.data.photo_results && response.data.data.photo_results.length > 0) { this.isAnalyzing = false; this.processResults(response.data.data.photo_results); } else if (this.currentRetry < this.maxRetries) { this.currentRetry++; setTimeout(() => { this.fetchAnalysisResults(); }, this.retryInterval); } else { this.isAnalyzing = false; } } catch (error) { console.error("获取分析结果失败:", error); this.isAnalyzing = false; } }, processResults(photoResults) { const results = {}; photoResults.forEach((photo) => { const checkItem = this.checkItems.find( (item) => photo.description === item.description ); console.log(checkItem, photo); if (checkItem) { results[checkItem.type] = photo.part_verification.is_correct_part; } }); this.updateCheckResults(results); }, updateCheckResults(results) { this.checkItems = this.checkItems.map((item) => ({ ...item, success: results[item.type] || false })); }, retake() { if (this.hasFailedItems) { common_vendor.index.navigateTo({ url: "/pages/interview/interview?retake=true&failedItems=" + JSON.stringify(this.failedItems.map((item) => item.type)) }); } else { common_vendor.index.navigateBack(); } }, goNext() { if (!this.hasFailedItems) { common_vendor.index.reLaunch({ url: "/pages/success/success" }); } else { common_vendor.index.reLaunch({ url: "/pages/interview_retake/interview_retake?failedItems=" + JSON.stringify(this.failedItems) }); } } } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: $data.isAnalyzing }, $data.isAnalyzing ? {} : {}, { b: $data.isAnalyzing }, $data.isAnalyzing ? {} : { c: common_vendor.f($data.checkItems, (item, index, i0) => { return { a: common_vendor.t(index + 1), b: common_vendor.t(item.name), c: common_vendor.t(item.success ? "动作检测成功" : "动作检测失败"), d: !item.success ? 1 : "", e: index }; }) }, { d: !$data.isAnalyzing }, !$data.isAnalyzing ? { e: common_vendor.o((...args) => $options.retake && $options.retake(...args)), f: $data.isAnalyzing, g: common_vendor.t($options.hasFailedItems ? "补拍" : "下一步"), h: common_vendor.o((...args) => $options.goNext && $options.goNext(...args)), i: $data.isAnalyzing } : {}); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]); wx.createPage(MiniProgramPage);