basicInfo.vue 14 KB

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