basicInfo.vue 15 KB

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