basicInfo.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  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. value: '4',
  163. text: '实习',
  164. recommended: false
  165. }
  166. ]
  167. }
  168. },
  169. onLoad(options) {
  170. // #ifdef APP-PLUS
  171. let systemInfo = uni.getSystemInfoSync();
  172. this.BarHeight = systemInfo.statusBarHeight;
  173. // #endif
  174. if (options && options.resumesStatus)
  175. this.selectedJobStatus = options.resumesStatus
  176. if (options && options.birthday)
  177. this.birthDateText = options.birthday
  178. if (options && options.ifExp)
  179. this.ifExp = options.ifExp
  180. if (options && options.resumesPhone)
  181. this.phone = options.resumesPhone
  182. if (options && options.resumesEmail)
  183. this.email = options.resumesEmail
  184. this.getUserInfo()
  185. },
  186. methods: {
  187. goBack() {
  188. uni.navigateBack();
  189. },
  190. // 选择头像
  191. async chooseAvatar() {
  192. // 1. 检查权限状态
  193. const hasPermission = await this.$queue.checkPermission(
  194. 'camera',
  195. '选择/拍摄照片需要相机/相册权限,用于上传用户头像',
  196. this
  197. );
  198. // 2. 如果未授权或者用户拒绝,显示提示
  199. if (!hasPermission) {
  200. return;
  201. }
  202. // 3. 调用系统选择图片(系统弹框会出现,让用户授权)
  203. uni.chooseImage({
  204. count: 1,
  205. sizeType: ['compressed'],
  206. sourceType: ['album', 'camera'],
  207. success: (res) => {
  208. // 上传图片
  209. this.$queue.uploadFile(res.tempFilePaths[0], (path) => {
  210. if (path) this.avatar = path;
  211. });
  212. // 上传成功隐藏提示
  213. this.$refs.permission.close();
  214. },
  215. fail: (err) => {
  216. console.log('用户拒绝或取消选择', err);
  217. // 用户拒绝仍然保持提示文字
  218. }
  219. });
  220. },
  221. // 日期选择确认
  222. onDateConfirm(e) {
  223. const {
  224. year,
  225. month,
  226. day
  227. } = e;
  228. this.birthDateText = `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
  229. this.showDatePicker = false;
  230. },
  231. // 显示求职状态选择器
  232. showJobStatusPicker() {
  233. this.showJobStatusModal = true;
  234. },
  235. // 选择求职状态
  236. selectJobStatus(item) {
  237. this.selectedJobStatus = item.value;
  238. this.showJobStatusModal = false;
  239. // 可以在这里添加保存状态的逻辑
  240. console.log('选择的求职状态:', item);
  241. },
  242. getUserInfo() {
  243. let userId = uni.getStorageSync('userId')
  244. this.$Request.get("/app/user/selectUserById").then(res => {
  245. if (res.code == 0) {
  246. this.weChatNum = res.data.weChatNum
  247. this.sex = res.data.sex
  248. this.age = res.data.age
  249. this.avatar = res.data.avatar;
  250. this.userName = res.data.userName;
  251. this.phone = res.data.phone
  252. }
  253. uni.hideLoading();
  254. });
  255. },
  256. // 保存
  257. messagebtn() {
  258. if (!this.userName) {
  259. // this.$queue.showToast('用户名不能为空');
  260. uni.showToast({
  261. title: "用户名不能为空",
  262. icon: "none"
  263. })
  264. } else if (!this.phone) {
  265. // this.$queue.showToast('用户名不能为空');
  266. uni.showToast({
  267. title: "联系电话不能为空",
  268. icon: "none"
  269. })
  270. } else if (!this.birthDateText) {
  271. uni.showToast({
  272. title: "生日不能为空",
  273. icon: "none"
  274. })
  275. }else if(!this.email){
  276. this.$queue.showToast('邮箱不能为空')
  277. } else {
  278. this.age = this.$queue.calculateAgeFromBirthday(this.birthDateText) || 0
  279. let that = this
  280. uni.showModal({
  281. title: '温馨提示',
  282. content: '确定保存信息',
  283. success: e => {
  284. if (e.confirm) {
  285. that.$Request.postJson("/app/user/updateUser", {
  286. userName: that.userName,
  287. avatar: that.avatar,
  288. sex: that.sex,
  289. age: that.age,
  290. weChatNum: that.weChatNum
  291. }).then(res => {
  292. if (res.code === 0) {
  293. uni.showToast({
  294. title: '保存成功',
  295. icon: "none"
  296. })
  297. that.setResume()
  298. } else {
  299. uni.showToast({
  300. title: res.msg,
  301. icon: "none"
  302. })
  303. }
  304. })
  305. }
  306. }
  307. });
  308. }
  309. },
  310. setResume() {
  311. let data = {
  312. resumesStatus: this.selectedJobStatus,
  313. resumesPhone: this.phone,
  314. birthday: this.birthDateText,
  315. resumesEmail:this.email,
  316. ifExp: this.ifExp
  317. }
  318. this.$Request.postJson("/app/userFirst/regist", data).then((res) => {
  319. if (res.code == 0) {
  320. // 实际开发中可以在这里添加跳转逻辑
  321. uni.$emit('updateResume')
  322. setTimeout(function() {
  323. uni.navigateBack()
  324. }, 1000)
  325. } else {
  326. uni.showToast({
  327. title: res.msg,
  328. icon: "none",
  329. });
  330. }
  331. });
  332. }
  333. }
  334. }
  335. </script>
  336. <style lang="scss" scoped>
  337. .basic-info {
  338. background-color: #fff;
  339. height: 100vh;
  340. display: flex;
  341. flex-direction: column;
  342. }
  343. // 表单内容
  344. .form-content {
  345. padding: 0 40rpx;
  346. flex: 1;
  347. display: flex;
  348. flex-direction: column;
  349. overflow: auto;
  350. .form-item {
  351. margin-bottom: 30rpx;
  352. .form-label {
  353. color: var(--Neutral/100, rgba(31, 44, 55, 1));
  354. font-family: DM Sans;
  355. font-size: 16px;
  356. font-weight: 500;
  357. line-height: 22px;
  358. letter-spacing: 0.5%;
  359. text-align: left;
  360. display: flex;
  361. align-items: center;
  362. margin-bottom: 20rpx;
  363. .required-mark {
  364. color: #FF3B30;
  365. font-size: 18px;
  366. font-weight: 600;
  367. margin-right: 8rpx;
  368. }
  369. text {
  370. color: var(--Neutral/100, rgba(31, 44, 55, 1));
  371. font-family: DM Sans;
  372. font-size: 16px;
  373. font-weight: 500;
  374. line-height: 22px;
  375. letter-spacing: 0.5%;
  376. text-align: left;
  377. }
  378. }
  379. .form-input {
  380. width: 100%;
  381. height: 75rpx;
  382. font-size: 14px;
  383. border: 1px solid rgba(227, 231, 236, 1);
  384. border-radius: 24px;
  385. color: rgba(23, 23, 37, 1);
  386. padding: 0 16px;
  387. box-sizing: border-box;
  388. }
  389. .form-display {
  390. color: rgba(23, 23, 37, 1);
  391. font-family: DM Sans;
  392. font-size: 16px;
  393. font-weight: 400;
  394. line-height: 22px;
  395. letter-spacing: 0%;
  396. text-align: left;
  397. padding: 15px 0px;
  398. }
  399. // 头像样式
  400. .avatar-container {
  401. position: relative;
  402. display: inline-block;
  403. .user-avatar {
  404. width: 80rpx;
  405. height: 80rpx;
  406. border-radius: 50%;
  407. }
  408. .edit-avatar-icon {
  409. position: absolute;
  410. bottom: 10rpx;
  411. left: 60rpx;
  412. width: 25rpx;
  413. height: 25rpx;
  414. border-radius: 50%;
  415. display: flex;
  416. align-items: center;
  417. justify-content: center;
  418. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  419. }
  420. }
  421. // 日期选择器样式
  422. .date-picker {
  423. display: flex;
  424. align-items: center;
  425. justify-content: space-between;
  426. height: 75rpx;
  427. font-size: 14px;
  428. border: 1px solid rgba(227, 231, 236, 1);
  429. border-radius: 24px;
  430. color: rgba(23, 23, 37, 1);
  431. padding: 12px 16px;
  432. .date-text {
  433. color: rgba(23, 23, 37, 1);
  434. font-family: DM Sans;
  435. font-size: 14px;
  436. font-weight: 400;
  437. line-height: 22px;
  438. letter-spacing: 0%;
  439. text-align: left;
  440. }
  441. }
  442. // 下拉选择器样式
  443. .select-picker {
  444. display: flex;
  445. align-items: center;
  446. justify-content: space-between;
  447. height: 75rpx;
  448. font-size: 14px;
  449. border: 1px solid rgba(227, 231, 236, 1);
  450. border-radius: 24px;
  451. color: rgba(23, 23, 37, 1);
  452. padding: 12px 16px;
  453. .select-text {
  454. color: rgba(23, 23, 37, 1);
  455. font-family: DM Sans;
  456. font-size: 14px;
  457. font-weight: 400;
  458. line-height: 22px;
  459. letter-spacing: 0%;
  460. text-align: left;
  461. }
  462. }
  463. }
  464. }
  465. // 保存按钮
  466. .save-button {
  467. // position: fixed;
  468. // left: 0;
  469. // right: 0;
  470. height: 120rpx;
  471. margin: 0 60rpx 60rpx;
  472. border-radius: 24px;
  473. background: #007AFF;
  474. display: flex;
  475. align-items: center;
  476. justify-content: center;
  477. .save-text {
  478. color: rgba(255, 255, 255, 1);
  479. font-family: DM Sans;
  480. font-size: 18px;
  481. font-weight: 400;
  482. line-height: 24px;
  483. letter-spacing: 0.5%;
  484. text-align: left;
  485. }
  486. }
  487. // 求职状态选择器样式
  488. .job-status-picker {
  489. background: #fff;
  490. border-radius: 42rpx 42rpx 0 0;
  491. .picker-header {
  492. padding: 40rpx 40rpx 20rpx 40rpx;
  493. text-align: center;
  494. border-bottom: 1px solid #f0f0f0;
  495. .picker-title {
  496. color: rgba(23, 23, 37, 1);
  497. font-family: DM Sans;
  498. font-size: 18px;
  499. font-weight: 600;
  500. line-height: 26px;
  501. letter-spacing: 0%;
  502. text-align: center;
  503. }
  504. }
  505. .picker-content {
  506. padding: 20rpx 40rpx 40rpx 40rpx;
  507. .status-option {
  508. padding: 30rpx 0;
  509. border-bottom: 1px solid #f0f0f0;
  510. &:last-child {
  511. border-bottom: none;
  512. }
  513. &.active {
  514. background-color: rgba(0, 122, 255, 0.05);
  515. }
  516. .option-left {
  517. display: flex;
  518. align-items: center;
  519. .radio-btn {
  520. width: 40rpx;
  521. height: 40rpx;
  522. border-radius: 50%;
  523. border: 2px solid #e0e0e0;
  524. display: flex;
  525. align-items: center;
  526. justify-content: center;
  527. margin-right: 20rpx;
  528. &.checked {
  529. background-color: #007AFF;
  530. border-color: #007AFF;
  531. }
  532. }
  533. .option-text {
  534. flex: 1;
  535. color: rgba(23, 23, 37, 1);
  536. font-family: DM Sans;
  537. font-size: 16px;
  538. font-weight: 400;
  539. line-height: 22px;
  540. letter-spacing: 0%;
  541. text-align: left;
  542. }
  543. .recommend-tag {
  544. background-color: #007AFF;
  545. border-radius: 8rpx;
  546. padding: 4rpx 12rpx;
  547. margin-left: 16rpx;
  548. text {
  549. color: #fff;
  550. font-family: DM Sans;
  551. font-size: 12px;
  552. font-weight: 500;
  553. line-height: 16px;
  554. letter-spacing: 0%;
  555. text-align: center;
  556. }
  557. }
  558. }
  559. }
  560. }
  561. }
  562. // 权限弹窗页面
  563. .popup-content {
  564. height: 100vh;
  565. .popup-text {
  566. font-size: 32rpx;
  567. padding-left: 32rpx;
  568. padding-right: 32rpx;
  569. }
  570. }
  571. </style>