basicInfo.vue 18 KB

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