userinfo.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. <template>
  2. <view class="page-container" :style="{ paddingTop: statusBarHeight + 'px' }">
  3. <!-- 顶部导航栏 -->
  4. <navBar title="基本信息"></navBar>
  5. <!-- <nav-bar title="基本信息"></nav-bar> -->
  6. <view class="usermain">
  7. <view class="usermain-item ">
  8. <view class="form-label">
  9. <text class="required-mark">*</text>
  10. <text class="usermain-item-title">头像</text>
  11. </view>
  12. <view class="avatar-wrapper flex align-center" @click="uploadImg()">
  13. <!-- #ifndef MP-WEIXIN -->
  14. <view>
  15. <image src="../../static/logo.png" v-if="avatar == null" mode=""
  16. style="width: 78rpx;height: 78rpx;border-radius: 50%;"></image>
  17. <image v-else :src="avatar" mode="" style="width: 78rpx;height: 78rpx;border-radius: 50%;">
  18. </image>
  19. </view>
  20. <!-- #endif -->
  21. <view class="tip">重新上传</view>
  22. </view>
  23. </view>
  24. <view class="usermain-item item-padding ">
  25. <view class="form-label">
  26. <text class="required-mark">*</text>
  27. <text class="usermain-item-title">姓名</text>
  28. </view>
  29. <view class="cu-form-group">
  30. <input type="nickname" v-model="userName" placeholder="请输入用户名" />
  31. </view>
  32. </view>
  33. <view class="usermain-item item-padding ">
  34. <view class="form-label">
  35. <text class="required-mark">*</text>
  36. <view class="usermain-item-title">性别</view>
  37. </view>
  38. <view>
  39. <view class="cu-form-group">
  40. <u-radio-group v-model="sex">
  41. <u-radio shape="circle" :name="1">男</u-radio>
  42. <u-radio shape="circle" active-color="red" :name="2">女</u-radio>
  43. </u-radio-group>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="usermain-item item-padding ">
  48. <view class="usermain-item-title">年龄</view>
  49. <view>
  50. <view class="cu-form-group">
  51. <input v-model="age" />
  52. </view>
  53. </view>
  54. </view>
  55. <view class="usermain-item item-padding contact-structure">
  56. <view class="usermain-item-title">联系方式</view>
  57. <view class="contact-wrapper">
  58. <text class="phone-display">{{ phoneWithMask }}</text>
  59. <!-- <text class="modify-link" @click="modifyPhone">修改手机号</text> -->
  60. </view>
  61. </view>
  62. <!-- <view class="usermain-item item-padding">
  63. <view >姓名</view>
  64. <view class="cu-form-group">
  65. <input v-model="realName" placeholder="请填写您的真实姓名" />
  66. </view>
  67. </view> -->
  68. <view class="usermain-item item-padding ">
  69. <view class="usermain-item-title">微信号码</view>
  70. <view>
  71. <view class="cu-form-group">
  72. <input v-model="weChatNum" placeholder="请输入微信号码,方便给求职者交换微信联系" />
  73. </view>
  74. </view>
  75. </view>
  76. <!-- 接收简历邮箱 -->
  77. <view class="usermain-item item-padding">
  78. <view class="usermain-item-title">接收简历邮箱</view>
  79. <view>
  80. <view class="cu-form-group">
  81. <input v-model="hrEmail" placeholder="建议录入企业邮箱" />
  82. </view>
  83. </view>
  84. </view>
  85. <!-- 我的公司 -->
  86. <view class="usermain-item item-padding">
  87. <view class="usermain-item-title">我的公司</view>
  88. <view>
  89. <view class="form-input-selector" @click="selectCompany">
  90. <text v-if="selectedCompany">{{ selectedCompany }}</text>
  91. <text v-else class="placeholder">请选择公司</text>
  92. <u-icon name="arrow-right" color="#999" size="36"></u-icon>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 我的职务 -->
  97. <view class="usermain-item item-padding">
  98. <view class="usermain-item-title">我的职务</view>
  99. <view>
  100. <view class="form-input-selector">
  101. <!-- <text v-if="selectedPosition">{{ selectedPosition }}</text>
  102. <text v-else class="placeholder">请选择职务</text>
  103. <u-icon name="arrow-down" color="#999" size="36"></u-icon> -->
  104. <input type="text" v-model="hrPosition" placeholder="请输入职务" @input="filterSymbols"
  105. style="width: 100%;" :key='inputKey' />
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. <view class="button-section">
  111. <view class="submit-btn" @click="messagebtn()">保存</view>
  112. </view>
  113. <!-- 权限说明弹窗 -->
  114. <u-popup mode="top" ref="permission">
  115. <view class="popup-content">
  116. <view class="popup-text-permission">选择/拍摄照片需要相机/相册权限,用于上传用户头像</view>
  117. </view>
  118. </u-popup>
  119. </view>
  120. </template>
  121. <script>
  122. import configdata from '../../common/config.js';
  123. import navBar from "@/components/nav-bar/index.vue";
  124. export default {
  125. components: {
  126. navBar
  127. },
  128. data() {
  129. return {
  130. statusBarHeight: 0, // 状态栏高度
  131. phone: '',
  132. weChatNum: '', //微信号
  133. email: '', //接收简历邮箱
  134. selectedCompany: '深圳市汉瑞国际猎头服务有限公司', // 我的公司
  135. selectedPosition: '人事总监', // 我的职务
  136. avatar: '../../static/logo.png',
  137. userName: '',
  138. nickName: '',
  139. userId: '',
  140. realName: '',
  141. weChatId: "",
  142. password: '',
  143. platform: '',
  144. createTime: '',
  145. money: '',
  146. jiFen: '',
  147. status: '',
  148. zhiFuBao: '',
  149. zhiFuBaoName: '',
  150. sex: 1,
  151. age: 0,
  152. hrInfo: {},
  153. hrPosition: '',
  154. hrEmail: '',
  155. inputKey: ''
  156. };
  157. },
  158. computed: {
  159. phoneWithMask() {
  160. if (this.phone && this.phone.length >= 11) {
  161. return this.phone.substring(0, 3) + '******' + this.phone.substring(9);
  162. }
  163. return this.phone || '请设置手机号';
  164. }
  165. },
  166. onLoad(e) {
  167. // 获取状态栏高度
  168. let systemInfo = uni.getSystemInfoSync();
  169. this.statusBarHeight = systemInfo.statusBarHeight || 0;
  170. // this.getUserInfo()
  171. // this.getUserHr()
  172. this.inputKey = new Date().getTime()
  173. // this.avatar = uni.getStorageSync('avatar')
  174. },
  175. onShow() {
  176. this.getUserInfo()
  177. this.getUserHr()
  178. },
  179. methods: {
  180. filterSymbols(e) {
  181. // 使用正则表达式过滤掉所有符号(只保留中文、英文、数字)
  182. let value = e.detail.value
  183. // 允许:中文、英文、数字
  184. let filteredValue = value.replace(/[^\u4e00-\u9fa5a-zA-Z0-9]/g, '')
  185. console.log(this.hrPosition);
  186. // 如果值被修改了
  187. this.hrPosition = filteredValue
  188. if (value !== filteredValue) {
  189. this.inputKey = new Date().getTime()
  190. uni.showToast({
  191. title: '禁止输入符号',
  192. icon: "none"
  193. })
  194. }
  195. },
  196. // 返回上一页
  197. goBack() {
  198. uni.navigateBack();
  199. },
  200. // 修改手机号
  201. modifyPhone() {
  202. console.log('点击修改手机号,当前手机号:', this.phone);
  203. const url = `/pages/my/userphone?currentPhone=${this.phone}`;
  204. console.log('跳转路径:', url);
  205. uni.navigateTo({
  206. url: url,
  207. });
  208. },
  209. // 选择公司
  210. selectCompany() {
  211. uni.navigateTo({
  212. url: '/pages/my/myCompany'
  213. });
  214. },
  215. // 选择职务
  216. selectPosition() {
  217. // 这里可以跳转到职务选择页面或显示职务选择弹窗
  218. console.log('选择职务');
  219. },
  220. onChooseAvatar(e) {
  221. let that = this;
  222. let token = uni.getStorageSync('token');
  223. uni.uploadFile({
  224. url: that.config("APIHOST1") +
  225. '/alioss/upload', //真实的接口地址
  226. filePath: e.detail.avatarUrl,
  227. header: {
  228. token: token
  229. },
  230. name: 'file',
  231. success: uploadFileRes => {
  232. let url = JSON.parse(uploadFileRes.data);
  233. that.avatar = url.data
  234. uni.hideLoading();
  235. }
  236. });
  237. },
  238. goMyAddress() {
  239. uni.navigateTo({
  240. url: '../jifen/myaddress'
  241. });
  242. },
  243. async uploadImg() {
  244. let token = uni.getStorageSync('token')
  245. if (!token) {
  246. this.goLoginInfo();
  247. return;
  248. }
  249. let that = this;
  250. var url = null;
  251. uni.showActionSheet({
  252. // itemList按钮的文字接受的是数组
  253. itemList: ["查看头像", "从相册选择图片"],
  254. async success(e) {
  255. var index = e.tapIndex
  256. if (index === 0) {
  257. // 用户点击了预览当前图片
  258. // 可以自己实现当前头像链接的读取
  259. let url = that.avatar;
  260. let arr = []
  261. arr.push(url)
  262. uni.previewImage({
  263. // 预览功能图片也必须是数组的
  264. urls: arr
  265. })
  266. } else if (index === 1) {
  267. const hasPermission = await that.$queue.checkPermission(
  268. 'camera',
  269. '选择/拍摄照片需要相机/相册权限,用于上传用户头像',
  270. that
  271. );
  272. // 2. 如果未授权或者用户拒绝,显示提示
  273. if (!hasPermission) {
  274. return;
  275. }
  276. uni.chooseImage({
  277. count: 1, //默认9
  278. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  279. sourceType: ['album','camera'], //从相册选择
  280. success: function (res) {
  281. uni.showLoading({
  282. title: '上传中...'
  283. });
  284. let token = uni.getStorageSync('token');
  285. let userId = uni.getStorageSync('userId');
  286. uni.uploadFile({
  287. url: that.config("APIHOST1") +
  288. '/alioss/upload', //真实的接口地址
  289. filePath: res.tempFilePaths[0],
  290. header: {
  291. token: token
  292. },
  293. name: 'file',
  294. success: uploadFileRes => {
  295. url = JSON.parse(uploadFileRes.data);
  296. that.avatar = url.data
  297. uni.hideLoading();
  298. }
  299. });
  300. }
  301. });
  302. }
  303. }
  304. })
  305. },
  306. config: function (name) {
  307. var info = null;
  308. if (name) {
  309. var name2 = name.split("."); //字符分割
  310. if (name2.length > 1) {
  311. info = configdata[name2[0]][name2[1]] || null;
  312. } else {
  313. info = configdata[name] || null;
  314. }
  315. if (info == null) {
  316. let web_config = cache.get("web_config");
  317. if (web_config) {
  318. if (name2.length > 1) {
  319. info = web_config[name2[0]][name2[1]] || null;
  320. } else {
  321. info = web_config[name] || null;
  322. }
  323. }
  324. }
  325. }
  326. return info;
  327. },
  328. getUserHr() {
  329. this.$Request.get("/app/HrFirst/getUserHr").then(res => {
  330. if (res.code === 0) {
  331. this.hrInfo = res.data.HrEntity
  332. this.hrPosition = res.data.HrEntity.hrPosition
  333. this.hrEmail = res.data.HrEntity.hrEmail
  334. }
  335. })
  336. },
  337. getUserInfo() {
  338. let userId = uni.getStorageSync('userId')
  339. this.$Request.get("/app/user/selectUserById").then(res => {
  340. if (res.code == 0) {
  341. this.$queue.setData('avatar', res.data.avatar);
  342. this.$queue.setData('userId', res.data.userId);
  343. this.$queue.setData('userName', res.data.userName);
  344. this.$queue.setData('phone', res.data.phone);
  345. this.$queue.setData('age', res.data.age);
  346. this.$queue.setData('weChatNum', res.data.weChatNum)
  347. this.weChatNum = res.data.weChatNum
  348. this.sex = res.data.sex
  349. this.age = res.data.age
  350. this.phone = res.data.phone;
  351. this.avatar = res.data.avatar;
  352. this.userName = res.data.userName;
  353. if (this.userName == null) {
  354. this.userName = res.data.nickName;
  355. } else {
  356. this.userName = res.data.userName;
  357. }
  358. this.selectedCompany = this.$queue.getData('companyName')
  359. }
  360. uni.hideLoading();
  361. });
  362. },
  363. // 保存
  364. messagebtn() {
  365. if (!this.userName) {
  366. // this.$queue.showToast('用户名不能为空');
  367. uni.showToast({
  368. title: "用户名不能为空",
  369. icon: "none"
  370. })
  371. } else if (!this.phone) {
  372. // this.$queue.showToast('用户名不能为空');
  373. uni.showToast({
  374. title: "联系电话不能为空",
  375. icon: "none"
  376. })
  377. } else {
  378. let that = this
  379. uni.showModal({
  380. title: '温馨提示',
  381. content: '确定保存信息',
  382. success: e => {
  383. if (e.confirm) {
  384. let phone = that.$queue.getData('newPhone') ? this.$queue.getData('newPhone') :
  385. that.phone
  386. that.$Request.postJson("/app/user/updateUser", {
  387. userName: that.userName,
  388. avatar: that.avatar,
  389. phone,
  390. sex: that.sex,
  391. age: that.age,
  392. weChatNum: that.weChatNum
  393. }).then(res => {
  394. if (res.code === 0) {
  395. that.$Request.postJson("/app/HrFirst/addHr", {
  396. hrPosition: this.hrPosition,
  397. hrEmail: this.hrEmail,
  398. avatar: this.avatar
  399. }).then(res => {
  400. if (res.code === 0) {
  401. uni.showToast({
  402. title: '保存成功',
  403. icon: "none"
  404. })
  405. that.getUserInfo()
  406. setTimeout(function () {
  407. uni.navigateBack()
  408. }, 1000)
  409. } else {
  410. uni.showToast({
  411. title: res.msg,
  412. icon: "none"
  413. })
  414. }
  415. })
  416. // uni.showToast({
  417. // title: '保存成功',
  418. // icon: "none"
  419. // })
  420. // that.getUserInfo()
  421. // setTimeout(function() {
  422. // uni.navigateBack()
  423. // }, 1000)
  424. } else {
  425. uni.showToast({
  426. title: res.msg,
  427. icon: "none"
  428. })
  429. }
  430. })
  431. }
  432. }
  433. });
  434. }
  435. }
  436. },
  437. // userphone(){
  438. // uni.navigateTo({
  439. // url:'/pages/my/userphone'
  440. // })
  441. // }
  442. };
  443. </script>
  444. <style lang="scss" scoped>
  445. .page-container {
  446. height: 100vh;
  447. display: flex;
  448. flex-direction: column;
  449. box-sizing: border-box;
  450. }
  451. button::after {
  452. border: none;
  453. background-color: none;
  454. }
  455. button {
  456. position: relative;
  457. display: block;
  458. margin-left: auto;
  459. margin-right: auto;
  460. padding-left: 0px;
  461. padding-right: 0px;
  462. box-sizing: border-box;
  463. text-decoration: none;
  464. line-height: 1.35;
  465. overflow: hidden;
  466. color: #666666;
  467. /* background-color: #fff; */
  468. background-color: rgba(255, 255, 255, 0) !important;
  469. width: 100%;
  470. height: 100%;
  471. }
  472. .usermain {
  473. flex: 1;
  474. overflow: auto;
  475. padding-bottom: 40rpx;
  476. }
  477. .usermain-item {
  478. display: flex;
  479. flex-direction: column;
  480. margin: 0 40rpx;
  481. padding: 20rpx 0;
  482. // border-bottom: 1rpx solid rgba(229, 229, 229, 0.3);
  483. gap: 16rpx;
  484. }
  485. .usermain-item-title {
  486. color: rgba(31, 44, 55, 1);
  487. font-family: DM Sans;
  488. font-size: 28rpx;
  489. font-weight: 500;
  490. line-height: 44rpx;
  491. text-align: left;
  492. }
  493. .usermain-item.item-padding {
  494. /* padding: 0; */
  495. }
  496. .cu-form-group {
  497. padding: 0;
  498. background: #ffffff;
  499. text-align: right;
  500. }
  501. .cu-form-group input {
  502. background: #ffffff;
  503. font-size: 28rpx;
  504. /* color: #fff; */
  505. }
  506. /* 姓名字段样式 - 参考basicInfo.vue */
  507. .usermain-item .form-label {
  508. color: rgba(31, 44, 55, 1);
  509. font-family: DM Sans;
  510. font-size: 32rpx;
  511. font-weight: 500;
  512. line-height: 44rpx;
  513. letter-spacing: 0.5%;
  514. text-align: left;
  515. display: flex;
  516. align-items: center;
  517. margin-bottom: 16rpx;
  518. }
  519. .usermain-item .required-mark {
  520. color: #FF3B30;
  521. font-size: 36rpx;
  522. font-weight: 600;
  523. margin-right: 8rpx;
  524. }
  525. .usermain-item .cu-form-group {
  526. background: transparent;
  527. text-align: left;
  528. padding: 0;
  529. }
  530. .usermain-item .cu-form-group input {
  531. width: 100%;
  532. height: 68rpx;
  533. font-size: 28rpx;
  534. border: 1rpx solid rgba(227, 231, 236, 1);
  535. border-radius: 44rpx;
  536. color: rgba(23, 23, 37, 1);
  537. padding: 0 32rpx;
  538. background: #ffffff;
  539. font-family: DM Sans;
  540. font-weight: 400;
  541. }
  542. .usermain-item .cu-form-group input::placeholder {
  543. color: rgba(155, 155, 155, 1);
  544. font-size: 28rpx;
  545. }
  546. /* 联系方式样式 */
  547. .contact-structure {
  548. border-bottom: none !important;
  549. }
  550. .contact-wrapper {
  551. display: flex;
  552. align-items: center;
  553. justify-content: space-between;
  554. padding: 0;
  555. margin-top: 8rpx;
  556. }
  557. .phone-display {
  558. color: rgba(23, 23, 37, 1);
  559. font-family: DM Sans;
  560. font-size: 28rpx;
  561. font-weight: 400;
  562. line-height: 40rpx;
  563. letter-spacing: 0.5%;
  564. }
  565. .modify-link {
  566. color: rgba(24, 144, 255, 1);
  567. font-family: DM Sans;
  568. font-size: 28rpx;
  569. font-weight: 400;
  570. line-height: 40rpx;
  571. letter-spacing: 0.5%;
  572. cursor: pointer;
  573. text-decoration: none;
  574. }
  575. .modify-link:active {
  576. opacity: 0.7;
  577. }
  578. /* 头像编辑图标样式 */
  579. .avatar-wrapper {
  580. .tip {
  581. font-size: 20rpx;
  582. line-height: 44rpx;
  583. color: rgba(1, 107, 246, 1);
  584. margin-left: 24rpx;
  585. }
  586. }
  587. .avatar-button {
  588. position: relative;
  589. padding: 0;
  590. margin: 0;
  591. background: transparent;
  592. border: none;
  593. }
  594. .button-section {
  595. padding: 28rpx 40rpx;
  596. box-shadow: 0px -4px 16px 0px rgba(0, 0, 0, 0.04);
  597. }
  598. .submit-btn {
  599. flex-shrink: 0;
  600. border-radius: 999px;
  601. box-shadow: 0px -4px 16px 0px rgba(0, 0, 0, 0.04);
  602. background: linear-gradient(90deg, rgba(13, 39, 247, 1), rgba(19, 193, 234, 1) 100%);
  603. color: rgba(255, 255, 255, 1);
  604. font-family: DM Sans;
  605. font-size: 32rpx;
  606. font-weight: 400;
  607. line-height: 48rpx;
  608. display: flex;
  609. justify-content: center;
  610. align-items: center;
  611. padding: 16rpx 32rpx;
  612. box-sizing: border-box;
  613. }
  614. /* 选择器样式 - 参考workExperience页面 */
  615. .form-input-selector {
  616. width: 100%;
  617. height: 68rpx;
  618. padding: 0 40rpx;
  619. border: 1px solid rgba(227, 231, 236, 1);
  620. border-radius: 24px;
  621. background: rgba(255, 255, 255, 1);
  622. display: flex;
  623. align-items: center;
  624. justify-content: space-between;
  625. cursor: pointer;
  626. transition: all 0.2s ease;
  627. .placeholder {
  628. color: #999999;
  629. font-family: DM Sans;
  630. font-size: 28rpx;
  631. font-weight: 400;
  632. line-height: 40rpx;
  633. }
  634. text {
  635. color: rgba(23, 23, 37, 1);
  636. font-family: DM Sans;
  637. font-size: 28rpx;
  638. font-weight: 400;
  639. line-height: 40rpx;
  640. }
  641. }
  642. .arrow-down {
  643. color: rgba(96, 98, 102, 1);
  644. font-size: 24rpx;
  645. font-weight: 400;
  646. transform: scale(1.5);
  647. }
  648. .selector-group:active {
  649. background: #f5f7fa !important;
  650. transform: scale(0.99);
  651. }
  652. </style>