setup.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  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. }else{
  416. uni.showToast({
  417. title: res.msg||'返回失败',
  418. icon: 'none'
  419. })
  420. }
  421. });
  422. },
  423. clear() {
  424. var that = this
  425. this.$queue.appConfirm('是否确认清除数据缓存?', function (res) {
  426. if (res) {
  427. uni.clearStorage();
  428. that.storageSize = `0.00MB`
  429. }
  430. })
  431. }
  432. },
  433. // userphone(){
  434. // uni.navigateTo({
  435. // url:'/pages/my/userphone'
  436. // })
  437. // }
  438. };
  439. </script>
  440. <style lang="scss" scoped>
  441. page {
  442. /* background: #1c1b20; */
  443. }
  444. .navbar {
  445. // position: fixed;
  446. // top: 0;
  447. // left: 0;
  448. // right: 0;
  449. // z-index: 999;
  450. background: #fff;
  451. // padding: 0 0 40rpx 20rpx;
  452. .navbar-content {
  453. display: flex;
  454. align-items: center;
  455. justify-content: space-between;
  456. padding: 0 30rpx;
  457. height: 88rpx;
  458. .navbar-left {
  459. width: 60rpx;
  460. height: 60rpx;
  461. display: flex;
  462. align-items: center;
  463. justify-content: center;
  464. }
  465. .navbar-title {
  466. color: rgba(23, 23, 37, 1);
  467. font-family: DM Sans;
  468. font-size: 36rpx;
  469. font-weight: 700;
  470. line-height: 52rpx;
  471. letter-spacing: 0%;
  472. text-align: center;
  473. }
  474. .navbar-right {
  475. width: 60rpx;
  476. height: 60rpx;
  477. }
  478. }
  479. }
  480. button::after {
  481. border: none;
  482. background-color: none;
  483. }
  484. button {
  485. position: relative;
  486. display: block;
  487. margin-left: auto;
  488. margin-right: auto;
  489. padding-left: 0px;
  490. padding-right: 0px;
  491. box-sizing: border-box;
  492. text-decoration: none;
  493. line-height: 1.35;
  494. overflow: hidden;
  495. color: #666666;
  496. /* background-color: #fff; */
  497. background-color: rgba(255, 255, 255, 0) !important;
  498. width: 100%;
  499. height: 100%;
  500. }
  501. .usermain {
  502. background: #ffffff;
  503. /* color: #fff; */
  504. margin-top: 20rpx;
  505. /* 为固定导航栏留出空间 */
  506. }
  507. .usermain-item {
  508. display: flex;
  509. justify-content: space-between;
  510. margin: 0 40rpx;
  511. padding: 30rpx 0;
  512. // border-bottom: 1rpx solid rgba(229, 229, 229, 0.3);
  513. gap: 16rpx;
  514. }
  515. .usermain-item-title {
  516. color: rgba(31, 44, 55, 1);
  517. font-family: DM Sans;
  518. font-size: 28rpx;
  519. font-weight: 500;
  520. line-height: 44rpx;
  521. text-align: left;
  522. }
  523. .usermain-item.item-padding {
  524. /* padding: 0; */
  525. }
  526. .cu-form-group {
  527. padding: 0;
  528. background: #ffffff;
  529. text-align: right;
  530. }
  531. .cu-form-group input {
  532. background: #ffffff;
  533. font-size: 28rpx;
  534. /* color: #fff; */
  535. }
  536. /* 姓名字段样式 - 参考basicInfo.vue */
  537. .usermain-item .form-label {
  538. color: rgba(31, 44, 55, 1);
  539. font-family: DM Sans;
  540. font-size: 32rpx;
  541. font-weight: 500;
  542. line-height: 44rpx;
  543. letter-spacing: 0.5%;
  544. text-align: left;
  545. display: flex;
  546. align-items: center;
  547. margin-bottom: 16rpx;
  548. }
  549. .usermain-item .required-mark {
  550. color: #FF3B30;
  551. font-size: 36rpx;
  552. font-weight: 600;
  553. margin-right: 8rpx;
  554. }
  555. .usermain-item .cu-form-group {
  556. background: transparent;
  557. text-align: left;
  558. padding: 0;
  559. }
  560. .usermain-item .cu-form-group input {
  561. width: 100%;
  562. height: 68rpx;
  563. font-size: 28rpx;
  564. border: 1rpx solid rgba(227, 231, 236, 1);
  565. border-radius: 44rpx;
  566. color: rgba(23, 23, 37, 1);
  567. padding: 0 32rpx;
  568. background: #ffffff;
  569. font-family: DM Sans;
  570. font-weight: 400;
  571. }
  572. .usermain-item .cu-form-group input::placeholder {
  573. color: rgba(155, 155, 155, 1);
  574. font-size: 28rpx;
  575. }
  576. /* 联系方式样式 */
  577. .contact-structure {
  578. border-bottom: none !important;
  579. }
  580. .contact-wrapper {
  581. display: flex;
  582. align-items: center;
  583. justify-content: space-between;
  584. padding: 0;
  585. margin-top: 8rpx;
  586. }
  587. .phone-display {
  588. color: rgba(23, 23, 37, 1);
  589. font-family: DM Sans;
  590. font-size: 28rpx;
  591. font-weight: 400;
  592. line-height: 40rpx;
  593. letter-spacing: 0.5%;
  594. }
  595. .modify-link {
  596. color: rgba(24, 144, 255, 1);
  597. font-family: DM Sans;
  598. font-size: 28rpx;
  599. font-weight: 400;
  600. line-height: 40rpx;
  601. letter-spacing: 0.5%;
  602. cursor: pointer;
  603. text-decoration: none;
  604. }
  605. .modify-link:active {
  606. opacity: 0.7;
  607. }
  608. /* 头像编辑图标样式 */
  609. .avatar-wrapper {
  610. position: relative;
  611. display: inline-block;
  612. }
  613. .edit-avatar-icon {
  614. position: absolute;
  615. bottom: 10rpx;
  616. right: 2rpx;
  617. width: 24rpx;
  618. height: 24rpx;
  619. // background: #fff;
  620. border-radius: 50%;
  621. display: flex;
  622. align-items: center;
  623. justify-content: center;
  624. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  625. }
  626. .avatar-button {
  627. position: relative;
  628. padding: 0;
  629. margin: 0;
  630. background: transparent;
  631. border: none;
  632. }
  633. .footer-btn {
  634. margin-top: 40rpx;
  635. padding-bottom: 40rpx;
  636. }
  637. .footer-btn .usermain-btn {
  638. color: rgba(255, 255, 255, 1);
  639. background: rgba(1, 107, 246, 1);
  640. text-align: center;
  641. width: 90%;
  642. height: 80rpx;
  643. font-size: 32rpx;
  644. line-height: 80rpx;
  645. margin: 20rpx auto;
  646. border-radius: 40rpx;
  647. }
  648. /* 选择器样式 - 参考workExperience页面 */
  649. .form-input-selector {
  650. width: 100%;
  651. height: 68rpx;
  652. padding: 0 40rpx;
  653. border: 1px solid rgba(227, 231, 236, 1);
  654. border-radius: 24px;
  655. background: rgba(255, 255, 255, 1);
  656. display: flex;
  657. align-items: center;
  658. justify-content: space-between;
  659. cursor: pointer;
  660. transition: all 0.2s ease;
  661. .placeholder {
  662. color: #999999;
  663. font-family: DM Sans;
  664. font-size: 28rpx;
  665. font-weight: 400;
  666. line-height: 40rpx;
  667. }
  668. text {
  669. color: rgba(23, 23, 37, 1);
  670. font-family: DM Sans;
  671. font-size: 28rpx;
  672. font-weight: 400;
  673. line-height: 40rpx;
  674. }
  675. }
  676. .arrow-down {
  677. color: rgba(96, 98, 102, 1);
  678. font-size: 24rpx;
  679. font-weight: 400;
  680. transform: scale(1.5);
  681. }
  682. .selector-group:active {
  683. background: #f5f7fa !important;
  684. transform: scale(0.99);
  685. }
  686. .version{
  687. text-align: center;
  688. margin-top: 300rpx;
  689. color: #ccc;
  690. font-size: 24rpx;
  691. text{
  692. margin-left: 20rpx;
  693. }
  694. }
  695. </style>