job-detail.vue 9.3 KB

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