interview_success.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. this.navigateToNextPage();
  97. } else {
  98. common_vendor.index.reLaunch({
  99. url: "/pages/interview_retake/interview_retake?failedItems=" + JSON.stringify(this.failedItems)
  100. });
  101. }
  102. },
  103. // 根据配置决定跳转到下一个页面
  104. navigateToNextPage() {
  105. let configData = {};
  106. try {
  107. const configStr = common_vendor.index.getStorageSync("configData");
  108. if (configStr && configStr.trim()) {
  109. configData = JSON.parse(configStr);
  110. }
  111. } catch (error) {
  112. console.error("解析configData失败:", error);
  113. configData = {};
  114. }
  115. console.log("interview_success页面获取到的配置数据:", configData);
  116. const questionFormSwitches = (configData == null ? void 0 : configData.question_form_switches) || {};
  117. const hasChoiceQuestions = questionFormSwitches.enable_fill_blank || questionFormSwitches.enable_image_choice || questionFormSwitches.enable_multiple_choice || questionFormSwitches.enable_single_choice;
  118. const hasPostureDetection = configData == null ? void 0 : configData.enable_posture_check;
  119. const hasCandidateQuestions = questionFormSwitches.enable_candidate_questions;
  120. let targetUrl = "/pages/success/success";
  121. let pageName = "success页面";
  122. console.log("interview_success页面配置检查:", {
  123. hasChoiceQuestions,
  124. hasPostureDetection,
  125. hasCandidateQuestions,
  126. questionFormSwitches
  127. });
  128. if (hasCandidateQuestions) {
  129. targetUrl = "/pages/interview-question/interview-question";
  130. pageName = "interview-question页面";
  131. } else {
  132. targetUrl = "/pages/success/success";
  133. pageName = "success页面";
  134. }
  135. console.log("interview_success页面根据配置跳转到:", targetUrl);
  136. common_vendor.index.reLaunch({
  137. url: targetUrl,
  138. success: () => {
  139. console.log(`成功跳转到${pageName}`);
  140. },
  141. fail: (err) => {
  142. console.error(`跳转到${pageName}失败:`, err);
  143. common_vendor.index.navigateTo({
  144. url: targetUrl,
  145. fail: (navigateErr) => {
  146. console.error(`导航到${pageName}也失败:`, navigateErr);
  147. common_vendor.index.redirectTo({
  148. url: targetUrl,
  149. fail: (redirectErr) => {
  150. console.error("所有跳转方式都失败:", redirectErr);
  151. common_vendor.index.reLaunch({
  152. url: "/pages/success/success"
  153. });
  154. }
  155. });
  156. }
  157. });
  158. }
  159. });
  160. }
  161. }
  162. };
  163. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  164. return common_vendor.e({
  165. a: $data.isAnalyzing
  166. }, $data.isAnalyzing ? {} : {}, {
  167. b: $data.isAnalyzing
  168. }, $data.isAnalyzing ? {} : {
  169. c: common_vendor.f($data.checkItems, (item, index, i0) => {
  170. return {
  171. a: common_vendor.t(index + 1),
  172. b: common_vendor.t(item.name),
  173. c: common_vendor.t(item.success ? "动作检测成功" : "动作检测失败"),
  174. d: !item.success ? 1 : "",
  175. e: index
  176. };
  177. })
  178. }, {
  179. d: !$data.isAnalyzing
  180. }, !$data.isAnalyzing ? {
  181. e: common_vendor.o((...args) => $options.retake && $options.retake(...args)),
  182. f: $data.isAnalyzing,
  183. g: common_vendor.t($options.hasFailedItems ? "补拍" : "下一步"),
  184. h: common_vendor.o((...args) => $options.goNext && $options.goNext(...args)),
  185. i: $data.isAnalyzing
  186. } : {});
  187. }
  188. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
  189. wx.createPage(MiniProgramPage);