setup.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  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. /* that.isLogin = true;
  369. that.userName = "登录";
  370. that.avatar = "../../static/logo.png";
  371. that.isVip = false; */
  372. // uni.reLaunch({
  373. // url: '/pages/public/selectIdentity/selectIdentity'
  374. // })
  375. } else if (res.cancel) {
  376. console.log("用户点击取消");
  377. }
  378. },
  379. });
  380. },
  381. goNavNoLogin(e) {
  382. // #ifdef MP-WEIXIN
  383. if (uni.getStorageSync("sendMsg")) {
  384. // console.log('授权+1')
  385. wx.requestSubscribeMessage({
  386. tmplIds: this.arr,
  387. success(re) {
  388. var datas = JSON.stringify(re);
  389. if (datas.indexOf("accept") != -1) {
  390. // console.log(re)
  391. }
  392. },
  393. fail: (res) => {
  394. // console.log(res)
  395. },
  396. });
  397. }
  398. // #endif
  399. uni.navigateTo({
  400. url: e,
  401. });
  402. },
  403. deleteAccountCon() {
  404. var that = this
  405. this.$queue.appConfirm('账号注销后,关联数据将永久清除,请再次确认?', function (res) {
  406. if (res)
  407. that.deleteAccount()
  408. })
  409. },
  410. deleteAccount() {
  411. var that = this
  412. this.$Request.postJson("/app/user/logout").then((res) => {
  413. //订单状态通知
  414. if (res.code == 0) {
  415. // 退出极光推送
  416. logoutJP()
  417. that.$queue.logout()
  418. uni.$emit('offLogin')
  419. uni.showToast({
  420. title: "注销成功!",
  421. icon: "none",
  422. success: () => {
  423. this.$queue.toLogin()
  424. }
  425. });
  426. }else{
  427. uni.showToast({
  428. title: res.msg||'返回失败',
  429. icon: 'none'
  430. })
  431. }
  432. });
  433. },
  434. clear() {
  435. var that = this
  436. this.$queue.appConfirm('是否确认清除数据缓存?', function (res) {
  437. if (res) {
  438. uni.clearStorage();
  439. that.storageSize = `0.00MB`
  440. }
  441. })
  442. }
  443. },
  444. // userphone(){
  445. // uni.navigateTo({
  446. // url:'/pages/my/userphone'
  447. // })
  448. // }
  449. };
  450. </script>
  451. <style lang="scss" scoped>
  452. page {
  453. /* background: #1c1b20; */
  454. }
  455. .navbar {
  456. // position: fixed;
  457. // top: 0;
  458. // left: 0;
  459. // right: 0;
  460. // z-index: 999;
  461. background: #fff;
  462. // padding: 0 0 40rpx 20rpx;
  463. .navbar-content {
  464. display: flex;
  465. align-items: center;
  466. justify-content: space-between;
  467. padding: 0 30rpx;
  468. height: 88rpx;
  469. .navbar-left {
  470. width: 60rpx;
  471. height: 60rpx;
  472. display: flex;
  473. align-items: center;
  474. justify-content: center;
  475. }
  476. .navbar-title {
  477. color: rgba(23, 23, 37, 1);
  478. font-family: DM Sans;
  479. font-size: 36rpx;
  480. font-weight: 700;
  481. line-height: 52rpx;
  482. letter-spacing: 0%;
  483. text-align: center;
  484. }
  485. .navbar-right {
  486. width: 60rpx;
  487. height: 60rpx;
  488. }
  489. }
  490. }
  491. button::after {
  492. border: none;
  493. background-color: none;
  494. }
  495. button {
  496. position: relative;
  497. display: block;
  498. margin-left: auto;
  499. margin-right: auto;
  500. padding-left: 0px;
  501. padding-right: 0px;
  502. box-sizing: border-box;
  503. text-decoration: none;
  504. line-height: 1.35;
  505. overflow: hidden;
  506. color: #666666;
  507. /* background-color: #fff; */
  508. background-color: rgba(255, 255, 255, 0) !important;
  509. width: 100%;
  510. height: 100%;
  511. }
  512. .usermain {
  513. background: #ffffff;
  514. /* color: #fff; */
  515. margin-top: 20rpx;
  516. /* 为固定导航栏留出空间 */
  517. }
  518. .usermain-item {
  519. display: flex;
  520. justify-content: space-between;
  521. margin: 0 40rpx;
  522. padding: 30rpx 0;
  523. // border-bottom: 1rpx solid rgba(229, 229, 229, 0.3);
  524. gap: 16rpx;
  525. }
  526. .usermain-item-title {
  527. color: rgba(31, 44, 55, 1);
  528. font-family: DM Sans;
  529. font-size: 28rpx;
  530. font-weight: 500;
  531. line-height: 44rpx;
  532. text-align: left;
  533. }
  534. .usermain-item.item-padding {
  535. /* padding: 0; */
  536. }
  537. .cu-form-group {
  538. padding: 0;
  539. background: #ffffff;
  540. text-align: right;
  541. }
  542. .cu-form-group input {
  543. background: #ffffff;
  544. font-size: 28rpx;
  545. /* color: #fff; */
  546. }
  547. /* 姓名字段样式 - 参考basicInfo.vue */
  548. .usermain-item .form-label {
  549. color: rgba(31, 44, 55, 1);
  550. font-family: DM Sans;
  551. font-size: 32rpx;
  552. font-weight: 500;
  553. line-height: 44rpx;
  554. letter-spacing: 0.5%;
  555. text-align: left;
  556. display: flex;
  557. align-items: center;
  558. margin-bottom: 16rpx;
  559. }
  560. .usermain-item .required-mark {
  561. color: #FF3B30;
  562. font-size: 36rpx;
  563. font-weight: 600;
  564. margin-right: 8rpx;
  565. }
  566. .usermain-item .cu-form-group {
  567. background: transparent;
  568. text-align: left;
  569. padding: 0;
  570. }
  571. .usermain-item .cu-form-group input {
  572. width: 100%;
  573. height: 68rpx;
  574. font-size: 28rpx;
  575. border: 1rpx solid rgba(227, 231, 236, 1);
  576. border-radius: 44rpx;
  577. color: rgba(23, 23, 37, 1);
  578. padding: 0 32rpx;
  579. background: #ffffff;
  580. font-family: DM Sans;
  581. font-weight: 400;
  582. }
  583. .usermain-item .cu-form-group input::placeholder {
  584. color: rgba(155, 155, 155, 1);
  585. font-size: 28rpx;
  586. }
  587. /* 联系方式样式 */
  588. .contact-structure {
  589. border-bottom: none !important;
  590. }
  591. .contact-wrapper {
  592. display: flex;
  593. align-items: center;
  594. justify-content: space-between;
  595. padding: 0;
  596. margin-top: 8rpx;
  597. }
  598. .phone-display {
  599. color: rgba(23, 23, 37, 1);
  600. font-family: DM Sans;
  601. font-size: 28rpx;
  602. font-weight: 400;
  603. line-height: 40rpx;
  604. letter-spacing: 0.5%;
  605. }
  606. .modify-link {
  607. color: rgba(24, 144, 255, 1);
  608. font-family: DM Sans;
  609. font-size: 28rpx;
  610. font-weight: 400;
  611. line-height: 40rpx;
  612. letter-spacing: 0.5%;
  613. cursor: pointer;
  614. text-decoration: none;
  615. }
  616. .modify-link:active {
  617. opacity: 0.7;
  618. }
  619. /* 头像编辑图标样式 */
  620. .avatar-wrapper {
  621. position: relative;
  622. display: inline-block;
  623. }
  624. .edit-avatar-icon {
  625. position: absolute;
  626. bottom: 10rpx;
  627. right: 2rpx;
  628. width: 24rpx;
  629. height: 24rpx;
  630. // background: #fff;
  631. border-radius: 50%;
  632. display: flex;
  633. align-items: center;
  634. justify-content: center;
  635. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  636. }
  637. .avatar-button {
  638. position: relative;
  639. padding: 0;
  640. margin: 0;
  641. background: transparent;
  642. border: none;
  643. }
  644. .footer-btn {
  645. margin-top: 40rpx;
  646. padding-bottom: 40rpx;
  647. }
  648. .footer-btn .usermain-btn {
  649. color: rgba(255, 255, 255, 1);
  650. background: rgba(1, 107, 246, 1);
  651. text-align: center;
  652. width: 90%;
  653. height: 80rpx;
  654. font-size: 32rpx;
  655. line-height: 80rpx;
  656. margin: 20rpx auto;
  657. border-radius: 40rpx;
  658. }
  659. /* 选择器样式 - 参考workExperience页面 */
  660. .form-input-selector {
  661. width: 100%;
  662. height: 68rpx;
  663. padding: 0 40rpx;
  664. border: 1px solid rgba(227, 231, 236, 1);
  665. border-radius: 24px;
  666. background: rgba(255, 255, 255, 1);
  667. display: flex;
  668. align-items: center;
  669. justify-content: space-between;
  670. cursor: pointer;
  671. transition: all 0.2s ease;
  672. .placeholder {
  673. color: #999999;
  674. font-family: DM Sans;
  675. font-size: 28rpx;
  676. font-weight: 400;
  677. line-height: 40rpx;
  678. }
  679. text {
  680. color: rgba(23, 23, 37, 1);
  681. font-family: DM Sans;
  682. font-size: 28rpx;
  683. font-weight: 400;
  684. line-height: 40rpx;
  685. }
  686. }
  687. .arrow-down {
  688. color: rgba(96, 98, 102, 1);
  689. font-size: 24rpx;
  690. font-weight: 400;
  691. transform: scale(1.5);
  692. }
  693. .selector-group:active {
  694. background: #f5f7fa !important;
  695. transform: scale(0.99);
  696. }
  697. .version{
  698. text-align: center;
  699. margin-top: 300rpx;
  700. color: #ccc;
  701. font-size: 24rpx;
  702. text{
  703. margin-left: 20rpx;
  704. }
  705. }
  706. </style>