setup.vue 16 KB

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