basicInfo.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. <template>
  2. <view class="basic-info">
  3. <navBar title="基本信息" color="#000" />
  4. <!-- 表单内容 -->
  5. <view class="form-content">
  6. <!-- 头像 -->
  7. <view class="form-item">
  8. <view class="form-label">头像</view>
  9. <view @click="chooseAvatar" class="avatar-container">
  10. <image :src="avatar?avatar:'../../static/logo.png'" class="user-avatar" mode="aspectFill"></image>
  11. <view class="edit-avatar-icon">
  12. <image src="../../static/images/index/Combined-Shape.svg" style="width: 32rpx;height: 32rpx;"
  13. mode=""></image>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 姓名 -->
  18. <view class="form-item">
  19. <view class="form-label">
  20. <text class="required-mark">*</text>
  21. <text>姓名</text>
  22. </view>
  23. <input class="form-input" type="text" placeholder="请输入姓名" v-model="userName" />
  24. </view>
  25. <!-- 性别 -->
  26. <view class="form-item">
  27. <view class="form-label">
  28. <text class="required-mark">*</text>
  29. <text>性别</text>
  30. </view>
  31. <u-radio-group v-model="sex" direction="row">
  32. <u-radio name="1" activeColor="#007AFF">男</u-radio>
  33. <u-radio name="2" activeColor="#007AFF">女</u-radio>
  34. </u-radio-group>
  35. </view>
  36. <!-- 联系方式 -->
  37. <view class="form-item">
  38. <view class="form-label">联系方式</view>
  39. <input class="form-input" type="text" placeholder="请输入手机号" v-model="phone" />
  40. </view>
  41. <!-- 微信号码 -->
  42. <view class="form-item">
  43. <view class="form-label">微信号码</view>
  44. <input class="form-input" type="text" placeholder="请输入微信号码,方便给求职者交换微信联系" v-model="weChatNum" />
  45. </view>
  46. <!-- 出生年月 -->
  47. <view class="form-item">
  48. <view class="form-label">
  49. <text class="required-mark">*</text>
  50. <text>出生年月</text>
  51. </view>
  52. <view class="date-picker" @click="showDatePicker = true">
  53. <text class="date-text">{{ birthDateText }}</text>
  54. <u-icon name="arrow-down" color="#999" size="24"></u-icon>
  55. </view>
  56. <u-picker :default-time="birthDateText" v-model="showDatePicker" mode="time" :params="dateParams"
  57. @confirm="onDateConfirm"></u-picker>
  58. </view>
  59. <view class="form-item">
  60. <view class="form-label">
  61. <text class="required-mark">*</text>
  62. <text>邮箱</text>
  63. </view>
  64. <input class="form-input" type="text" placeholder="请输入邮箱号码,方便接收offer" v-model="email" />
  65. </view>
  66. <!-- 求职状态 -->
  67. <view class="form-item">
  68. <view class="form-label">
  69. <text class="required-mark">*</text>
  70. <text>求职状态</text>
  71. </view>
  72. <view class="select-picker" @click="showJobStatusPicker">
  73. <text class="select-text">{{ jobStatusList[selectedJobStatus].text }}</text>
  74. <u-icon name="arrow-down" color="#999" size="24"></u-icon>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- 保存按钮 -->
  79. <view @click="messagebtn" class="save-button">
  80. <text class="save-text">保存</text>
  81. </view>
  82. <!-- 求职状态选择器 -->
  83. <u-popup v-model="showJobStatusModal" mode="bottom" border-radius="42" height="auto"
  84. :safe-area-inset-bottom="true">
  85. <view class="job-status-picker">
  86. <view class="picker-header">
  87. <text class="picker-title">求职状态</text>
  88. </view>
  89. <view class="picker-content">
  90. <view class="status-option" :class="{ active: selectedJobStatus == item.value }"
  91. v-for="item in jobStatusList" :key="item.value" @click="selectJobStatus(item)">
  92. <view class="option-left">
  93. <view class="radio-btn" :class="{ checked: selectedJobStatus == item.value }">
  94. <u-icon v-if="selectedJobStatus == item.value" name="checkmark" color="#ffffff"
  95. size="28"></u-icon>
  96. </view>
  97. <text class="option-text">{{ item.text }}</text>
  98. <view v-if="item.recommended" class="recommend-tag">
  99. <text>推荐</text>
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. </u-popup>
  106. <!-- 权限说明弹窗 -->
  107. <u-popup mode="top" ref="permission">
  108. <view class="popup-content">
  109. <view class="popup-text-permission">选择/拍摄照片需要相机/相册权限,用于上传用户头像</view>
  110. </view>
  111. </u-popup>
  112. </view>
  113. </template>
  114. <script>
  115. import navBar from "@/components/nav-bar/index.vue";
  116. export default {
  117. components: {
  118. navBar,
  119. },
  120. data() {
  121. return {
  122. BarHeight: '',
  123. weChatNum: '',
  124. email:'',
  125. sex: '',
  126. age: '',
  127. phone: '',
  128. avatar: '',
  129. ifExp: 0,
  130. userName: '',
  131. birthDateText: '1991-11-29', // 显示的日期文本
  132. showDatePicker: false, // 控制日期选择器显示
  133. dateParams: {
  134. year: true,
  135. month: true,
  136. day: true
  137. },
  138. // 求职状态相关
  139. showJobStatusModal: false,
  140. selectedJobStatus: 0,
  141. jobStatusList: [{
  142. value: '0',
  143. text: '离职-随时到岗',
  144. recommended: true
  145. },
  146. {
  147. value: '1',
  148. text: '在职-月内到岗',
  149. recommended: true
  150. },
  151. {
  152. value: '2',
  153. text: '在职-考虑机会',
  154. recommended: false
  155. },
  156. {
  157. value: '3',
  158. text: '在职-暂不考虑',
  159. recommended: false
  160. }
  161. ]
  162. }
  163. },
  164. onLoad(options) {
  165. // #ifdef APP-PLUS
  166. let systemInfo = uni.getSystemInfoSync();
  167. this.BarHeight = systemInfo.statusBarHeight;
  168. // #endif
  169. if (options && options.resumesStatus)
  170. this.selectedJobStatus = options.resumesStatus
  171. if (options && options.birthday)
  172. this.birthDateText = options.birthday
  173. if (options && options.ifExp)
  174. this.ifExp = options.ifExp
  175. if (options && options.resumesPhone)
  176. this.phone = options.resumesPhone
  177. if (options && options.resumesEmail)
  178. this.email = options.resumesEmail
  179. this.getUserInfo()
  180. },
  181. methods: {
  182. goBack() {
  183. uni.navigateBack();
  184. },
  185. // 选择头像
  186. async chooseAvatar() {
  187. // 1. 检查权限状态
  188. const hasPermission = await this.$queue.checkPermission(
  189. 'camera',
  190. '选择/拍摄照片需要相机/相册权限,用于上传用户头像',
  191. this
  192. );
  193. // 2. 如果未授权或者用户拒绝,显示提示
  194. if (!hasPermission) {
  195. return;
  196. }
  197. // 3. 调用系统选择图片(系统弹框会出现,让用户授权)
  198. uni.chooseImage({
  199. count: 1,
  200. sizeType: ['compressed'],
  201. sourceType: ['album', 'camera'],
  202. success: (res) => {
  203. // 上传图片
  204. this.$queue.uploadFile(res.tempFilePaths[0], (path) => {
  205. if (path) this.avatar = path;
  206. });
  207. // 上传成功隐藏提示
  208. this.$refs.permission.close();
  209. },
  210. fail: (err) => {
  211. console.log('用户拒绝或取消选择', err);
  212. // 用户拒绝仍然保持提示文字
  213. }
  214. });
  215. },
  216. // 日期选择确认
  217. onDateConfirm(e) {
  218. const {
  219. year,
  220. month,
  221. day
  222. } = e;
  223. this.birthDateText = `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
  224. this.showDatePicker = false;
  225. },
  226. // 显示求职状态选择器
  227. showJobStatusPicker() {
  228. this.showJobStatusModal = true;
  229. },
  230. // 选择求职状态
  231. selectJobStatus(item) {
  232. this.selectedJobStatus = item.value;
  233. this.showJobStatusModal = false;
  234. // 可以在这里添加保存状态的逻辑
  235. console.log('选择的求职状态:', item);
  236. },
  237. getUserInfo() {
  238. let userId = uni.getStorageSync('userId')
  239. this.$Request.get("/app/user/selectUserById").then(res => {
  240. if (res.code == 0) {
  241. this.weChatNum = res.data.weChatNum
  242. this.sex = res.data.sex
  243. this.age = res.data.age
  244. this.avatar = res.data.avatar;
  245. this.userName = res.data.userName;
  246. this.phone = res.data.phone
  247. }
  248. uni.hideLoading();
  249. });
  250. },
  251. // 保存
  252. messagebtn() {
  253. if (!this.userName) {
  254. // this.$queue.showToast('用户名不能为空');
  255. uni.showToast({
  256. title: "用户名不能为空",
  257. icon: "none"
  258. })
  259. } else if (!this.phone) {
  260. // this.$queue.showToast('用户名不能为空');
  261. uni.showToast({
  262. title: "联系电话不能为空",
  263. icon: "none"
  264. })
  265. } else if (!this.birthDateText) {
  266. uni.showToast({
  267. title: "生日不能为空",
  268. icon: "none"
  269. })
  270. }else if(!this.email){
  271. this.$queue.showToast('邮箱不能为空')
  272. } else {
  273. this.age = this.$queue.calculateAgeFromBirthday(this.birthDateText) || 0
  274. let that = this
  275. uni.showModal({
  276. title: '温馨提示',
  277. content: '确定保存信息',
  278. success: e => {
  279. if (e.confirm) {
  280. that.$Request.postJson("/app/user/updateUser", {
  281. userName: that.userName,
  282. avatar: that.avatar,
  283. sex: that.sex,
  284. age: that.age,
  285. weChatNum: that.weChatNum
  286. }).then(res => {
  287. if (res.code === 0) {
  288. uni.showToast({
  289. title: '保存成功',
  290. icon: "none"
  291. })
  292. that.setResume()
  293. } else {
  294. uni.showToast({
  295. title: res.msg,
  296. icon: "none"
  297. })
  298. }
  299. })
  300. }
  301. }
  302. });
  303. }
  304. },
  305. setResume() {
  306. let data = {
  307. resumesStatus: this.selectedJobStatus,
  308. resumesPhone: this.phone,
  309. birthday: this.birthDateText,
  310. resumesEmail:this.email,
  311. ifExp: this.ifExp
  312. }
  313. this.$Request.postJson("/app/userFirst/regist", data).then((res) => {
  314. if (res.code == 0) {
  315. // 实际开发中可以在这里添加跳转逻辑
  316. uni.$emit('updateResume')
  317. setTimeout(function() {
  318. uni.navigateBack()
  319. }, 1000)
  320. } else {
  321. uni.showToast({
  322. title: res.msg,
  323. icon: "none",
  324. });
  325. }
  326. });
  327. }
  328. }
  329. }
  330. </script>
  331. <style lang="scss" scoped>
  332. .basic-info {
  333. background-color: #fff;
  334. height: 100vh;
  335. display: flex;
  336. flex-direction: column;
  337. }
  338. // 表单内容
  339. .form-content {
  340. padding: 0 40rpx;
  341. flex: 1;
  342. display: flex;
  343. flex-direction: column;
  344. overflow: auto;
  345. .form-item {
  346. margin-bottom: 30rpx;
  347. .form-label {
  348. color: var(--Neutral/100, rgba(31, 44, 55, 1));
  349. font-family: DM Sans;
  350. font-size: 16px;
  351. font-weight: 500;
  352. line-height: 22px;
  353. letter-spacing: 0.5%;
  354. text-align: left;
  355. display: flex;
  356. align-items: center;
  357. margin-bottom: 20rpx;
  358. .required-mark {
  359. color: #FF3B30;
  360. font-size: 18px;
  361. font-weight: 600;
  362. margin-right: 8rpx;
  363. }
  364. text {
  365. color: var(--Neutral/100, rgba(31, 44, 55, 1));
  366. font-family: DM Sans;
  367. font-size: 16px;
  368. font-weight: 500;
  369. line-height: 22px;
  370. letter-spacing: 0.5%;
  371. text-align: left;
  372. }
  373. }
  374. .form-input {
  375. width: 100%;
  376. height: 75rpx;
  377. font-size: 14px;
  378. border: 1px solid rgba(227, 231, 236, 1);
  379. border-radius: 24px;
  380. color: rgba(23, 23, 37, 1);
  381. padding: 0 16px;
  382. box-sizing: border-box;
  383. }
  384. .form-display {
  385. color: rgba(23, 23, 37, 1);
  386. font-family: DM Sans;
  387. font-size: 16px;
  388. font-weight: 400;
  389. line-height: 22px;
  390. letter-spacing: 0%;
  391. text-align: left;
  392. padding: 15px 0px;
  393. }
  394. // 头像样式
  395. .avatar-container {
  396. position: relative;
  397. display: inline-block;
  398. .user-avatar {
  399. width: 80rpx;
  400. height: 80rpx;
  401. border-radius: 50%;
  402. }
  403. .edit-avatar-icon {
  404. position: absolute;
  405. bottom: 10rpx;
  406. left: 60rpx;
  407. width: 25rpx;
  408. height: 25rpx;
  409. border-radius: 50%;
  410. display: flex;
  411. align-items: center;
  412. justify-content: center;
  413. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  414. }
  415. }
  416. // 日期选择器样式
  417. .date-picker {
  418. display: flex;
  419. align-items: center;
  420. justify-content: space-between;
  421. height: 75rpx;
  422. font-size: 14px;
  423. border: 1px solid rgba(227, 231, 236, 1);
  424. border-radius: 24px;
  425. color: rgba(23, 23, 37, 1);
  426. padding: 12px 16px;
  427. .date-text {
  428. color: rgba(23, 23, 37, 1);
  429. font-family: DM Sans;
  430. font-size: 14px;
  431. font-weight: 400;
  432. line-height: 22px;
  433. letter-spacing: 0%;
  434. text-align: left;
  435. }
  436. }
  437. // 下拉选择器样式
  438. .select-picker {
  439. display: flex;
  440. align-items: center;
  441. justify-content: space-between;
  442. height: 75rpx;
  443. font-size: 14px;
  444. border: 1px solid rgba(227, 231, 236, 1);
  445. border-radius: 24px;
  446. color: rgba(23, 23, 37, 1);
  447. padding: 12px 16px;
  448. .select-text {
  449. color: rgba(23, 23, 37, 1);
  450. font-family: DM Sans;
  451. font-size: 14px;
  452. font-weight: 400;
  453. line-height: 22px;
  454. letter-spacing: 0%;
  455. text-align: left;
  456. }
  457. }
  458. }
  459. }
  460. // 保存按钮
  461. .save-button {
  462. // position: fixed;
  463. // left: 0;
  464. // right: 0;
  465. height: 120rpx;
  466. margin: 0 60rpx 60rpx;
  467. border-radius: 24px;
  468. background: #007AFF;
  469. display: flex;
  470. align-items: center;
  471. justify-content: center;
  472. .save-text {
  473. color: rgba(255, 255, 255, 1);
  474. font-family: DM Sans;
  475. font-size: 18px;
  476. font-weight: 400;
  477. line-height: 24px;
  478. letter-spacing: 0.5%;
  479. text-align: left;
  480. }
  481. }
  482. // 求职状态选择器样式
  483. .job-status-picker {
  484. background: #fff;
  485. border-radius: 42rpx 42rpx 0 0;
  486. .picker-header {
  487. padding: 40rpx 40rpx 20rpx 40rpx;
  488. text-align: center;
  489. border-bottom: 1px solid #f0f0f0;
  490. .picker-title {
  491. color: rgba(23, 23, 37, 1);
  492. font-family: DM Sans;
  493. font-size: 18px;
  494. font-weight: 600;
  495. line-height: 26px;
  496. letter-spacing: 0%;
  497. text-align: center;
  498. }
  499. }
  500. .picker-content {
  501. padding: 20rpx 40rpx 40rpx 40rpx;
  502. .status-option {
  503. padding: 30rpx 0;
  504. border-bottom: 1px solid #f0f0f0;
  505. &:last-child {
  506. border-bottom: none;
  507. }
  508. &.active {
  509. background-color: rgba(0, 122, 255, 0.05);
  510. }
  511. .option-left {
  512. display: flex;
  513. align-items: center;
  514. .radio-btn {
  515. width: 40rpx;
  516. height: 40rpx;
  517. border-radius: 50%;
  518. border: 2px solid #e0e0e0;
  519. display: flex;
  520. align-items: center;
  521. justify-content: center;
  522. margin-right: 20rpx;
  523. &.checked {
  524. background-color: #007AFF;
  525. border-color: #007AFF;
  526. }
  527. }
  528. .option-text {
  529. flex: 1;
  530. color: rgba(23, 23, 37, 1);
  531. font-family: DM Sans;
  532. font-size: 16px;
  533. font-weight: 400;
  534. line-height: 22px;
  535. letter-spacing: 0%;
  536. text-align: left;
  537. }
  538. .recommend-tag {
  539. background-color: #007AFF;
  540. border-radius: 8rpx;
  541. padding: 4rpx 12rpx;
  542. margin-left: 16rpx;
  543. text {
  544. color: #fff;
  545. font-family: DM Sans;
  546. font-size: 12px;
  547. font-weight: 500;
  548. line-height: 16px;
  549. letter-spacing: 0%;
  550. text-align: center;
  551. }
  552. }
  553. }
  554. }
  555. }
  556. }
  557. // 权限弹窗页面
  558. .popup-content {
  559. height: 100vh;
  560. .popup-text {
  561. font-size: 32rpx;
  562. padding-left: 32rpx;
  563. padding-right: 32rpx;
  564. }
  565. }
  566. </style>