interview_success.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const common_config = require("../../common/config.js");
  4. const _sfc_main = {
  5. data() {
  6. return {
  7. checkItems: [
  8. { name: "左手手心", success: true, type: "left_palm", description: "展示完整的左手手掌" },
  9. { name: "左手手背", success: true, type: "left_back", description: "展示完整的左手手背" },
  10. { name: "左手握拳", success: true, type: "left_fist", description: "展示完整的左手握拳" },
  11. { name: "右手手心", success: true, type: "right_palm", description: "展示完整的右手手掌" },
  12. { name: "右手手背", success: true, type: "right_back", description: "展示完整的右手手背" },
  13. { name: "右手握拳", success: true, type: "right_fist", description: "展示完整的右手握拳" }
  14. ],
  15. maxRetries: 3,
  16. currentRetry: 0,
  17. retryInterval: 3e3,
  18. // 3秒
  19. applicationId: null,
  20. isAnalyzing: false
  21. // 添加分析状态标志
  22. };
  23. },
  24. computed: {
  25. hasFailedItems() {
  26. return this.checkItems.some((item) => !item.success);
  27. },
  28. failedItems() {
  29. return this.checkItems.filter((item) => !item.success);
  30. }
  31. },
  32. onLoad(options) {
  33. this.applicationId = common_vendor.index.getStorageSync("appId");
  34. this.fetchAnalysisResults();
  35. },
  36. methods: {
  37. async fetchAnalysisResults() {
  38. try {
  39. this.isAnalyzing = true;
  40. const response = await common_vendor.index.request({
  41. url: `${common_config.apiBaseUrl}/api/system/job/get_visual_analysis_results?application_id=${this.applicationId}`
  42. });
  43. console.log(response);
  44. if (response.data.code === 2001) {
  45. setTimeout(() => {
  46. this.fetchAnalysisResults();
  47. }, this.retryInterval);
  48. return;
  49. }
  50. if (response.data.code === 2e3 && response.data.data && response.data.data.photo_results && response.data.data.photo_results.length > 0) {
  51. this.isAnalyzing = false;
  52. this.processResults(response.data.data.photo_results);
  53. } else if (this.currentRetry < this.maxRetries) {
  54. this.currentRetry++;
  55. setTimeout(() => {
  56. this.fetchAnalysisResults();
  57. }, this.retryInterval);
  58. } else {
  59. this.isAnalyzing = false;
  60. }
  61. } catch (error) {
  62. console.error("获取分析结果失败:", error);
  63. this.isAnalyzing = false;
  64. }
  65. },
  66. processResults(photoResults) {
  67. const results = {};
  68. photoResults.forEach((photo) => {
  69. const checkItem = this.checkItems.find(
  70. (item) => photo.description === item.description
  71. );
  72. console.log(checkItem, photo);
  73. if (checkItem) {
  74. results[checkItem.type] = photo.part_verification.is_correct_part;
  75. }
  76. });
  77. this.updateCheckResults(results);
  78. },
  79. updateCheckResults(results) {
  80. this.checkItems = this.checkItems.map((item) => ({
  81. ...item,
  82. success: results[item.type] || false
  83. }));
  84. },
  85. retake() {
  86. if (this.hasFailedItems) {
  87. common_vendor.index.navigateTo({
  88. url: "/pages/interview/interview?retake=true&failedItems=" + JSON.stringify(this.failedItems.map((item) => item.type))
  89. });
  90. } else {
  91. common_vendor.index.navigateBack();
  92. }
  93. },
  94. goNext() {
  95. if (!this.hasFailedItems) {
  96. common_vendor.index.reLaunch({
  97. url: "/pages/success/success"
  98. });
  99. } else {
  100. common_vendor.index.reLaunch({
  101. url: "/pages/interview_retake/interview_retake?failedItems=" + JSON.stringify(this.failedItems)
  102. });
  103. }
  104. }
  105. }
  106. };
  107. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  108. return common_vendor.e({
  109. a: $data.isAnalyzing
  110. }, $data.isAnalyzing ? {} : {}, {
  111. b: $data.isAnalyzing
  112. }, $data.isAnalyzing ? {} : {
  113. c: common_vendor.f($data.checkItems, (item, index, i0) => {
  114. return {
  115. a: common_vendor.t(index + 1),
  116. b: common_vendor.t(item.name),
  117. c: common_vendor.t(item.success ? "动作检测成功" : "动作检测失败"),
  118. d: !item.success ? 1 : "",
  119. e: index
  120. };
  121. })
  122. }, {
  123. d: !$data.isAnalyzing
  124. }, !$data.isAnalyzing ? {
  125. e: common_vendor.o((...args) => $options.retake && $options.retake(...args)),
  126. f: $data.isAnalyzing,
  127. g: common_vendor.t($options.hasFailedItems ? "补拍" : "下一步"),
  128. h: common_vendor.o((...args) => $options.goNext && $options.goNext(...args)),
  129. i: $data.isAnalyzing
  130. } : {});
  131. }
  132. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
  133. wx.createPage(MiniProgramPage);