setup.vue 16 KB

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