index.vue 27 KB

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