index.vue 25 KB

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