userinfo.vue 18 KB

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