setup.vue 16 KB

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