basicInfo.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  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. uni.showToast({
  317. title: '保存成功',
  318. icon: "none"
  319. })
  320. if (this.scene == 1) {
  321. uni.navigateTo({
  322. url: `/pages/public/improvePrompt?scene=${this.scene}`
  323. });
  324. } else if (!this.$queue.getData('userType')) {
  325. // 没有角色类型
  326. this.toSelectUserType()
  327. } else {
  328. // 实际开发中可以在这里添加跳转逻辑
  329. uni.$emit('updateResume')
  330. setTimeout(function() {
  331. uni.navigateBack()
  332. }, 1000)
  333. }
  334. // this.setResume()
  335. // 保存成功后,删除首次进入“稍后填写”保存的数据
  336. if (this.$queue.getData('temp_baseInfo')) {
  337. this.$queue.remove('temp_baseInfo')
  338. }
  339. } else {
  340. uni.showToast({
  341. title: res.msg,
  342. icon: "none"
  343. })
  344. }
  345. })
  346. }
  347. }
  348. });
  349. }
  350. },
  351. // 注册时跳转选择角色页面
  352. toSelectUserType() {
  353. uni.reLaunch({
  354. url: '/pages/my/jobApplicant/guidePage'
  355. })
  356. },
  357. // 稍后填写
  358. handleIgnore() {
  359. this.$queue.setData('temp_baseInfo', {
  360. userName: this.userName,
  361. avatar: this.avatar,
  362. sex: this.sex,
  363. weChatNum: this.weChatNum,
  364. isAnonymous: this.isAnonymous ? 1 : 0,
  365. resumesStatus: this.selectedJobStatus,
  366. resumesPhone: this.phone,
  367. birthday: this.birthDateText,
  368. resumesEmail: this.email,
  369. ifExp: this.ifExp
  370. })
  371. this.toSelectUserType()
  372. },
  373. // setResume() {
  374. // let data = {
  375. // resumesStatus: this.selectedJobStatus,
  376. // resumesPhone: this.phone,
  377. // birthday: this.birthDateText,
  378. // resumesEmail:this.email,
  379. // ifExp: this.ifExp
  380. // }
  381. // this.$Request.postJson("/app/userFirst/regist", data).then((res) => {
  382. // if (res.code == 0) {
  383. // if (this.scene == 1) {
  384. // uni.redirectTo({
  385. // url: `/pages/public/improvePrompt?scene=${this.scene}`
  386. // });
  387. // } else {
  388. // // 实际开发中可以在这里添加跳转逻辑
  389. // uni.$emit('updateResume')
  390. // setTimeout(function() {
  391. // uni.navigateBack()
  392. // }, 1000)
  393. // }
  394. // } else {
  395. // uni.showToast({
  396. // title: res.msg,
  397. // icon: "none",
  398. // });
  399. // }
  400. // });
  401. // }
  402. }
  403. }
  404. </script>
  405. <style lang="scss" scoped>
  406. .basic-info {
  407. background-color: #fff;
  408. height: 100vh;
  409. display: flex;
  410. flex-direction: column;
  411. }
  412. // 表单内容
  413. .form-content {
  414. padding: 0 40rpx 210rpx;
  415. flex: 1;
  416. display: flex;
  417. flex-direction: column;
  418. overflow: auto;
  419. .form-item {
  420. margin-bottom: 36rpx;
  421. .form-label {
  422. color: var(--Neutral/100, rgba(31, 44, 55, 1));
  423. font-family: DM Sans;
  424. font-size: 28rpx;
  425. font-weight: 500;
  426. line-height: 44rpx;
  427. letter-spacing: 0.5%;
  428. text-align: left;
  429. display: flex;
  430. align-items: center;
  431. margin-bottom: 16rpx;
  432. .required-mark {
  433. color: #FF3B30;
  434. font-size: 18px;
  435. font-weight: 600;
  436. margin-right: 8rpx;
  437. }
  438. text {
  439. color: var(--Neutral/100, rgba(31, 44, 55, 1));
  440. font-family: DM Sans;
  441. font-size: 16px;
  442. font-weight: 500;
  443. line-height: 22px;
  444. letter-spacing: 0.5%;
  445. text-align: left;
  446. }
  447. }
  448. .form-input {
  449. width: 100%;
  450. height: 75rpx;
  451. font-size: 14px;
  452. border: 1px solid rgba(227, 231, 236, 1);
  453. border-radius: 24px;
  454. color: rgba(23, 23, 37, 1);
  455. padding: 0 16px;
  456. box-sizing: border-box;
  457. }
  458. .form-display {
  459. color: rgba(23, 23, 37, 1);
  460. font-family: DM Sans;
  461. font-size: 16px;
  462. font-weight: 400;
  463. line-height: 22px;
  464. letter-spacing: 0%;
  465. text-align: left;
  466. padding: 15px 0px;
  467. }
  468. // 头像样式
  469. .avatar-container {
  470. display: flex;
  471. align-items: center;
  472. .user-avatar {
  473. width: 80rpx;
  474. height: 80rpx;
  475. border-radius: 50%;
  476. margin-right: 24rpx;
  477. }
  478. .tip {
  479. font-size: 20rpx;
  480. line-height: 44rpx;
  481. color: rgba(1, 107, 246, 1);
  482. }
  483. }
  484. // 日期选择器样式
  485. .date-picker {
  486. display: flex;
  487. align-items: center;
  488. justify-content: space-between;
  489. height: 75rpx;
  490. font-size: 14px;
  491. border: 1px solid rgba(227, 231, 236, 1);
  492. border-radius: 24px;
  493. color: rgba(23, 23, 37, 1);
  494. padding: 12px 16px;
  495. .date-text {
  496. color: rgba(23, 23, 37, 1);
  497. font-family: DM Sans;
  498. font-size: 14px;
  499. font-weight: 400;
  500. line-height: 22px;
  501. letter-spacing: 0%;
  502. text-align: left;
  503. }
  504. }
  505. // 下拉选择器样式
  506. .select-picker {
  507. display: flex;
  508. align-items: center;
  509. justify-content: space-between;
  510. height: 75rpx;
  511. font-size: 14px;
  512. border: 1px solid rgba(227, 231, 236, 1);
  513. border-radius: 24px;
  514. color: rgba(23, 23, 37, 1);
  515. padding: 12px 16px;
  516. .select-text {
  517. color: rgba(23, 23, 37, 1);
  518. font-family: DM Sans;
  519. font-size: 14px;
  520. font-weight: 400;
  521. line-height: 22px;
  522. letter-spacing: 0%;
  523. text-align: left;
  524. }
  525. }
  526. .u-checkbox {
  527. padding-bottom: 0;
  528. }
  529. // 手机号
  530. .phone-number {
  531. height: 48rpx;
  532. font-family: DM Sans;
  533. font-size: 24rpx;
  534. font-weight: bold;
  535. color: #333;
  536. line-height: 48rpx;
  537. }
  538. // 出生年月placeholder样式
  539. .placeholder-text {
  540. color: #999;
  541. }
  542. }
  543. }
  544. // 保存按钮
  545. .button-section {
  546. position: fixed;
  547. left: 0;
  548. right: 0;
  549. bottom: 0;
  550. // height: 210rpx;
  551. box-shadow: 0px -4px 16px 0px rgba(0, 0, 0, 0.04);
  552. background: rgba(255, 255, 255, 1);
  553. .link-btn {
  554. font-size: 32rpx;
  555. line-height: 1;
  556. text-align: center;
  557. color: rgba(1, 107, 246, 1);
  558. padding-top: 28rpx;
  559. }
  560. .btn {
  561. width: 600rpx;
  562. height: 88rpx;
  563. border-radius: 100px;
  564. background: var(--线性渐变, linear-gradient(90.00deg, rgba(13, 39, 247, 1),rgba(19, 193, 234, 1) 100%));
  565. font-size: 32rpx;
  566. font-weight: bold;
  567. line-height: 88rpx;
  568. text-align: center;
  569. color: #fff;
  570. margin: 32rpx auto 32rpx;
  571. }
  572. }
  573. // 求职状态选择器样式
  574. .job-status-picker {
  575. background: #fff;
  576. border-radius: 42rpx 42rpx 0 0;
  577. .picker-header {
  578. padding: 40rpx 40rpx 20rpx 40rpx;
  579. text-align: center;
  580. border-bottom: 1px solid #f0f0f0;
  581. .picker-title {
  582. color: rgba(23, 23, 37, 1);
  583. font-family: DM Sans;
  584. font-size: 18px;
  585. font-weight: 600;
  586. line-height: 26px;
  587. letter-spacing: 0%;
  588. text-align: center;
  589. }
  590. }
  591. .picker-content {
  592. padding: 20rpx 40rpx 40rpx 40rpx;
  593. .status-option {
  594. padding: 30rpx 0;
  595. border-bottom: 1px solid #f0f0f0;
  596. &:last-child {
  597. border-bottom: none;
  598. }
  599. &.active {
  600. background-color: rgba(0, 122, 255, 0.05);
  601. }
  602. .option-left {
  603. display: flex;
  604. align-items: center;
  605. .radio-btn {
  606. width: 40rpx;
  607. height: 40rpx;
  608. border-radius: 50%;
  609. border: 2px solid #e0e0e0;
  610. display: flex;
  611. align-items: center;
  612. justify-content: center;
  613. margin-right: 20rpx;
  614. &.checked {
  615. background-color: #007AFF;
  616. border-color: #007AFF;
  617. }
  618. }
  619. .option-text {
  620. flex: 1;
  621. color: rgba(23, 23, 37, 1);
  622. font-family: DM Sans;
  623. font-size: 16px;
  624. font-weight: 400;
  625. line-height: 22px;
  626. letter-spacing: 0%;
  627. text-align: left;
  628. }
  629. .recommend-tag {
  630. background-color: #007AFF;
  631. border-radius: 8rpx;
  632. padding: 4rpx 12rpx;
  633. margin-left: 16rpx;
  634. text {
  635. color: #fff;
  636. font-family: DM Sans;
  637. font-size: 12px;
  638. font-weight: 500;
  639. line-height: 16px;
  640. letter-spacing: 0%;
  641. text-align: center;
  642. }
  643. }
  644. }
  645. }
  646. }
  647. }
  648. // 权限弹窗页面
  649. .popup-content {
  650. height: 100vh;
  651. .popup-text {
  652. font-size: 32rpx;
  653. padding-left: 32rpx;
  654. padding-right: 32rpx;
  655. }
  656. }
  657. </style>