userinfo.vue 17 KB

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