basicInfo.vue 16 KB

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