jobPosting.vue 12 KB

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