basicInfo.vue 14 KB

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