completeMsg.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <template>
  2. <view class="company">
  3. <nav-bar title="完善信息" color="#000"></nav-bar>
  4. <view class="company-content">
  5. <view class="company-title">完善你的招聘名片</view>
  6. <view class="company-desc">求职者更愿意主动联系名片信息完整的HR</view>
  7. <!-- 头像上传区域 -->
  8. <view class="form-label">头像</view>
  9. <view class="avatar-section">
  10. <view class="avatar-upload" @click="chooseAvatar">
  11. <view class="avatar-preview">
  12. <image v-if="avatar" :src="avatar" class="avatar-image" mode="aspectFill"></image>
  13. <image v-else src="@/static/images/jobApplicant/touxiang.svg" mode="scaleToFill"
  14. class="user-img" />
  15. </view>
  16. <view class="upload-view">上传头像</view>
  17. </view>
  18. </view>
  19. <!-- 姓名 -->
  20. <view class="form-item">
  21. <view class="form-label">填写职务</view>
  22. <u-input placeholder="真实的职务,更能赢得牛人的信任" v-model="name" :border="false" class="form-input"></u-input>
  23. </view>
  24. <!-- email -->
  25. <view class="form-item">
  26. <view class="form-label">填写email</view>
  27. <u-input placeholder="填写email,方便牛人联系" v-model="email" :border="false"
  28. :class="{ 'form-input': true, 'error': emailError }" @blur="validateEmailOnBlur"></u-input>
  29. <!-- 添加错误提示 -->
  30. <view v-if="emailError" class="error-message">
  31. {{ emailError }}
  32. </view>
  33. </view>
  34. <view class="form-item">
  35. <view class="form-label">求职者视角中的效果</view>
  36. <view class="form-border" v-for="(item, inx) in userpost" :key="inx">
  37. <view class="form-border-top">
  38. <view class="form-border-title">{{ item.ruleClassifyName }}</view>
  39. <view class="form-border-money">{{ item.salaryRange }}</view>
  40. </view>
  41. <view class="form-border-desc">{{ item.companyName }}{{ item.companyPeople }}人</view>
  42. <view class="form-border-img-name">
  43. <view class="people-img">
  44. <image v-if="item.hr != null && item.hr.hrImg" :src="item.hr.hrImg" class="avatar-image"
  45. mode="aspectFill"></image>
  46. <image v-else src="@/static/images/jobApplicant/touxiang.svg" mode="scaleToFill"
  47. class="user-img" />
  48. </view>
  49. <view class="people-name">{{ item.hr ? item.hr.hrPosition : "无" }} 招聘者</view>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="bottom-btn" @click="submithr">开始招聘</view>
  54. </view>
  55. <!-- 权限说明弹窗 -->
  56. <u-popup mode="top" ref="permission">
  57. <view class="popup-content">
  58. <view class="popup-text-permission">选择/拍摄照片需要相机/相册权限,用于上传用户头像</view>
  59. </view>
  60. </u-popup>
  61. </view>
  62. </template>
  63. <script>
  64. import navBar from "@/components/nav-bar/index.vue";
  65. export default {
  66. data() {
  67. return {
  68. avatar: "",
  69. name: "",
  70. isok: false,
  71. email: '',
  72. emailError: "", // 添加错误提示
  73. userpost: {}
  74. };
  75. },
  76. components: {
  77. navBar,
  78. },
  79. onShow() {
  80. this.getmypost()
  81. this.HrFirst()
  82. },
  83. methods: {
  84. goUploadImg() {
  85. uni.navigateTo({
  86. url: "/package/jobIntention/companyImg"
  87. });
  88. },
  89. goCompanyReview() {
  90. if (this.isok) {
  91. uni.navigateTo({
  92. url: "/package/jobIntention/companyReview",
  93. });
  94. }
  95. return uni.showToast({
  96. title: "请补全资料",
  97. icon: "none"
  98. });
  99. },
  100. // 选择头像
  101. async chooseAvatar() {
  102. var that = this
  103. /// 1. 检查权限状态
  104. const hasPermission = await this.$queue.checkPermission(
  105. 'camera',
  106. '选择/拍摄照片需要相机/相册权限,用于上传用户头像',
  107. this
  108. );
  109. // 2. 如果未授权或者用户拒绝,显示提示
  110. if (!hasPermission) {
  111. return;
  112. }
  113. uni.chooseImage({
  114. count: 1,
  115. sizeType: ["compressed"],
  116. sourceType: ["album", "camera"],
  117. success: (res) => {
  118. that.$queue.uploadFile(res.tempFilePaths[0], function (path) {
  119. console.log("上传返回?:", path)
  120. if (path) {
  121. that.avatar = path;
  122. }
  123. })
  124. },
  125. });
  126. },
  127. //提交hr 信息
  128. // 邮箱验证方法
  129. validateEmail(email) {
  130. const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
  131. return emailRegex.test(email);
  132. },
  133. // 邮箱失焦验证
  134. validateEmailOnBlur() {
  135. if (!this.email) {
  136. this.emailError = "邮箱不能为空";
  137. return;
  138. }
  139. if (!this.validateEmail(this.email)) {
  140. this.emailError = "邮箱格式不正确";
  141. } else {
  142. this.emailError = "";
  143. }
  144. },
  145. // 实时验证(可选)
  146. onEmailInput(e) {
  147. this.email = e;
  148. // 如果之前有错误,输入时清除错误提示
  149. if (this.emailError && this.email) {
  150. this.emailError = "";
  151. }
  152. },
  153. // 验证所有表单字段
  154. validateForm() {
  155. let isValid = true;
  156. // 验证头像
  157. if (!this.avatar) {
  158. uni.showToast({
  159. title: "请上传头像",
  160. icon: "none"
  161. });
  162. return false;
  163. }
  164. // 验证职务
  165. if (!this.name) {
  166. uni.showToast({
  167. title: "请输入职务",
  168. icon: "none"
  169. });
  170. return false;
  171. }
  172. // 验证邮箱
  173. if (!this.email) {
  174. this.emailError = "邮箱不能为空";
  175. uni.showToast({
  176. title: "请输入邮箱",
  177. icon: "none"
  178. });
  179. return false;
  180. }
  181. // 验证邮箱格式
  182. if (!this.validateEmail(this.email)) {
  183. this.emailError = "邮箱格式不正确";
  184. uni.showToast({
  185. title: "邮箱格式不正确",
  186. icon: "none"
  187. });
  188. return false;
  189. }
  190. this.emailError = ""; // 清除错误提示
  191. return true;
  192. },
  193. // 提交 hr 信息(修改后的版本)
  194. submithr() {
  195. // 先验证表单
  196. if (!this.validateForm()) {
  197. return;
  198. }
  199. // 构造提交数据(添加邮箱)
  200. const data = {
  201. hrImg: this.avatar, // 头像
  202. hrPosition: this.name, // 职位
  203. hrEmail: this.email // 添加邮箱
  204. };
  205. // 调用接口提交
  206. uni.showLoading({
  207. title: "提交中..."
  208. });
  209. this.$Request.postJson("/app/HrFirst/addHr", data)
  210. .then((res) => {
  211. uni.hideLoading();
  212. if (res.code === 0) {
  213. this.isok = true;
  214. uni.showToast({
  215. title: "提交成功,请开始招聘吧。",
  216. icon: "success"
  217. });
  218. uni.switchTab({
  219. url: '/pages/index/index'
  220. });
  221. } else {
  222. uni.showToast({
  223. title: res.msg || "提交失败",
  224. icon: "none"
  225. });
  226. }
  227. })
  228. .catch((err) => {
  229. uni.hideLoading();
  230. console.error("提交失败:", err);
  231. uni.showToast({
  232. title: "网络异常",
  233. icon: "none"
  234. });
  235. });
  236. },
  237. // submithr() {
  238. // // 验证必填项
  239. // if (!this.avatar) {
  240. // return uni.showToast({
  241. // title: "请上传头像",
  242. // icon: "none"
  243. // });
  244. // }
  245. // if (!this.name) {
  246. // return uni.showToast({
  247. // title: "请输入职务",
  248. // icon: "none"
  249. // });
  250. // }
  251. // // 构造提交数据
  252. // const data = {
  253. // hrImg: this.avatar, //头像
  254. // hrPosition: this.name, //职位
  255. // };
  256. // // 调用接口提交
  257. // uni.showLoading({
  258. // title: "提交中..."
  259. // });
  260. // this.$Request.postJson("/app/HrFirst/addHr", data)
  261. // .then((res) => {
  262. // uni.hideLoading();
  263. // if (res.code === 0) {
  264. // this.isok = true
  265. // uni.showToast({
  266. // title: "提交成功,请开始招聘吧。",
  267. // icon: "success"
  268. // });
  269. // // uni.navigateTo({
  270. // // url: "/package/jobIntention/companyReview",
  271. // // });
  272. // uni.switchTab({
  273. // url: '/pages/index/index'
  274. // })
  275. // } else {
  276. // uni.showToast({
  277. // title: res.msg || "提交失败",
  278. // icon: "none"
  279. // });
  280. // }
  281. // })
  282. // .catch((err) => {
  283. // uni.hideLoading();
  284. // console.error("提交失败:", err);
  285. // uni.showToast({
  286. // title: "网络异常",
  287. // icon: "none"
  288. // });
  289. // });
  290. // },
  291. //获取我发布的岗位列表
  292. getmypost() {
  293. this.$Request.get("/app/postPush/getMyPostPush", { status: "" })
  294. .then((res) => {
  295. if (res.code != 0) {
  296. uni.showToast({
  297. title: res.msg || "查询失败",
  298. icon: "none"
  299. });
  300. return;
  301. }
  302. this.userpost = res.data.records || {};
  303. if (this.userpost[0].hr) {
  304. this.name = this.userpost[0].hr.hrPosition || ""
  305. this.avatar = this.userpost[0].hr.hrImg || ""
  306. }
  307. console.log("查询我的岗位列表状态", res)
  308. })
  309. .catch((err) => {
  310. console.error("查询失败:", err);
  311. uni.showToast({
  312. title: "网络异常",
  313. icon: "none"
  314. });
  315. });
  316. },
  317. //Hr 名片
  318. HrFirst() {
  319. this.$Request.get("/app/HrFirst", "")
  320. .then((res) => {
  321. if (res.code != 0) {
  322. uni.showToast({
  323. title: res.msg || "查询失败",
  324. icon: "none"
  325. });
  326. return;
  327. }
  328. console.log("Hr 名片", res)
  329. })
  330. .catch((err) => {
  331. console.error("查询失败:", err);
  332. uni.showToast({
  333. title: "网络异常",
  334. icon: "none"
  335. });
  336. });
  337. },
  338. },
  339. };
  340. </script>
  341. <style scoped lang="scss">
  342. .company {
  343. position: absolute;
  344. left: 0;
  345. right: 0;
  346. top: 0;
  347. bottom: 0;
  348. display: flex;
  349. flex-direction: column;
  350. font-family: DM Sans;
  351. .company-content {
  352. flex: 1;
  353. padding: 40rpx;
  354. box-sizing: border-box;
  355. overflow: hidden;
  356. overflow-y: auto;
  357. .company-title {
  358. color: #333;
  359. font-size: 40rpx;
  360. font-weight: 600;
  361. margin-bottom: 20rpx;
  362. }
  363. .form-label {
  364. color: #1f2c37;
  365. font-family: DM Sans;
  366. font-size: 28rpx;
  367. font-weight: 500;
  368. line-height: 44rpx;
  369. padding-top: 30rpx;
  370. padding-bottom: 27rpx;
  371. box-sizing: border-box;
  372. }
  373. .avatar-section {
  374. display: flex;
  375. }
  376. .avatar-upload {
  377. display: flex;
  378. align-items: center;
  379. }
  380. .avatar-preview {
  381. width: 48rpx;
  382. height: 48rpx;
  383. border-radius: 50%;
  384. display: flex;
  385. align-items: center;
  386. justify-content: center;
  387. margin-right: 20rpx;
  388. }
  389. .avatar-image {
  390. width: 100%;
  391. height: 100%;
  392. border-radius: 50%;
  393. }
  394. .upload-view {
  395. color: #016bf6;
  396. font-family: DM Sans;
  397. font-size: 20rpx;
  398. font-weight: 500;
  399. line-height: 48rpx;
  400. }
  401. .form-item {
  402. padding-bottom: 24rpx;
  403. box-sizing: border-box;
  404. .job-txt {
  405. color: #016bf6;
  406. font-family: DM Sans;
  407. font-size: 20rpx;
  408. margin-left: 16rpx;
  409. }
  410. .form-border {
  411. box-sizing: border-box;
  412. border: 1rpx solid rgba(227, 231, 236, 1);
  413. border-radius: 12rpx;
  414. background: rgba(253, 253, 253, 1);
  415. padding: 36rpx;
  416. box-sizing: border-box;
  417. .form-border-top {
  418. display: flex;
  419. justify-content: space-between;
  420. align-items: center;
  421. .form-border-title {
  422. color: rgba(23, 23, 37, 1);
  423. font-family: DM Sans;
  424. font-size: 32rpx;
  425. font-weight: 700;
  426. line-height: 48rpx;
  427. }
  428. .form-border-money {
  429. color: #016bf6;
  430. font-family: DM Sans;
  431. font-size: 24rpx;
  432. font-weight: 700;
  433. line-height: 40rpx;
  434. }
  435. }
  436. .form-border-desc {
  437. color: rgba(156, 164, 171, 1);
  438. font-family: DM Sans;
  439. font-size: 24rpx;
  440. font-weight: 400;
  441. line-height: 40rpx;
  442. padding: 6rpx 0;
  443. box-sizing: border-box;
  444. }
  445. .form-border-img-name {
  446. display: flex;
  447. align-items: center;
  448. gap: 8rpx;
  449. .people-img {
  450. image {
  451. width: 40rpx;
  452. height: 40rpx;
  453. }
  454. }
  455. .people-name {
  456. color: rgba(156, 164, 171, 1);
  457. font-family: DM Sans;
  458. font-size: 16rpx;
  459. font-weight: 400;
  460. }
  461. }
  462. }
  463. }
  464. .form-item:last-child {
  465. border-bottom: none;
  466. }
  467. .form-label {
  468. color: #1f2c37;
  469. font-family: DM Sans;
  470. font-size: 28rpx;
  471. font-weight: 500;
  472. line-height: 44rpx;
  473. padding-top: 30rpx;
  474. padding-bottom: 27rpx;
  475. box-sizing: border-box;
  476. }
  477. .form-input {
  478. flex: 1;
  479. box-sizing: border-box;
  480. border: 2rpx solid #9ea1a8;
  481. border-radius: 100rpx;
  482. background: rgba(255, 255, 255, 1);
  483. padding: 0rpx 24rpx !important;
  484. }
  485. }
  486. .bottom-btn {
  487. border-radius: 999px;
  488. background: rgba(255, 102, 0, 1);
  489. display: flex;
  490. justify-content: center;
  491. align-items: center;
  492. color: rgba(255, 255, 255, 1);
  493. font-family: DM Sans;
  494. font-size: 32rpx;
  495. font-weight: 400;
  496. line-height: 48rpx;
  497. padding: 16rpx 32rpx;
  498. box-sizing: border-box;
  499. }
  500. }
  501. ::v-deep .u-input {
  502. text-align: left !important;
  503. }
  504. .error-message {
  505. color: #ff4d4f;
  506. font-size: 24rpx;
  507. margin-top: 8rpx;
  508. padding-left: 24rpx;
  509. }
  510. /* 如果有错误,可以修改输入框边框颜色 */
  511. .form-input.error {
  512. border-color: #ff4d4f !important;
  513. }
  514. </style>