jobPosting.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <template>
  2. <view class="switch-roles">
  3. <nav-bar title="发布职位" color="#000" :isBack="isBack"></nav-bar>
  4. <view class="roles-content">
  5. <view class="content">
  6. <view class="title">{{ isDisabled ? '编辑【' + jobInfo.ruleClassifyName + '】' : '发布社招' }}岗位</view>
  7. <view class="desc">{{ companyName }}</view>
  8. <view class="step">
  9. <u-steps :list="numList" mode="number" :current="0"></u-steps>
  10. </view>
  11. <view class="check-title-big">招聘模式</view>
  12. <view class="check-select radioseletvi">
  13. <radio-group @change="onRadioChange">
  14. <view class="select-txt radioseletview">
  15. <label class="radio radioselet">
  16. <radio value="0" :checked="true" class="radio-size" :disabled="isDisabled" />普通岗位招聘
  17. </label>
  18. <label class="radio radioselet">
  19. <radio value="1" class="radio-size" :disabled="isDisabled" />急聘
  20. </label>
  21. <text
  22. style="position: absolute;right: 0;bottom: 18px;font-size: 12px;color: rgba(120, 130, 138, 1);">急聘职位剩余{{
  23. vipDueTimes }}个</text>
  24. </view>
  25. </radio-group>
  26. </view>
  27. <view class="check-title">招聘类型</view>
  28. <view class="check-box" :class="{ disabled: isDisabled }">
  29. <view class="check-item" :class="{ 'is-check': check == index }" v-for="(item, index) in peopleList"
  30. :key="index" @click="!isDisabled && checkPeople(index)">{{ item }}</view>
  31. </view>
  32. <view class="check-title-big">招聘职位</view>
  33. <view class="check-select" @click="!isDisabledid && goJob()" :class="{ disabled: isDisabledid }">
  34. <view class="select-txt">{{ jobInfo.ruleClassifyName }}</view>
  35. <u-icon name="arrow-down" color="#D3D3D6" size="22"></u-icon>
  36. </view>
  37. <view class="check-title-big">岗位描述</view>
  38. <view class="check-select" @click="goJobContent">
  39. <view class="select-txt" v-if="textList.length > 0">
  40. <view v-for="(item, index) in textList" :key="index">
  41. {{ item }}
  42. </view>
  43. </view>
  44. <view class="select-txt" v-else>介绍工作内容、职位要求</view>
  45. <u-icon name="arrow-down" color="#D3D3D6" size="22"></u-icon>
  46. </view>
  47. <!-- <view class="check-select" @click="goJobContent">
  48. <view class="select-txt">{{ this.text ? this.text : "介绍工作内容、职位要求" }}</view>
  49. <u-icon name="arrow-down" color="#D3D3D6" size="22"></u-icon>
  50. </view> -->
  51. <view class="txt-desc">注:职位名称、职位类型等发布后不可修改</view>
  52. </view>
  53. </view>
  54. <view class="submit-btn" @click="goJobPostingSecond">下一步</view>
  55. </view>
  56. </template>
  57. <script>
  58. import navBar from "@/components/nav-bar/index.vue";
  59. export default {
  60. data() {
  61. return {
  62. selectedValue: 0, // 默认选中值
  63. peopleList: ["社招全职", "应届生校园招聘", "实习生招聘", "兼职招聘"],
  64. check: 0,
  65. isDisabled: false,
  66. isDisabledid: false,
  67. isCompanyVip: 0,
  68. vipDueTimes: 0,
  69. postPushId: "",
  70. update: "",
  71. vipPostTimes: 0,
  72. text: "",
  73. textList: [],
  74. status: "",
  75. companyName: "",
  76. companyId: "",
  77. isBack: true,
  78. numList: [{
  79. name: "填写基本信息",
  80. },
  81. {
  82. name: "选择职位要求",
  83. },
  84. ],
  85. jobInfo: {
  86. ruleClassifyId: '',
  87. ruleClassifyName: '请选择要招聘的职位',
  88. price: ''
  89. }
  90. };
  91. },
  92. components: {
  93. navBar,
  94. },
  95. onLoad(options) {
  96. if (options.isBack == 'false') {
  97. this.isBack = false;
  98. }
  99. // 接收上个页面传递的公司名称参数
  100. if (options.postPushId) {
  101. this.postPushId = options.postPushId
  102. this.getInfo()
  103. }
  104. if (options.type) {
  105. this.update = decodeURIComponent(options.type);
  106. this.isDisabled = true;
  107. }
  108. if (options.companyName) {
  109. this.companyName = decodeURIComponent(options.companyName);
  110. }
  111. else {
  112. this.companyName = uni.getStorageSync('companyName')
  113. }
  114. this.descListener = uni.$on("jobDescUpdated", (data) => {
  115. this.text = data.desc; // 赋值给当前页变量
  116. this.textList = this.text.split('\n').filter(i => i.trim());
  117. });
  118. this.onJobEvent = (data) => {
  119. console.log('接收从B页传来的数据:', data)
  120. this.jobInfo = data
  121. }
  122. uni.$on('jobs', this.onJobEvent)
  123. if (options.companyId) {
  124. this.companyId = options.companyId;
  125. }
  126. else {
  127. this.companyId = uni.getStorageSync('companyId')
  128. }
  129. if (options.status) {
  130. this.status = options.status;
  131. }
  132. this.isCompanyVip = uni.getStorageSync('isCompanyVip') || 0
  133. this.vipDueTimes = uni.getStorageSync('vipDueTimes') || 0
  134. this.vipPostTimes = uni.getStorageSync('vipPostTimes') || 0
  135. console.log('接收的公司名称:', this.companyName);
  136. console.log("收到岗位描述数据:", this.text);
  137. console.log('接收的公司ID:', this.companyId);
  138. console.log('接收的公司状态:', this.status);
  139. },
  140. onUnload() {
  141. // 页面卸载时移除监听,避免内存泄漏
  142. uni.$off('jobs', this.onJobEvent);
  143. },
  144. methods: {
  145. goBusinessLicense() {
  146. uni.navigateTo({
  147. url: "/pages/my/businessLicense"
  148. });
  149. },
  150. checkPeople(index) {
  151. this.check = index;
  152. },
  153. goJob() {
  154. uni.navigateTo({
  155. url: "/package/jobIntention/jobList",
  156. });
  157. },
  158. goJobContent() {
  159. uni.navigateTo({
  160. url: `/package/jobIntention/editJob?text=${this.text}`,
  161. });
  162. },
  163. /**
  164. * 获取岗位详情
  165. */
  166. getInfo() {
  167. this.$Request.getT("/app/postPush/selectPostPushDetails", {
  168. // userId:uni.getStorageSync('userId'),
  169. postPushId: this.postPushId
  170. }).then(res => {
  171. if (res.code == 0) {
  172. this.jobInfo = res.data
  173. this.text = res.data.positionDetails
  174. if (!this.jobInfo?.ruleClassifyId) {
  175. this.isDisabledid = false
  176. } else {
  177. this.isDisabledid = true
  178. }
  179. }
  180. })
  181. },
  182. //radio 选中变化时触发
  183. onRadioChange(e) {
  184. // 获取选中的值
  185. // 根据值做不同处理
  186. if (this.selectedValue === 0) {
  187. console.log('选中了:普通岗位招聘');
  188. // 执行普通岗位招聘的逻辑
  189. } else if (this.selectedValue === 1) {
  190. console.log('选中了:急聘');
  191. if (!this.isCompanyVip) {
  192. uni.showToast({
  193. title: '对不起,您还不是会员,不能发布急聘。',
  194. icon: 'none',
  195. duration: 2000
  196. });
  197. return
  198. }
  199. if (this.vipDueTimes < 1) {
  200. uni.showToast({
  201. title: '对不起,您的次数已经用完,不能发布。',
  202. icon: 'none',
  203. duration: 2000
  204. });
  205. return
  206. }
  207. // 执行急聘的逻辑
  208. }
  209. this.selectedValue = e.detail.value;
  210. },
  211. //提交
  212. goJobPostingSecond() {
  213. // 显示加载中
  214. uni.showLoading({
  215. title: '提交中...'
  216. });
  217. //校验数据
  218. // 校验数据
  219. const validate = () => {
  220. // 2. 校验岗位描述(positionDetails)
  221. if (!this.text || this.text.trim() === '') {
  222. uni.hideLoading();
  223. uni.showToast({
  224. title: '岗位描述不能为空',
  225. icon: 'none',
  226. duration: 2000
  227. });
  228. return false;
  229. }
  230. if (this.text.length > 2000) {
  231. uni.hideLoading();
  232. uni.showToast({
  233. title: '岗位描述不能超过2000字',
  234. icon: 'none',
  235. duration: 2000
  236. });
  237. return false;
  238. }
  239. // 校验是否包含违规内容(简单示例,可根据实际需求扩展)
  240. const illegalChars = /QQ|微信|电话|手机号|\?/g;
  241. if (illegalChars.test(this.text)) {
  242. uni.hideLoading();
  243. uni.showToast({
  244. title: '岗位描述不能包含联系方式或特殊符号',
  245. icon: 'none',
  246. duration: 2000
  247. });
  248. return false;
  249. }
  250. // 3. 校验岗位分类信息(假设ruleClassifyId是必选)
  251. if (!this.jobInfo?.ruleClassifyId) {
  252. uni.hideLoading();
  253. uni.showToast({
  254. title: '请选择岗位分类',
  255. icon: 'none',
  256. duration: 2000
  257. });
  258. return false;
  259. }
  260. if (!this.jobInfo?.ruleClassifyName || this.jobInfo?.ruleClassifyName == '请选择要招聘的职位') {
  261. uni.hideLoading();
  262. uni.showToast({
  263. title: '岗位分类名称异常,请重新选择',
  264. icon: 'none',
  265. duration: 2000
  266. });
  267. return false;
  268. }
  269. // 4. 校验orderId(如果有实际业务含义,可根据需求调整)
  270. // if (!this.orderId || this.orderId < 1) {
  271. // uni.hideLoading();
  272. // uni.showToast({
  273. // title: '订单信息异常',
  274. // icon: 'none',
  275. // duration: 2000
  276. // });
  277. // return false;
  278. // }
  279. // 所有校验通过
  280. return true;
  281. };
  282. // 执行校验,通过后再提交
  283. if (!validate()) {
  284. return; // 校验失败,终止提交
  285. }
  286. if (this.selectedValue == 1) {//急聘刚
  287. if (!this.isCompanyVip) {
  288. uni.showToast({
  289. title: '对不起,您还不是会员,不能发布急聘。',
  290. icon: 'none',
  291. duration: 2000
  292. });
  293. return
  294. }
  295. if (this.vipDueTimes < 1) {
  296. uni.showToast({
  297. title: '对不起,您的次数已经用完,不能发布。',
  298. icon: 'none',
  299. duration: 2000
  300. });
  301. return
  302. }
  303. }
  304. const data = {
  305. postPushId: this.postPushId,
  306. type: this.check,
  307. isDue: this.selectedValue,
  308. // companyId: (this.companyId === undefined || this.companyId === 'undefined') ? '' : this.companyId,
  309. positionDetails: this.text,
  310. ruleClassifyId: this.jobInfo.ruleClassifyId,
  311. ruleClassifyName: this.jobInfo.ruleClassifyName,
  312. orderId: 1
  313. }
  314. // 发送请求
  315. this.$Request.postJson("/app/postPush/savePostPush", data)
  316. .then((res) => {
  317. uni.hideLoading();
  318. if (res.code === 0) {
  319. uni.showToast({
  320. title: '提交成功',
  321. icon: 'success'
  322. });
  323. console.log("sssssss", this.companyId)
  324. var pid = res.data || ""
  325. if (!pid) {
  326. uni.showToast({
  327. title: '系统错误,请重新提交',
  328. icon: 'none'
  329. });
  330. return
  331. }
  332. // 提交成功后跳转到职位发布页面
  333. setTimeout(() => {
  334. uni.redirectTo({
  335. url: "/pages/my/jobPostingSecond?pid=" + pid + '&companyId=' +
  336. this.companyId + "&status=" + this
  337. .status + "&companyName=" + this.companyName + '&type=' + this.update + '&workData=' + JSON.stringify(this.jobInfo) + '&isBack=' + true + '&ruleClassifyId=' + this.jobInfo.ruleClassifyId
  338. });
  339. }, 1500);
  340. } else {
  341. uni.showToast({
  342. title: res.msg || '提交失败,请重试',
  343. icon: 'none'
  344. });
  345. }
  346. })
  347. .catch((err) => {
  348. uni.hideLoading();
  349. console.error('请求失败:', err);
  350. uni.showToast({
  351. title: '网络异常,请稍后重试',
  352. icon: 'none'
  353. });
  354. });
  355. }
  356. },
  357. };
  358. </script>
  359. <style lang="scss" scoped>
  360. .switch-roles {
  361. background-color: #fff;
  362. position: absolute;
  363. left: 0;
  364. right: 0;
  365. top: 0;
  366. bottom: 0;
  367. display: flex;
  368. flex-direction: column;
  369. .roles-content {
  370. width: 100%;
  371. flex: 1;
  372. overflow: hidden;
  373. overflow-y: auto;
  374. .content {
  375. padding: 40rpx;
  376. box-sizing: border-box;
  377. display: flex;
  378. flex-direction: column;
  379. align-items: center;
  380. justify-content: center;
  381. .title {
  382. color: #333;
  383. width: 100%;
  384. font-family: DM Sans;
  385. font-size: 40rpx;
  386. font-weight: 600;
  387. }
  388. .desc {
  389. color: rgba(102, 102, 102, 1);
  390. width: 100%;
  391. font-family: DM Sans;
  392. font-size: 24rpx;
  393. font-weight: 400;
  394. line-height: 32rpx;
  395. letter-spacing: 0.5%;
  396. text-align: left;
  397. padding: 20rpx 0;
  398. box-sizing: border-box;
  399. }
  400. .check-title {
  401. width: 100%;
  402. color: rgba(31, 44, 55, 1);
  403. font-family: DM Sans;
  404. font-size: 28rpx;
  405. font-weight: 500;
  406. line-height: 44rpx;
  407. margin-top: 20rpx;
  408. margin-bottom: 16rpx;
  409. }
  410. .check-title-big {
  411. color: rgba(58, 57, 67, 1);
  412. font-family: DM Sans;
  413. font-size: 36rpx;
  414. font-weight: 500;
  415. line-height: 48rpx;
  416. width: 100%;
  417. padding: 20rpx 0;
  418. box-sizing: border-box;
  419. }
  420. .check-select {
  421. width: 100%;
  422. display: flex;
  423. justify-content: space-between;
  424. align-items: center;
  425. border-radius: 12rpx;
  426. box-shadow: 0px 16rpx 300rpx 0px rgba(0, 0, 0, 0.06);
  427. background: rgba(255, 255, 255, 1);
  428. padding: 32rpx 47rpx;
  429. box-sizing: border-box;
  430. .select-txt {}
  431. }
  432. /* 禁用状态样式 */
  433. .check-select.disabled {
  434. background-color: #f5f5f5;
  435. opacity: 0.6;
  436. pointer-events: none;
  437. /* 防止点击穿透 */
  438. }
  439. .check-select.disabled .select-txt {
  440. color: #999;
  441. /* 文字变灰 */
  442. }
  443. .check-select.disabled u-icon {
  444. color: #ccc;
  445. /* 图标变灰 */
  446. }
  447. /* 禁用状态样式 */
  448. .check-box.disabled {
  449. opacity: 0.6;
  450. }
  451. .check-box.disabled .check-item {
  452. pointer-events: none;
  453. background-color: #e9e9e9;
  454. color: #999;
  455. }
  456. .check-box.disabled .check-item.is-check {
  457. background-color: #b3d1ff;
  458. color: #666;
  459. }
  460. .radioseletvi {
  461. position: relative;
  462. }
  463. .radioseletview {
  464. display: flex;
  465. flex-direction: column;
  466. justify-content: space-between;
  467. font-size: 14px;
  468. }
  469. .radioselet {
  470. display: block;
  471. margin-top: 10px;
  472. }
  473. .radio-size {
  474. transform: scale(0.5);
  475. /* 放大到1.5倍,可根据需要调整数值 */
  476. /* 可选:调整位置避免偏移 */
  477. }
  478. .check-box {
  479. width: 100%;
  480. display: grid;
  481. grid-template-columns: repeat(2, 1fr);
  482. gap: 24rpx;
  483. .check-item {
  484. border-radius: 16rpx;
  485. background: rgba(245, 248, 254, 1);
  486. color: rgba(153, 153, 153, 1);
  487. font-family: DM Sans;
  488. font-size: 28rpx;
  489. font-weight: 400;
  490. line-height: 44rpx;
  491. text-align: center;
  492. padding: 12rpx 48rpx;
  493. box-sizing: border-box;
  494. }
  495. .is-check {
  496. box-sizing: border-box;
  497. border: 1rpx solid #016bf6;
  498. border-radius: 16rpx;
  499. background: rgba(252, 233, 220, 1);
  500. color: #016bf6;
  501. }
  502. }
  503. }
  504. }
  505. .step {
  506. width: 100%;
  507. padding: 32rpx 0;
  508. box-sizing: border-box;
  509. }
  510. .submit-btn {
  511. flex-shrink: 0;
  512. border-radius: 999px;
  513. box-shadow: 0px 2px 4px 0px rgba(9, 196, 116, 0.3);
  514. background: linear-gradient(90deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%);
  515. color: rgba(255, 255, 255, 1);
  516. font-family: DM Sans;
  517. font-size: 32rpx;
  518. font-weight: 400;
  519. line-height: 48rpx;
  520. display: flex;
  521. justify-content: center;
  522. align-items: center;
  523. padding: 16rpx 32rpx;
  524. box-sizing: border-box;
  525. margin: 60rpx 20rpx;
  526. }
  527. .txt-desc {
  528. color: rgba(102, 102, 102, 1);
  529. font-family: DM Sans;
  530. font-size: 24rpx;
  531. font-weight: 400;
  532. line-height: 32rpx;
  533. text-align: left;
  534. width: 100%;
  535. margin-top: 20rpx;
  536. }
  537. }
  538. </style>