index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101
  1. <template>
  2. <view class="interview-container">
  3. <!-- 职位列表 v-if="!userInfoFilled"-->
  4. <view class="job-list-container" >
  5. <view class="job-list-title">可选职位列表</view>
  6. <view class="job-list">
  7. <view v-for="(job, index) in jobList" :key="index" class="job-item"
  8. :class="{'job-selected': selectedJobId === job.id}" v-show="job.status == 1" @click="selectJob(job)">
  9. <view class="job-name">{{job.title}}</view>
  10. <view class="job-actions">
  11. <button class="detail-btn" @click.stop="viewJobDetail(job)">查看详情</button>
  12. </view>
  13. <view class="job-details">
  14. <text class="job-salary"></text>
  15. <text class="job-location">{{formatLocation(job.location)}}</text>
  16. </view>
  17. </view>
  18. </view>
  19. <button class="apply-btn" :disabled="!selectedJobId" @click="applyForJob">申请面试</button>
  20. </view>
  21. <!-- 表单信息 -->
  22. <!-- <view class="form-container" v-if="userInfoFilled">
  23. <view class="form-title">请完成验证信息填写</view>
  24. <view class="form-item phone-item">
  25. <view class="country-code">
  26. <text>+86</text>
  27. </view>
  28. <input type="number" v-model="formData.phone" placeholder="请输入手机号" maxlength="11" @input="validatePhone" />
  29. <view class="validation-icon" v-if="formData.phone">
  30. <text class="icon-success" v-if="isPhoneValid">✓</text>
  31. <text class="icon-error" v-else>✗</text>
  32. </view>
  33. </view>
  34. <view class="form-item">
  35. <input type="text" v-model="formData.name" placeholder="请输入姓名" @input="validateName" />
  36. <view class="validation-icon" v-if="formData.name">
  37. <text class="icon-success" v-if="isNameValid">✓</text>
  38. <text class="icon-error" v-else>✗</text>
  39. </view>
  40. </view>
  41. <view class="form-item">
  42. <input type="text" v-model="formData.idCard" placeholder="请输入身份证号" maxlength="18" @input="validateIdCard" />
  43. <view class="validation-icon" v-if="formData.idCard">
  44. <text class="icon-success" v-if="isIdCardValid">✓</text>
  45. <text class="icon-error" v-else>✗</text>
  46. </view>
  47. </view>
  48. <view class="form-item">
  49. <picker @change="genderChange" :value="genderIndex" :range="genderOptions">
  50. <view class="picker-input">
  51. <input type="text" disabled placeholder="请选择性别" :value="formData.gender" />
  52. <view class="dropdown-icon">▼</view>
  53. </view>
  54. </picker>
  55. </view>
  56. <button class="verify-btn" :disabled="!canSubmitSimple" @click="submitForm">确认面试</button>
  57. <view class="agreement">
  58. <checkbox :checked="isAgreed" @tap="toggleAgreement" color="#0039b3" />
  59. <text class="agreement-text">
  60. 我已阅读并同意<text class="agreement-link">《用户协议》</text>和<text class="agreement-link">《隐私政策》</text>
  61. </text>
  62. </view>
  63. </view> -->
  64. </view>
  65. </template>
  66. <script>
  67. import { apiBaseUrl } from '@/common/config.js';
  68. import {
  69. fillUserInfo,
  70. getUserInfo,
  71. getJobList,
  72. applyJob
  73. } from '@/api/user';
  74. export default {
  75. data() {
  76. return {
  77. tenant_id: '', // 租户ID
  78. formData: {
  79. name: '',
  80. gender: '',
  81. phone: '',
  82. email: '',
  83. idCard: '',
  84. emergencyContact: '',
  85. emergencyPhone: '',
  86. relation: ''
  87. },
  88. relationOptions: ['父母', '配偶', '子女', '兄弟姐妹', '朋友', '其他'],
  89. relationIndex: 0,
  90. isAgreed: false,
  91. userInfoFilled: false,
  92. jobList: [],
  93. selectedJobId: null,
  94. selectedJob: null,
  95. isPhoneValid: false,
  96. isNameValid: false,
  97. isIdCardValid: false,
  98. genderOptions: ['男', '女'],
  99. genderIndex: 0,
  100. genderMapping: {
  101. '男': '1',
  102. '女': '2',
  103. '1': '男',
  104. '2': '女'
  105. }
  106. }
  107. },
  108. onLoad(options) {
  109. console.log('options:', options);
  110. if (options.scene) {
  111. // 对scene进行解码
  112. const scene = decodeURIComponent(options.scene);
  113. console.log('解码后的scene:', scene);
  114. let parsedTenantId = null;
  115. if (scene.includes('=')) {
  116. // 如果scene是key1=val1&key2=val2格式
  117. const sceneParams = {};
  118. scene.split('&').forEach(pair => {
  119. const [key, value] = pair.split('=');
  120. sceneParams[key] = value;
  121. });
  122. console.log('解析后的参数:', sceneParams);
  123. parsedTenantId = sceneParams.tenant_id || null;
  124. } else {
  125. // 兼容场景:scene 直接就是租户ID
  126. parsedTenantId = scene;
  127. }
  128. if (parsedTenantId) {
  129. const storedTenantId = uni.getStorageSync('tenant_id');
  130. const userInfo = uni.getStorageSync('userInfo');
  131. const userInfoTenantId = userInfo.tenant_id;
  132. /* console.log('userInfoTenantId:', userInfoTenantId);
  133. console.log('storedTenantId:', storedTenantId , 'parsedTenantId:', parsedTenantId, storedTenantId !== parsedTenantId); */
  134. if (storedTenantId && storedTenantId !== userInfoTenantId) {
  135. // 租户发生变化时,静默清除登录态以避免越租户数据串联
  136. this.silentLogout();
  137. }
  138. this.setTenantId(parsedTenantId);
  139. }
  140. }
  141. // 尝试从本地存储获取tenant_id
  142. this.getTenantId();
  143. this.checkUserInfo();
  144. this.fetchJobList();
  145. },
  146. computed: {
  147. canSubmit() {
  148. return this.formData.name.trim() &&
  149. this.formData.gender &&
  150. this.formData.phone.trim() &&
  151. (/^1\d{10}$/.test(this.formData.phone)) &&
  152. (!this.formData.email || /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(this.formData.email)) &&
  153. this.formData.idCard.trim() &&
  154. this.formData.emergencyContact.trim() &&
  155. this.formData.emergencyPhone.trim() &&
  156. (/^1\d{10}$/.test(this.formData.emergencyPhone)) &&
  157. this.formData.relation &&
  158. this.isAgreed;
  159. },
  160. canSubmitSimple() {
  161. return this.formData.name.trim() &&
  162. this.formData.phone.trim() &&
  163. this.isPhoneValid &&
  164. this.formData.idCard.trim() &&
  165. this.isIdCardValid &&
  166. this.isAgreed;
  167. }
  168. },
  169. methods: {
  170. // 静默清理登录态(不提示不跳转)
  171. silentLogout() {
  172. try {
  173. uni.removeStorageSync('token');
  174. uni.removeStorageSync('userInfo');
  175. } catch (e) {
  176. console.error('静默登出失败:', e);
  177. }
  178. },
  179. // 获取本地存储的tenant_id
  180. getTenantId() {
  181. const tenantId = uni.getStorageSync('tenant_id');
  182. if (tenantId) {
  183. this.tenant_id = tenantId;
  184. return tenantId;
  185. }
  186. return null;
  187. },
  188. // 设置tenant_id到本地存储
  189. setTenantId(tenantId) {
  190. this.tenant_id = tenantId;
  191. uni.setStorageSync('tenant_id', tenantId);
  192. console.log('已设置tenant_id:', tenantId);
  193. },
  194. checkLogin() {
  195. const userInfo = uni.getStorageSync('userInfo');
  196. if (!userInfo) {
  197. // 未登录时跳转到身份验证登录页面
  198. uni.reLaunch({
  199. url: '/pages/login/login',
  200. success: () => {
  201. console.log('跳转到身份验证登录页面成功');
  202. },
  203. fail: (err) => {
  204. console.error('跳转到身份验证登录页面失败:', err);
  205. uni.showToast({
  206. title: '跳转失败,请重试',
  207. icon: 'none'
  208. });
  209. }
  210. });
  211. return false;
  212. }
  213. try {
  214. const parsedUserInfo = JSON.parse(userInfo);
  215. if (!parsedUserInfo.openid) {
  216. // 没有openid时跳转到身份验证登录页面
  217. uni.navigateTo({
  218. url: '/pages/login/login'
  219. });
  220. return false;
  221. }
  222. return true;
  223. } catch (e) {
  224. console.error('解析用户信息失败:', e);
  225. uni.removeStorageSync('userInfo');
  226. uni.navigateTo({
  227. url: '/pages/login/login'
  228. });
  229. return false;
  230. }
  231. },
  232. goHome() {
  233. uni.navigateBack({
  234. delta: 1
  235. });
  236. },
  237. toggleAgreement() {
  238. this.isAgreed = !this.isAgreed;
  239. },
  240. relationChange(e) {
  241. this.relationIndex = e.detail.value;
  242. this.formData.relation = this.relationOptions[this.relationIndex];
  243. },
  244. checkUserInfo() {
  245. // if (!this.checkLogin()) {
  246. // return;
  247. // }
  248. uni.showLoading({
  249. title: '加载中...'
  250. });
  251. try {
  252. const userInfo = JSON.parse(uni.getStorageSync('userInfo'));
  253. console.log('id:', userInfo.id);
  254. getUserInfo(userInfo.id,userInfo.openid)
  255. .then(res => {
  256. uni.hideLoading();
  257. const userData = res;
  258. if (!userData.name || !userData.phone) {
  259. this.userInfoFilled = true;
  260. this.formData.name = userData.name || '';
  261. if (userData.gender) {
  262. this.formData.gender = this.genderMapping[userData.gender] || userData.gender;
  263. const index = this.genderOptions.findIndex(item => item === this.formData.gender);
  264. if (index !== -1) {
  265. this.genderIndex = index;
  266. }
  267. } else {
  268. this.formData.gender = '';
  269. }
  270. this.formData.phone = userData.phone || '';
  271. this.formData.idCard = userData.id_card || '';
  272. this.formData.emergencyContact = userData.emergency_contact || '';
  273. this.formData.emergencyPhone = userData.emergency_phone || '';
  274. this.formData.relation = userData.relation || '';
  275. if (userData.relation) {
  276. const index = this.relationOptions.findIndex(item => item === userData.relation);
  277. if (index !== -1) {
  278. this.relationIndex = index;
  279. }
  280. }
  281. }
  282. })
  283. .catch(err => {
  284. uni.hideLoading();
  285. console.error('获取用户信息失败:', err);
  286. uni.showToast({
  287. title: '获取用户信息失败',
  288. icon: 'none'
  289. });
  290. });
  291. } catch (e) {
  292. uni.hideLoading();
  293. console.error('获取用户信息失败:', e);
  294. uni.showToast({
  295. title: '获取用户信息失败',
  296. icon: 'none'
  297. });
  298. // uni.navigateTo({
  299. // url: '/pages/login/login'
  300. // });
  301. }
  302. },
  303. fetchJobList() {
  304. uni.showLoading({
  305. title: '加载职位列表...'
  306. });
  307. getJobList()
  308. .then(res => {
  309. uni.hideLoading();
  310. console.log('职位列表数据:', res);
  311. // 确保返回的数据是数组
  312. this.jobList = Array.isArray(res) ? res.filter(job => job !== null && job !== undefined) : [];
  313. if (this.jobList.length === 0) {
  314. uni.showToast({
  315. title: '暂无可用职位',
  316. icon: 'none'
  317. });
  318. }
  319. })
  320. .catch(err => {
  321. uni.hideLoading();
  322. console.error('获取职位列表失败:', err);
  323. this.jobList = []; // 确保发生错误时jobList是空数组
  324. uni.showToast({
  325. title: '网络错误,请稍后重试',
  326. icon: 'none'
  327. });
  328. });
  329. },
  330. selectJob(job) {
  331. // 清除之前的问题缓存
  332. try {
  333. uni.removeStorageSync('interviewQuestions');
  334. uni.removeStorageSync('currentQuestionIndex');
  335. } catch (e) {
  336. console.error('清除问题缓存失败:', e);
  337. }
  338. // 更新选中的职位
  339. this.selectedJobId = job.id;
  340. this.selectedJob = job;
  341. // 立即更新本地存储中的职位信息
  342. uni.setStorageSync('selectedJob', JSON.stringify(job));
  343. console.log('已选择职位:', job.id, job.title);
  344. },
  345. // 处理用户信息获取和页面跳转逻辑
  346. handleUserInfoAndNavigation(require_resume_upload) {
  347. // 调用获取用户完整信息的接口
  348. const openid = JSON.parse(uni.getStorageSync('userInfo')).openid;
  349. uni.request({
  350. url: `${apiBaseUrl}/api/wechat/user/get_full_info?tenant_id=${this.tenant_id||JSON.parse(uni.getStorageSync('userInfo')).tenant_id ||1}&openid=${openid}`,
  351. method: 'GET',
  352. success: (infoRes) => {
  353. if (infoRes.statusCode === 200 && infoRes.data && infoRes.data.data && infoRes.data.data.profile) {
  354. const resumeUrl = infoRes.data.data.profile.resume_url || '';
  355. if (!resumeUrl && require_resume_upload) {
  356. // resume_url 为空,跳转到其他页面
  357. uni.navigateTo({
  358. url: '/pages/uploadResume/uploadResume', // 假设跳转到上传简历页面
  359. fail: (err) => {
  360. console.error('页面跳转失败:', err);
  361. uni.showToast({
  362. title: '页面跳转失败',
  363. icon: 'none'
  364. });
  365. }
  366. });
  367. } else {
  368. // resume_url 不为空,跳转到 Personal 页面
  369. uni.navigateTo({
  370. url: '/pages/Personal/Personal',
  371. fail: (err) => {
  372. console.error('页面跳转失败:', err);
  373. uni.showToast({
  374. title: '页面跳转失败',
  375. icon: 'none'
  376. });
  377. }
  378. });
  379. }
  380. } else {
  381. // 获取用户信息失败,直接跳转到 Personal 页面
  382. uni.navigateTo({
  383. url: '/pages/Personal/Personal',
  384. fail: (err) => {
  385. console.error('页面跳转失败:', err);
  386. uni.showToast({
  387. title: '页面跳转失败',
  388. icon: 'none'
  389. });
  390. }
  391. });
  392. }
  393. },
  394. fail: (err) => {
  395. console.error('获取用户信息失败:', err);
  396. uni.navigateTo({
  397. url: '/pages/Personal/Personal',
  398. fail: (err) => {
  399. console.error('页面跳转失败:', err);
  400. uni.showToast({
  401. title: '页面跳转失败',
  402. icon: 'none'
  403. });
  404. }
  405. });
  406. }
  407. });
  408. },
  409. // 获取当前职位配置
  410. getConfig(){
  411. uni.request({
  412. url: `${apiBaseUrl}/api/job/config/position/${this.selectedJobId}`,
  413. method: 'GET',
  414. data: {
  415. openid: JSON.parse(uni.getStorageSync('userInfo')).openid
  416. },
  417. header: {
  418. 'content-type': 'application/x-www-form-urlencoded'
  419. },
  420. success: (res) => {
  421. // 身份验证成功后,继续提交用户信息
  422. console.log(res);
  423. if (res.statusCode === 200) {
  424. if (res.data.code === 2000) {
  425. uni.setStorageSync('configData', JSON.stringify(res.data.data))
  426. // 检查是否启用了视频宣讲功能
  427. const configData = res.data.data;
  428. const enableVideoPresentation = configData?.enable_video_presentation || false;
  429. const requireResumeUpload = configData?.require_resume_upload || false;
  430. if (enableVideoPresentation) {
  431. // 如果启用了视频宣讲,跳转到video-briefing页面
  432. const videoUrl = configData?.video_presentation_url || 'https://data.qicai321.com/minlong/latentsync/9791ad45-dd30-4f84-a1c6-0c07c4d08707_result.mp4';
  433. const nextPage = '/pages/Personal/Personal'; // 视频播放完成后的跳转页面
  434. uni.navigateTo({
  435. url: `/pages/video-briefing/video-briefing?src=${encodeURIComponent(videoUrl)}&next=${encodeURIComponent(nextPage)}`,
  436. fail: (err) => {
  437. console.error('跳转到视频宣讲页面失败:', err);
  438. // 如果跳转失败,执行原有的逻辑
  439. this.handleUserInfoAndNavigation(requireResumeUpload);
  440. }
  441. });
  442. } else {
  443. // 如果未启用视频宣讲,执行原有的逻辑
  444. this.handleUserInfoAndNavigation(requireResumeUpload);
  445. }
  446. } else {
  447. // 其他逻辑
  448. }
  449. } else {
  450. uni.hideLoading();
  451. }
  452. },
  453. fail: (err) => {
  454. uni.hideLoading();
  455. uni.showToast({
  456. title: '网络错误,请稍后重试',
  457. icon: 'none'
  458. });
  459. }
  460. });
  461. },
  462. applyForJob() {
  463. if (!this.checkLogin()) {
  464. return;
  465. }
  466. if (!this.selectedJobId) {
  467. uni.showToast({
  468. title: '请选择一个职位',
  469. icon: 'none'
  470. });
  471. return;
  472. }
  473. // 保存所选职位信息
  474. uni.setStorageSync('selectedJob', JSON.stringify(this.selectedJob));
  475. applyJob({
  476. job_id: this.selectedJobId,
  477. tenant_id: this.tenant_id||JSON.parse(uni.getStorageSync('userInfo')).tenant_id ||1,
  478. openid: JSON.parse(uni.getStorageSync('userInfo')).openid
  479. }).then(res => {
  480. // 保存返回的应用ID到本地存储
  481. if (res && res.id) {
  482. // 将应用ID保存到本地
  483. uni.setStorageSync('appId', res.id);
  484. // 也可以更新已有的userInfo对象
  485. try {
  486. const userInfo = JSON.parse(uni.getStorageSync('userInfo') || '{}');
  487. userInfo.appId = res.id;
  488. uni.setStorageSync('userInfo', JSON.stringify(userInfo));
  489. } catch (e) {
  490. console.error('更新用户信息失败:', e);
  491. }
  492. }
  493. this.getConfig()
  494. }).catch(err => {
  495. console.error('申请职位失败:', err);
  496. // 针对业务返回 code/status = 999 且提示职位已截止/已结束的情况,弹窗提示不影响其他功能
  497. const errCode = err && (err.status || err.code);
  498. const errMsg = (err && (err.message || (err.data && (err.data.msg || err.data.message)))) || '';
  499. if (errCode === 999 && (errMsg.includes('截止') || errMsg.includes('已结束') || errMsg.includes('已截止申请'))) {
  500. uni.showToast({
  501. title: '抱歉,本岗位招聘需求已结束',
  502. icon: 'none'
  503. });
  504. return;
  505. }
  506. uni.showToast({
  507. title: '申请职位失败,请重试',
  508. icon: 'none'
  509. });
  510. });
  511. },
  512. submitForm() {
  513. if (!this.checkLogin()) {
  514. return;
  515. }
  516. if (!this.formData.name.trim()) {
  517. uni.showToast({
  518. title: '请输入姓名',
  519. icon: 'none'
  520. });
  521. return;
  522. }
  523. if (!this.formData.gender) {
  524. uni.showToast({
  525. title: '请选择性别',
  526. icon: 'none'
  527. });
  528. return;
  529. }
  530. if (!this.formData.phone.trim()) {
  531. uni.showToast({
  532. title: '请输入手机号',
  533. icon: 'none'
  534. });
  535. return;
  536. }
  537. if (!/^1\d{10}$/.test(this.formData.phone)) {
  538. uni.showToast({
  539. title: '请输入正确的手机号',
  540. icon: 'none'
  541. });
  542. return;
  543. }
  544. if (!this.formData.idCard.trim()) {
  545. uni.showToast({
  546. title: '请输入身份证号',
  547. icon: 'none'
  548. });
  549. return;
  550. }
  551. const idCardReg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
  552. if (!idCardReg.test(this.formData.idCard)) {
  553. uni.showToast({
  554. title: '请输入正确的身份证号',
  555. icon: 'none'
  556. });
  557. return;
  558. }
  559. if (!this.isAgreed) {
  560. uni.showToast({
  561. title: '请阅读并同意相关协议',
  562. icon: 'none'
  563. });
  564. return;
  565. }
  566. uni.showLoading({
  567. title: '验证身份信息...'
  568. });
  569. // 先调用身份验证接口
  570. uni.request({
  571. url: `${apiBaseUrl}/wechat/identity/verify`,
  572. method: 'POST',
  573. data: {
  574. name: this.formData.name,
  575. id_number: this.formData.idCard,
  576. mobile: this.formData.phone
  577. },
  578. header: {
  579. 'content-type': 'application/x-www-form-urlencoded'
  580. },
  581. success: (res) => {
  582. // 身份验证成功后,继续提交用户信息
  583. console.log(res);
  584. if (res.statusCode === 200) {
  585. if (res.data.code === 200) {
  586. this.submitUserInfo();
  587. } else {
  588. uni.showToast({
  589. title: res.data.data.message,
  590. icon: 'none'
  591. });
  592. }
  593. } else {
  594. uni.hideLoading();
  595. uni.showToast({
  596. title: '身份验证失败,请检查信息是否正确',
  597. icon: 'none'
  598. });
  599. }
  600. },
  601. fail: (err) => {
  602. uni.hideLoading();
  603. console.error('身份验证失败:', err);
  604. uni.showToast({
  605. title: '网络错误,请稍后重试',
  606. icon: 'none'
  607. });
  608. }
  609. });
  610. },
  611. submitUserInfo() {
  612. const genderValue = this.genderMapping[this.formData.gender] || this.formData.gender;
  613. const submitData = {
  614. openid: JSON.parse(uni.getStorageSync('userInfo') || '{}').openid || '',
  615. name: this.formData.name,
  616. phone: this.formData.phone,
  617. id_card: this.formData.idCard,
  618. status: 1,
  619. source: 'mini',
  620. examine: 0,
  621. tenant_id: this.tenant_id||'1',
  622. /* emergency_contact: this.formData.emergencyContact,
  623. emergency_phone: this.formData.emergencyPhone,
  624. relation: this.formData.relation, */
  625. age: '20',
  626. job_id: this.selectedJobId,
  627. gender: genderValue
  628. };
  629. fillUserInfo(submitData)
  630. .then(res => {
  631. uni.hideLoading();
  632. this.updateLocalUserInfo(res.id,JSON.parse(uni.getStorageSync('userInfo')).openid);
  633. uni.showToast({
  634. title: '提交成功',
  635. icon: 'success',
  636. duration: 1500,
  637. success: () => {
  638. this.userInfoFilled = false;
  639. // setTimeout(() => {
  640. // }, 1500);
  641. }
  642. });
  643. })
  644. .catch(err => {
  645. uni.hideLoading();
  646. console.error('提交表单失败:', err);
  647. uni.showToast({
  648. title: '网络错误,请稍后重试',
  649. icon: 'none'
  650. });
  651. });
  652. },
  653. updateLocalUserInfo(data) {
  654. getUserInfo(data)
  655. .then(res => {
  656. if (res.code === 200 && res.data) {
  657. let userInfo = {};
  658. try {
  659. userInfo = JSON.parse(uni.getStorageSync('userInfo') || '{}');
  660. } catch (e) {
  661. console.error('解析本地存储用户信息失败:', e);
  662. userInfo = {};
  663. }
  664. const updatedUserInfo = {
  665. ...userInfo,
  666. ...res.data
  667. };
  668. uni.setStorageSync('userInfo', JSON.stringify(updatedUserInfo));
  669. }
  670. })
  671. .catch(err => {
  672. console.error('更新本地用户信息失败:', err);
  673. });
  674. },
  675. validatePhone() {
  676. this.isPhoneValid = /^1\d{10}$/.test(this.formData.phone);
  677. },
  678. validateName() {
  679. this.isNameValid = this.formData.name.trim().length >= 2;
  680. },
  681. validateIdCard() {
  682. const idCardReg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
  683. this.isIdCardValid = idCardReg.test(this.formData.idCard);
  684. },
  685. genderChange(e) {
  686. this.genderIndex = e.detail.value;
  687. const displayGender = this.genderOptions[this.genderIndex];
  688. this.formData.gender = displayGender;
  689. },
  690. viewJobDetail(job) {
  691. // 未登录则先进行登录校验
  692. // if (!this.checkLogin()) {
  693. // return;
  694. // }
  695. // 保存所选职位信息到本地存储
  696. uni.setStorageSync('currentJobDetail', JSON.stringify(job));
  697. console.log(job);
  698. // 跳转到职位详情页面
  699. uni.navigateTo({
  700. url: '/pages/job-detail/job-detail?id=' + job.id,
  701. fail: (err) => {
  702. console.error('页面跳转失败:', err);
  703. uni.showToast({
  704. title: '页面跳转失败',
  705. icon: 'none'
  706. });
  707. }
  708. });
  709. },
  710. formatLocation(location) {
  711. if (!location) return '';
  712. // 处理字符串形式的数组
  713. if (typeof location === 'string' && location.startsWith('[')) {
  714. try {
  715. const locationArray = JSON.parse(location.replace(/'/g, '"'));
  716. return locationArray.join(' ');
  717. } catch (e) {
  718. console.error('解析location失败:', e);
  719. return location;
  720. }
  721. }
  722. // 处理数组格式
  723. if (Array.isArray(location)) {
  724. return location.join(' ');
  725. }
  726. // 处理对象格式
  727. if (typeof location === 'object' && location !== null) {
  728. const { province, city, district } = location;
  729. if (province && city) {
  730. return province + ' ' + city + (district ? ' ' + district : '');
  731. }
  732. }
  733. // 处理普通字符串格式
  734. return location;
  735. }
  736. }
  737. }
  738. </script>
  739. <style>
  740. .interview-container {
  741. display: flex;
  742. flex-direction: column;
  743. min-height: 100vh;
  744. background-color: #f5f7fa;
  745. }
  746. .nav-bar {
  747. display: flex;
  748. justify-content: space-between;
  749. align-items: center;
  750. padding: 20rpx 30rpx;
  751. background-color: #0039b3;
  752. color: #fff;
  753. }
  754. .scan-btn {
  755. display: flex;
  756. flex-direction: column;
  757. align-items: center;
  758. background-color: #ff9f43;
  759. padding: 10rpx 30rpx;
  760. border-radius: 30rpx;
  761. font-size: 24rpx;
  762. }
  763. .interview-info {
  764. background-color: #0039b3;
  765. color: #fff;
  766. padding: 20rpx 30rpx 40rpx;
  767. }
  768. .info-item {
  769. margin: 10rpx 0;
  770. font-size: 28rpx;
  771. }
  772. .label {
  773. margin-right: 10rpx;
  774. }
  775. .form-container {
  776. flex: 1;
  777. background-color: #fff;
  778. padding: 40rpx 30rpx;
  779. }
  780. .form-title {
  781. font-size: 32rpx;
  782. font-weight: bold;
  783. margin-bottom: 40rpx;
  784. text-align: center;
  785. color: #333;
  786. }
  787. .form-item {
  788. margin-bottom: 30rpx;
  789. position: relative;
  790. }
  791. .validation-icon {
  792. position: absolute;
  793. right: 20rpx;
  794. top: 50%;
  795. transform: translateY(-50%);
  796. font-size: 36rpx;
  797. display: flex;
  798. align-items: center;
  799. justify-content: center;
  800. }
  801. .icon-success {
  802. color: #4cd964;
  803. }
  804. .icon-error {
  805. color: #ff3b30;
  806. }
  807. input {
  808. width: 100%;
  809. height: 80rpx;
  810. border: 1px solid #eee;
  811. border-radius: 8rpx;
  812. padding: 0 60rpx 0 20rpx;
  813. font-size: 28rpx;
  814. box-sizing: border-box;
  815. background-color: #f9f9f9;
  816. }
  817. .phone-item {
  818. display: flex;
  819. align-items: center;
  820. position: relative;
  821. }
  822. .phone-item .validation-icon {
  823. right: 20rpx;
  824. }
  825. .phone-item input {
  826. flex: 1;
  827. border-radius: 0 8rpx 8rpx 0;
  828. }
  829. .verify-btn {
  830. width: 100%;
  831. height: 90rpx;
  832. line-height: 90rpx;
  833. background-color: #0039b3;
  834. color: #fff;
  835. border-radius: 45rpx;
  836. font-size: 32rpx;
  837. margin-top: 60rpx;
  838. }
  839. .verify-btn[disabled] {
  840. background-color: #b2b2b2;
  841. color: #fff;
  842. opacity: 0.7;
  843. }
  844. .agreement {
  845. display: flex;
  846. align-items: center;
  847. margin-top: 30rpx;
  848. }
  849. .agreement-text {
  850. font-size: 24rpx;
  851. color: #666;
  852. line-height: 1.5;
  853. margin-left: 10rpx;
  854. }
  855. .agreement-link {
  856. color: #0039b3;
  857. }
  858. /* 职位列表样式 */
  859. .job-list-container {
  860. flex: 1;
  861. background-color: #fff;
  862. border-radius: 20rpx 20rpx 0 0;
  863. margin-top: -20rpx;
  864. padding: 40rpx 30rpx;
  865. }
  866. .job-list-title {
  867. font-size: 32rpx;
  868. font-weight: bold;
  869. margin-bottom: 30rpx;
  870. }
  871. .job-list {
  872. max-height: 1000rpx;
  873. overflow-y: auto;
  874. }
  875. .job-item {
  876. padding: 30rpx;
  877. border-radius: 12rpx;
  878. background-color: #f8f9fa;
  879. margin-bottom: 20rpx;
  880. border: 2rpx solid transparent;
  881. }
  882. .job-selected {
  883. border-color: #0039b3;
  884. background-color: rgba(108, 92, 231, 0.1);
  885. }
  886. .job-name {
  887. font-size: 30rpx;
  888. font-weight: bold;
  889. margin-bottom: 10rpx;
  890. }
  891. .job-details {
  892. display: flex;
  893. justify-content: space-between;
  894. font-size: 24rpx;
  895. color: #666;
  896. }
  897. .job-salary {
  898. color: #fb752f;
  899. }
  900. .apply-btn {
  901. width: 100%;
  902. height: 90rpx;
  903. line-height: 90rpx;
  904. background-color: #0039b3;
  905. color: #fff;
  906. border-radius: 45rpx;
  907. font-size: 32rpx;
  908. margin-top: 40rpx;
  909. }
  910. .apply-btn[disabled] {
  911. background-color: #b2b2b2;
  912. color: #fff;
  913. }
  914. /* 修复国家代码样式 */
  915. .country-code {
  916. display: flex;
  917. align-items: center;
  918. justify-content: space-between;
  919. width: 100rpx;
  920. padding: 0 20rpx;
  921. height: 80rpx;
  922. border: 1px solid #eee;
  923. border-radius: 8rpx 0 0 8rpx;
  924. border-right: none;
  925. font-size: 28rpx;
  926. background-color: #f9f9f9;
  927. }
  928. .dropdown-icon {
  929. font-size: 20rpx;
  930. color: #999;
  931. margin-left: 10rpx;
  932. }
  933. /* 修复手机号输入框样式 */
  934. .phone-item {
  935. display: flex;
  936. align-items: center;
  937. position: relative;
  938. }
  939. .phone-item input {
  940. flex: 1;
  941. border-radius: 0 8rpx 8rpx 0;
  942. }
  943. /* 修复验证图标位置 */
  944. .validation-icon {
  945. position: absolute;
  946. right: 20rpx;
  947. top: 50%;
  948. transform: translateY(-50%);
  949. font-size: 36rpx;
  950. display: flex;
  951. align-items: center;
  952. justify-content: center;
  953. z-index: 2;
  954. }
  955. .phone-item .validation-icon {
  956. right: 20rpx;
  957. }
  958. /* 修改图标样式与图片一致 */
  959. .icon-success {
  960. color: #4cd964;
  961. font-weight: bold;
  962. }
  963. .icon-error {
  964. color: #ff3b30;
  965. font-weight: bold;
  966. }
  967. /* 修改性别选择样式,使其看起来像输入框 */
  968. .picker-input {
  969. position: relative;
  970. width: 100%;
  971. }
  972. .picker-input input {
  973. width: 100%;
  974. height: 80rpx;
  975. border: 1px solid #eee;
  976. border-radius: 8rpx;
  977. padding: 0 60rpx 0 20rpx;
  978. font-size: 28rpx;
  979. box-sizing: border-box;
  980. background-color: #f9f9f9;
  981. }
  982. .picker-input .dropdown-icon {
  983. position: absolute;
  984. right: 20rpx;
  985. top: 50%;
  986. transform: translateY(-50%);
  987. font-size: 24rpx;
  988. color: #999;
  989. }
  990. .job-actions {
  991. display: flex;
  992. justify-content: flex-end;
  993. margin-top: 15rpx;
  994. margin-bottom: 15rpx;
  995. }
  996. .detail-btn {
  997. background-color: #0039b3;
  998. color: #fff;
  999. font-size: 24rpx;
  1000. padding: 6rpx 20rpx;
  1001. border-radius: 30rpx;
  1002. line-height: 1.5;
  1003. margin: 0;
  1004. min-height: auto;
  1005. }
  1006. </style>