jobPosting.vue 15 KB

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