jobPosting.vue 14 KB

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