job-detail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <view class="job-detail-container">
  3. <!-- 顶部信息区域 -->
  4. <view class="job-header">
  5. <view class="job-title">{{ jobDetail.title }}</view>
  6. <view class="job-salary">{{ jobDetail.salary }}</view>
  7. <view class="job-department">{{ jobDetail.department }}</view>
  8. <view class="job-requirements">
  9. <view class="requirement-item">
  10. <view class="dot"></view>
  11. <text>{{ jobDetail.location }}</text>
  12. </view>
  13. <view class="requirement-item">
  14. <view class="time-icon"></view>
  15. <text>{{ jobDetail.experience }}</text>
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 工作地点区域 -->
  20. <view class="section">
  21. <view class="section-title">工作地点</view>
  22. <view class="map-container">
  23. <image class="map-image" src="https://data.qicai321.com/minlong/6be6ec51-d4a2-4f2b-9bfc-23e046a3db37.png" mode="aspectFill"></image>
  24. <!-- <view class="map-time">预计14:32到达</view> -->
  25. <view class="refresh-icon">
  26. <text class="iconfont icon-refresh"></text>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 福利待遇区域 -->
  31. <!-- <view class="section">
  32. <view class="section-title">福利待遇</view>
  33. <view class="benefits-list">
  34. <view class="benefit-tag" >暂无数据</view>
  35. </view>
  36. </view> -->
  37. <!-- 岗位介绍区域 -->
  38. <view class="section">
  39. <view class="section-title">岗位介绍</view>
  40. <view class="job-description">
  41. <!-- <view class="description-subtitle">{{ jobDetail.description[0].subtitle }}</view> -->
  42. <view class="description-content">
  43. <view class="description-item" v-for="(item, index) in jobDetail.description[0].items" :key="index">
  44. <view class="blue-dot"></view>
  45. <text style="color: #333;">{{ item }}</text>
  46. <!-- <view v-html="item"></view> -->
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- 右侧开始面试按钮 -->
  52. <view class="interview-button" @click="startInterview">
  53. <text>开始面试</text>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import { apiBaseUrl } from '@/common/config.js';
  59. import { applyJob } from '@/api/user.js';
  60. export default {
  61. data() {
  62. return {
  63. jobDetail: {
  64. title: '',
  65. salary: '',
  66. department: '',
  67. location: '',
  68. experience: '',
  69. benefits: [],
  70. description: [
  71. {
  72. subtitle: '岗位要求',
  73. items: []
  74. }
  75. ]
  76. },
  77. selectedJobId: null,
  78. jobId: null
  79. }
  80. },
  81. onLoad(options) {
  82. this.jobId = options.id;
  83. this.getJobDetail(options.id);
  84. // 尝试从本地存储获取职位详情
  85. try {
  86. const jobDetailStr = uni.getStorageSync('currentJobDetail');
  87. if (jobDetailStr) {
  88. const jobData = JSON.parse(jobDetailStr);
  89. // 这里可以根据实际数据结构进行处理
  90. // 如果后端返回的数据结构与页面需要的不一致,可以在这里进行转换
  91. this.jobDetail = {
  92. ...this.jobDetail,
  93. title: jobData.title || this.jobDetail.title,
  94. salary: jobData.salary || this.jobDetail.salary,
  95. department: jobData.department || this.jobDetail.department,
  96. location: jobData.location || this.jobDetail.location,
  97. experience: jobData.experience || this.jobDetail.experience,
  98. benefits: jobData.benefits || this.jobDetail.benefits,
  99. description: jobData.description || this.jobDetail.description
  100. };
  101. }
  102. } catch (e) {
  103. console.error('获取职位详情失败:', e);
  104. }
  105. },
  106. methods: {
  107. async getJobDetail(jobId) {
  108. try {
  109. const { data } = await uni.request({
  110. url: `${apiBaseUrl}/api/mini/job/detail?id=${jobId}&tenant_id=1`,
  111. method: 'GET',
  112. });
  113. if (data.code === 2000) {
  114. // 处理富文本description
  115. let descriptionItems = [];
  116. if (data.data.description) {
  117. // 使用正则表达式提取<li>标签中的文本内容
  118. const liRegex = /<li[^>]*>(.*?)<\/li>/g;
  119. const stripTagsRegex = /<[^>]*>/g;
  120. let match;
  121. while ((match = liRegex.exec(data.data.description)) !== null) {
  122. // 移除剩余的HTML标签,并清理空白字符
  123. const text = match[1]
  124. .replace(stripTagsRegex, '')
  125. .replace(/&nbsp;/g, ' ')
  126. .trim();
  127. if (text) {
  128. descriptionItems.push(text);
  129. }
  130. }
  131. }
  132. // 如果requirements存在,添加到描述项前面
  133. if (data.data.requirements) {
  134. descriptionItems.unshift(data.data.requirements);
  135. }
  136. this.jobDetail = {
  137. id: data.data.id,
  138. title: data.data.title || '',
  139. salary: data.data.salary_range ? `${data.data.salary_range}/月` : '',
  140. department: `${data.data.department || ''} ${data.data.job_type === 1 ? '全职' : '兼职'}`,
  141. location: data.data.location || '',
  142. experience: data.data.work_experience_required || '不限',
  143. benefits: data.data.competency_tags || ['五险一金', '带薪年假', '定期体检'],
  144. description: [
  145. {
  146. subtitle: '岗位要求',
  147. items: descriptionItems
  148. }
  149. ]
  150. };
  151. } else {
  152. uni.showToast({
  153. title: '获取职位详情失败',
  154. icon: 'none'
  155. });
  156. }
  157. } catch (e) {
  158. console.error('获取职位详情失败:', e);
  159. uni.showToast({
  160. title: '获取职位详情失败',
  161. icon: 'none'
  162. });
  163. }
  164. },
  165. checkLogin() {
  166. const userInfo = uni.getStorageSync('userInfo');
  167. if (!userInfo) {
  168. uni.showToast({
  169. title: '请先登录',
  170. icon: 'none'
  171. });
  172. return false;
  173. }
  174. return true;
  175. },
  176. async startInterview() {
  177. if (!this.checkLogin()) {
  178. return;
  179. }
  180. try {
  181. // 保存所选职位信息
  182. uni.setStorageSync('selectedJob', JSON.stringify(this.jobDetail));
  183. const userInfo = JSON.parse(uni.getStorageSync('userInfo'));
  184. const response = await applyJob({
  185. job_id: this.jobId,
  186. tenant_id: 1,
  187. openid: userInfo.openid
  188. });
  189. if (response && response.id) {
  190. // 保存应用ID到本地
  191. uni.setStorageSync('appId', response.id);
  192. // 更新userInfo对象
  193. try {
  194. userInfo.appId = response.id;
  195. uni.setStorageSync('userInfo', JSON.stringify(userInfo));
  196. } catch (e) {
  197. console.error('更新用户信息失败:', e);
  198. }
  199. // 导航到摄像头页面
  200. uni.navigateTo({
  201. url: '/pages/Personal/Personal',
  202. fail: (err) => {
  203. console.error('页面跳转失败:', err);
  204. uni.showToast({
  205. title: '页面跳转失败',
  206. icon: 'none'
  207. });
  208. }
  209. });
  210. }
  211. } catch (err) {
  212. console.error('申请职位失败:', err);
  213. uni.showToast({
  214. title: '申请职位失败,请重试',
  215. icon: 'none'
  216. });
  217. }
  218. }
  219. }
  220. }
  221. </script>
  222. <style lang="scss" scoped>
  223. .job-detail-container {
  224. padding: 20rpx;
  225. position: relative;
  226. background-color: #f5f5f5;
  227. min-height: 100vh;
  228. }
  229. .job-header {
  230. padding: 20rpx 0;
  231. }
  232. .job-title {
  233. font-size: 36rpx;
  234. font-weight: bold;
  235. color: #333;
  236. margin-bottom: 10rpx;
  237. }
  238. .job-salary {
  239. font-size: 32rpx;
  240. color: #ff6b00;
  241. margin-bottom: 10rpx;
  242. }
  243. .job-department {
  244. font-size: 28rpx;
  245. color: #666;
  246. margin-bottom: 20rpx;
  247. }
  248. .job-requirements {
  249. display: flex;
  250. align-items: center;
  251. margin-bottom: 20rpx;
  252. }
  253. .requirement-item {
  254. display: flex;
  255. align-items: center;
  256. margin-right: 30rpx;
  257. font-size: 26rpx;
  258. color: #666;
  259. }
  260. .dot {
  261. width: 16rpx;
  262. height: 16rpx;
  263. border-radius: 50%;
  264. background-color: #0052d9;
  265. margin-right: 10rpx;
  266. }
  267. .time-icon {
  268. width: 26rpx;
  269. height: 26rpx;
  270. background-color: #999;
  271. border-radius: 50%;
  272. margin-right: 10rpx;
  273. display: flex;
  274. justify-content: center;
  275. align-items: center;
  276. font-size: 18rpx;
  277. color: #fff;
  278. }
  279. .section {
  280. margin-bottom: 30rpx;
  281. background-color: #fff;
  282. border-radius: 16rpx;
  283. padding: 20rpx;
  284. }
  285. .section-title {
  286. font-size: 32rpx;
  287. font-weight: bold;
  288. color: #333;
  289. margin-bottom: 20rpx;
  290. }
  291. .map-container {
  292. position: relative;
  293. border-radius: 16rpx;
  294. overflow: hidden;
  295. }
  296. .map-image {
  297. width: 100%;
  298. height: 300rpx;
  299. border-radius: 16rpx;
  300. }
  301. .map-time {
  302. position: absolute;
  303. left: 20rpx;
  304. bottom: 20rpx;
  305. background-color: rgba(0, 0, 0, 0.6);
  306. color: #fff;
  307. font-size: 24rpx;
  308. padding: 6rpx 12rpx;
  309. border-radius: 6rpx;
  310. }
  311. .refresh-icon {
  312. position: absolute;
  313. right: 20rpx;
  314. bottom: 20rpx;
  315. width: 60rpx;
  316. height: 60rpx;
  317. background-color: #fff;
  318. border-radius: 50%;
  319. display: flex;
  320. justify-content: center;
  321. align-items: center;
  322. }
  323. .benefits-list {
  324. display: flex;
  325. flex-wrap: wrap;
  326. }
  327. .benefit-tag {
  328. background-color: #f5f5f5;
  329. color: #666;
  330. font-size: 26rpx;
  331. padding: 10rpx 20rpx;
  332. border-radius: 6rpx;
  333. margin-right: 20rpx;
  334. margin-bottom: 20rpx;
  335. }
  336. .description-subtitle {
  337. font-size: 28rpx;
  338. font-weight: bold;
  339. color: #333;
  340. margin-bottom: 20rpx;
  341. }
  342. .description-content {
  343. padding-left: 10rpx;
  344. }
  345. .description-item {
  346. display: flex;
  347. margin-bottom: 20rpx;
  348. /* * {
  349. background-color: #fff !important;
  350. color: #333 !important;
  351. }
  352. strong {
  353. font-weight: bold;
  354. } */
  355. }
  356. .blue-dot {
  357. min-width: 16rpx;
  358. height: 16rpx;
  359. border-radius: 50%;
  360. background-color: #0039b3 !important;
  361. margin-right: 10rpx;
  362. margin-top: 12rpx;
  363. }
  364. .description-item text {
  365. font-size: 26rpx;
  366. color: #666;
  367. line-height: 1.6;
  368. }
  369. .interview-button {
  370. position: fixed;
  371. right: 0;
  372. top: 50%;
  373. transform: translateY(-50%);
  374. background-color: #0039b3;
  375. color: #fff;
  376. writing-mode: vertical-lr;
  377. padding: 30rpx 20rpx;
  378. font-size: 32rpx;
  379. border-top-left-radius: 16rpx;
  380. border-bottom-left-radius: 16rpx;
  381. }
  382. </style>