job-detail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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. title: data.data.title || '',
  138. salary: data.data.salary_range ? `${data.data.salary_range}/月` : '',
  139. department: `${data.data.department || ''} ${data.data.job_type === 1 ? '全职' : '兼职'}`,
  140. location: data.data.location || '',
  141. experience: data.data.work_experience_required || '不限',
  142. benefits: data.data.competency_tags || ['五险一金', '带薪年假', '定期体检'],
  143. description: [
  144. {
  145. subtitle: '岗位要求',
  146. items: descriptionItems
  147. }
  148. ]
  149. };
  150. } else {
  151. uni.showToast({
  152. title: '获取职位详情失败',
  153. icon: 'none'
  154. });
  155. }
  156. } catch (e) {
  157. console.error('获取职位详情失败:', e);
  158. uni.showToast({
  159. title: '获取职位详情失败',
  160. icon: 'none'
  161. });
  162. }
  163. },
  164. checkLogin() {
  165. const userInfo = uni.getStorageSync('userInfo');
  166. if (!userInfo) {
  167. uni.showToast({
  168. title: '请先登录',
  169. icon: 'none'
  170. });
  171. return false;
  172. }
  173. return true;
  174. },
  175. async startInterview() {
  176. if (!this.checkLogin()) {
  177. return;
  178. }
  179. try {
  180. // 保存所选职位信息
  181. uni.setStorageSync('selectedJob', JSON.stringify(this.jobDetail));
  182. const userInfo = JSON.parse(uni.getStorageSync('userInfo'));
  183. const response = await applyJob({
  184. job_id: this.jobId,
  185. tenant_id: 1,
  186. openid: userInfo.openid
  187. });
  188. if (response && response.id) {
  189. // 保存应用ID到本地
  190. uni.setStorageSync('appId', response.id);
  191. // 更新userInfo对象
  192. try {
  193. userInfo.appId = response.id;
  194. uni.setStorageSync('userInfo', JSON.stringify(userInfo));
  195. } catch (e) {
  196. console.error('更新用户信息失败:', e);
  197. }
  198. // 导航到摄像头页面
  199. uni.navigateTo({
  200. url: '/pages/Personal/Personal',
  201. fail: (err) => {
  202. console.error('页面跳转失败:', err);
  203. uni.showToast({
  204. title: '页面跳转失败',
  205. icon: 'none'
  206. });
  207. }
  208. });
  209. }
  210. } catch (err) {
  211. console.error('申请职位失败:', err);
  212. uni.showToast({
  213. title: '申请职位失败,请重试',
  214. icon: 'none'
  215. });
  216. }
  217. }
  218. }
  219. }
  220. </script>
  221. <style lang="scss" scoped>
  222. .job-detail-container {
  223. padding: 20rpx;
  224. position: relative;
  225. background-color: #f5f5f5;
  226. min-height: 100vh;
  227. }
  228. .job-header {
  229. padding: 20rpx 0;
  230. }
  231. .job-title {
  232. font-size: 36rpx;
  233. font-weight: bold;
  234. color: #333;
  235. margin-bottom: 10rpx;
  236. }
  237. .job-salary {
  238. font-size: 32rpx;
  239. color: #ff6b00;
  240. margin-bottom: 10rpx;
  241. }
  242. .job-department {
  243. font-size: 28rpx;
  244. color: #666;
  245. margin-bottom: 20rpx;
  246. }
  247. .job-requirements {
  248. display: flex;
  249. align-items: center;
  250. margin-bottom: 20rpx;
  251. }
  252. .requirement-item {
  253. display: flex;
  254. align-items: center;
  255. margin-right: 30rpx;
  256. font-size: 26rpx;
  257. color: #666;
  258. }
  259. .dot {
  260. width: 16rpx;
  261. height: 16rpx;
  262. border-radius: 50%;
  263. background-color: #0052d9;
  264. margin-right: 10rpx;
  265. }
  266. .time-icon {
  267. width: 26rpx;
  268. height: 26rpx;
  269. background-color: #999;
  270. border-radius: 50%;
  271. margin-right: 10rpx;
  272. display: flex;
  273. justify-content: center;
  274. align-items: center;
  275. font-size: 18rpx;
  276. color: #fff;
  277. }
  278. .section {
  279. margin-bottom: 30rpx;
  280. background-color: #fff;
  281. border-radius: 16rpx;
  282. padding: 20rpx;
  283. }
  284. .section-title {
  285. font-size: 32rpx;
  286. font-weight: bold;
  287. color: #333;
  288. margin-bottom: 20rpx;
  289. }
  290. .map-container {
  291. position: relative;
  292. border-radius: 16rpx;
  293. overflow: hidden;
  294. }
  295. .map-image {
  296. width: 100%;
  297. height: 300rpx;
  298. border-radius: 16rpx;
  299. }
  300. .map-time {
  301. position: absolute;
  302. left: 20rpx;
  303. bottom: 20rpx;
  304. background-color: rgba(0, 0, 0, 0.6);
  305. color: #fff;
  306. font-size: 24rpx;
  307. padding: 6rpx 12rpx;
  308. border-radius: 6rpx;
  309. }
  310. .refresh-icon {
  311. position: absolute;
  312. right: 20rpx;
  313. bottom: 20rpx;
  314. width: 60rpx;
  315. height: 60rpx;
  316. background-color: #fff;
  317. border-radius: 50%;
  318. display: flex;
  319. justify-content: center;
  320. align-items: center;
  321. }
  322. .benefits-list {
  323. display: flex;
  324. flex-wrap: wrap;
  325. }
  326. .benefit-tag {
  327. background-color: #f5f5f5;
  328. color: #666;
  329. font-size: 26rpx;
  330. padding: 10rpx 20rpx;
  331. border-radius: 6rpx;
  332. margin-right: 20rpx;
  333. margin-bottom: 20rpx;
  334. }
  335. .description-subtitle {
  336. font-size: 28rpx;
  337. font-weight: bold;
  338. color: #333;
  339. margin-bottom: 20rpx;
  340. }
  341. .description-content {
  342. padding-left: 10rpx;
  343. }
  344. .description-item {
  345. display: flex;
  346. margin-bottom: 20rpx;
  347. /* * {
  348. background-color: #fff !important;
  349. color: #333 !important;
  350. }
  351. strong {
  352. font-weight: bold;
  353. } */
  354. }
  355. .blue-dot {
  356. min-width: 16rpx;
  357. height: 16rpx;
  358. border-radius: 50%;
  359. background-color: #0039b3 !important;
  360. margin-right: 10rpx;
  361. margin-top: 12rpx;
  362. }
  363. .description-item text {
  364. font-size: 26rpx;
  365. color: #666;
  366. line-height: 1.6;
  367. }
  368. .interview-button {
  369. position: fixed;
  370. right: 0;
  371. top: 50%;
  372. transform: translateY(-50%);
  373. background-color: #0039b3;
  374. color: #fff;
  375. writing-mode: vertical-lr;
  376. padding: 30rpx 20rpx;
  377. font-size: 32rpx;
  378. border-top-left-radius: 16rpx;
  379. border-bottom-left-radius: 16rpx;
  380. }
  381. </style>