userinfo.vue 17 KB

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