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