basicInfo.vue 16 KB

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