setup.vue 16 KB

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