people.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. <template>
  2. <view>
  3. <scroll-view scroll-y class="page">
  4. <!-- 头部logo-->
  5. <view class="UCenter-bg">
  6. <view class="avatar-box"> </view>
  7. </view>
  8. <view class="padding flex text-center bg-white userinfo-box">
  9. <view class="user1" :style="[{ animationDelay: '0.2s' }]">
  10. <view class="username1">
  11. <view class="text-xl" style="color: #fff">{{
  12. personalList.realname
  13. }}</view>
  14. <view class="text-info">姓名</view>
  15. </view>
  16. <view class="usericon1"> </view>
  17. </view>
  18. <view class="user2" :style="[{ animationDelay: '0.2s' }]">
  19. <view class="username2">
  20. <view class="text-xl" style="color: #fff">{{
  21. personalList.username
  22. }}</view>
  23. <view class="text-info">账号</view>
  24. </view>
  25. <view class="usericon2"> </view>
  26. </view>
  27. </view>
  28. <!-- 列表list-->
  29. <view
  30. class="cu-list menu card-menu margin-top-xl margin-bottom-xl shadow-lg radius people-menu"
  31. >
  32. <!-- <view
  33. class="cu-item arrow animation-slide-bottom"
  34. :style="[{ animationDelay: '0.3s' }]"
  35. @tap="scan"
  36. >
  37. <view class="content">
  38. <text class="cuIcon-scan menu-icon"></text>
  39. <text class="text-grey">扫码</text>
  40. </view>
  41. </view> -->
  42. <navigator
  43. class="cu-item arrow animation-slide-bottom"
  44. url="/pages/user/userdetail"
  45. :style="[{ animationDelay: '0.6s' }]"
  46. >
  47. <view class="content">
  48. <text class="cuIcon-settings menu-icon"></text>
  49. <text class="text-grey">设置</text>
  50. </view>
  51. </navigator>
  52. <view
  53. class="cu-item arrow animation-slide-bottom"
  54. :style="[{ animationDelay: '0.7s' }]"
  55. hover-class="none"
  56. @tap="confirmExit"
  57. >
  58. <view class="content">
  59. <text class="cuIcon-exit menu-icon"></text>
  60. <text class="text-grey">退出</text>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="cu-tabbar-height"></view>
  65. </scroll-view>
  66. <!-- 退出登录确认弹窗 -->
  67. <u-popup
  68. :show="exitShow"
  69. mode="center"
  70. :round="16"
  71. :closeable="false"
  72. :closeOnClickOverlay="true"
  73. @close="closeExit"
  74. >
  75. <view class="exit-modal">
  76. <view class="exit-modal-header">
  77. <text class="exit-modal-title">提示</text>
  78. <view class="exit-modal-close" @click="closeExit">
  79. <u-icon name="close" size="16" color="#2b7cff"></u-icon>
  80. </view>
  81. </view>
  82. <view class="exit-modal-divider"></view>
  83. <view class="exit-modal-body">
  84. <view class="exit-confirm-box">
  85. <!-- 退出图标位置:待替换为正式图标 -->
  86. <image
  87. class="exit-confirm-icon"
  88. src="/static/user/loginout.svg"
  89. ></image>
  90. <text class="exit-confirm-text">确定退出登录吗?</text>
  91. </view>
  92. </view>
  93. <view class="exit-modal-footer">
  94. <view class="exit-btn exit-btn-plain" @click="closeExit">
  95. <text class="exit-btn-text">取消</text>
  96. </view>
  97. <view class="exit-btn exit-btn-primary" @click="doLogout">
  98. <text class="exit-btn-text">确定</text>
  99. </view>
  100. </view>
  101. </view>
  102. </u-popup>
  103. </view>
  104. </template>
  105. <script>
  106. import api from "@/api/api";
  107. import { ACCESS_TOKEN, USER_NAME, USER_INFO } from "@/common/util/constants";
  108. export default {
  109. name: "people",
  110. data() {
  111. return {
  112. personalList: {
  113. realname: "",
  114. username: "",
  115. },
  116. positionUrl: "/sys/position/list",
  117. departUrl: "/sys/user/userDepartList",
  118. userUrl: "/sys/user/queryById",
  119. postUrl: "/sys/position/queryByCode",
  120. userId: "",
  121. id: "",
  122. logoutJumping: false, // 防止重复点击退出
  123. exitShow: false, // 退出确认弹窗
  124. };
  125. },
  126. watch: {
  127. cur: {
  128. immediate: true,
  129. handler() {
  130. console.log("watch", this.cur);
  131. const userInfo = uni.getStorageSync(USER_INFO) || {};
  132. this.userId = userInfo.id || "";
  133. this.personalList.realname = userInfo.realname || "";
  134. this.personalList.username = userInfo.username || "";
  135. this.load();
  136. },
  137. },
  138. },
  139. methods: {
  140. // 退出登录:先弹确认框,确认后直接退出并回到登录页
  141. confirmExit() {
  142. this.exitShow = true;
  143. },
  144. closeExit() {
  145. this.exitShow = false;
  146. },
  147. doLogout() {
  148. if (this.logoutJumping) {
  149. return;
  150. }
  151. this.logoutJumping = true;
  152. this.exitShow = false;
  153. const token = uni.getStorageSync(ACCESS_TOKEN);
  154. // 退出接口失败不影响本地退出流程
  155. if (token) {
  156. api.logout(token).catch(() => {});
  157. }
  158. this.clearLoginState();
  159. // 直接回到登录页,清空页面栈,避免侧滑返回系统内部页面
  160. uni.reLaunch({ url: "/pages/login/login" });
  161. },
  162. clearLoginState() {
  163. [
  164. ACCESS_TOKEN,
  165. USER_NAME,
  166. USER_INFO,
  167. "menuPermission",
  168. "btnPermission",
  169. ].forEach((key) => {
  170. uni.removeStorageSync(key);
  171. });
  172. this.$store.commit("SET_TOKEN", "");
  173. this.$store.commit("SET_NAME", { username: "", realname: "" });
  174. this.$store.commit("SET_DICT", "");
  175. },
  176. scan() {
  177. console.log("进来了");
  178. // #ifndef H5
  179. uni.scanCode({
  180. success: function (res) {
  181. console.log("条码res:" + res);
  182. console.log("条码类型:" + res.scanType);
  183. console.log("条码内容:" + res.result);
  184. },
  185. });
  186. // #endif
  187. // #ifdef H5
  188. this.$tip.alert("暂不支持");
  189. // #endif
  190. },
  191. load() {
  192. if (!this.userId) {
  193. return;
  194. }
  195. this.$http
  196. .get(this.userUrl, { params: { id: this.userId } })
  197. .then((res) => {
  198. console.log("res", res);
  199. if (res.data.success) {
  200. let perArr = res.data.result;
  201. let avatar =
  202. perArr.avatar && perArr.avatar.length > 0
  203. ? api.getFileAccessHttpUrl(perArr.avatar)
  204. : "/static/user2.png";
  205. this.personalList.realname = perArr.realname;
  206. console.log(perArr, "用户信息");
  207. this.personalList.username = perArr.username;
  208. }
  209. })
  210. .catch((err) => {
  211. console.log(err);
  212. });
  213. },
  214. },
  215. };
  216. </script>
  217. <style>
  218. .UCenter-bg {
  219. /* #ifdef MP-WEIXIN */
  220. background-image: url("/static/topnavbar.png");
  221. /* #endif */
  222. /* #ifndef MP-WEIXIN */
  223. background-image: url("/static/user/usertopbg.png");
  224. /* #endif */
  225. background-size: cover;
  226. height: 400rpx;
  227. display: flex;
  228. justify-content: center;
  229. padding-top: 40rpx;
  230. overflow: hidden;
  231. position: relative;
  232. flex-direction: column;
  233. align-items: center;
  234. color: #fff;
  235. font-weight: 300;
  236. text-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
  237. }
  238. .avatar-box {
  239. position: relative;
  240. width: 250rpx;
  241. height: 250rpx;
  242. background-image: url("/static/user/userTop.png");
  243. background-size: 100% 100%;
  244. }
  245. .avatar {
  246. position: absolute;
  247. width: 100%;
  248. height: 95%;
  249. background-image: url("/static/user2.png");
  250. background-size: 50% 50%;
  251. background-repeat: no-repeat;
  252. background-position: center;
  253. }
  254. .userinfo-box {
  255. display: flex;
  256. justify-content: space-between;
  257. align-items: center;
  258. padding: 20rpx;
  259. margin: 16rpx 15rpx 0;
  260. box-sizing: border-box;
  261. border-radius: 12rpx;
  262. background-color: #f9f9fb;
  263. border: 1px solid #fff;
  264. }
  265. .user1 {
  266. display: flex;
  267. align-items: center;
  268. justify-content: space-between;
  269. flex: 1;
  270. min-width: 0;
  271. box-sizing: border-box;
  272. position: relative;
  273. overflow: visible;
  274. background-image: url("/static/user/userbg1.png");
  275. background-size: 100% 100%;
  276. background-repeat: no-repeat;
  277. margin: 0;
  278. padding: 14rpx 10rpx 10rpx 20rpx;
  279. height: 128rpx;
  280. border-radius: 16rpx;
  281. }
  282. .usericon1 {
  283. flex: 0 0 auto;
  284. position: relative;
  285. z-index: 1;
  286. width: 72px;
  287. height: 80px;
  288. margin: 0 0px -5px 0;
  289. align-self: flex-end;
  290. background-image: url("/static/user/user.png");
  291. background-size: cover;
  292. background-position: right bottom;
  293. background-repeat: no-repeat;
  294. }
  295. .username1 {
  296. display: flex;
  297. flex-direction: column;
  298. justify-content: center;
  299. flex: 1;
  300. min-width: 0;
  301. padding-bottom: 8rpx;
  302. text-align: left;
  303. }
  304. .user2 {
  305. display: flex;
  306. align-items: center;
  307. justify-content: space-between;
  308. flex: 1;
  309. min-width: 0;
  310. box-sizing: border-box;
  311. position: relative;
  312. overflow: visible;
  313. background-image: url("/static/user/userbg2.png");
  314. background-size: 100% 100%;
  315. background-repeat: no-repeat;
  316. margin: 0 0 0 16rpx;
  317. padding: 14rpx 10rpx 10rpx 20rpx;
  318. height: 128rpx;
  319. border-radius: 16rpx;
  320. }
  321. .usericon2 {
  322. flex: 0 0 auto;
  323. position: relative;
  324. z-index: 1;
  325. width: 80px;
  326. height: 79px;
  327. margin: 0 -1px -4px 0;
  328. align-self: flex-end;
  329. background-image: url("/static/user/user1.png");
  330. background-size: cover;
  331. background-position: right bottom;
  332. background-repeat: no-repeat;
  333. }
  334. .username2 {
  335. display: flex;
  336. flex-direction: column;
  337. justify-content: center;
  338. flex: 1;
  339. min-width: 0;
  340. padding-bottom: 8rpx;
  341. text-align: left;
  342. }
  343. .username1 .text-xl,
  344. .username2 .text-xl {
  345. overflow: hidden;
  346. color: #fff;
  347. font-size: 28rpx;
  348. font-weight: bold;
  349. line-height: 1.2;
  350. text-overflow: ellipsis;
  351. white-space: nowrap;
  352. }
  353. .username1 .text-info,
  354. .username2 .text-info {
  355. color: rgba(255, 255, 255, 0.92);
  356. font-size: 22rpx;
  357. font-weight: 400;
  358. }
  359. .UCenter-bg text {
  360. opacity: 0.8;
  361. }
  362. .UCenter-bg image {
  363. width: 200rpx;
  364. height: 200rpx;
  365. }
  366. .UCenter-bg .gif-wave {
  367. position: absolute;
  368. width: 100%;
  369. bottom: 0;
  370. left: 0;
  371. z-index: 99;
  372. mix-blend-mode: screen;
  373. height: 100rpx;
  374. }
  375. map,
  376. .mapBox {
  377. left: 0;
  378. z-index: 99;
  379. mix-blend-mode: screen;
  380. height: 100rpx;
  381. }
  382. map,
  383. .mapBox {
  384. width: 750rpx;
  385. height: 300rpx;
  386. }
  387. .card-menu {
  388. margin: 20rpx;
  389. }
  390. .people-menu {
  391. overflow: visible;
  392. margin-top: 20rpx;
  393. background-color: transparent;
  394. box-shadow: none;
  395. }
  396. .people-menu > .cu-item {
  397. min-height: 80rpx;
  398. margin-bottom: 20rpx;
  399. border-radius: 12rpx;
  400. background-color: #f9f9fb;
  401. border: 1rpx solid #fff;
  402. }
  403. .people-menu > .cu-item:last-child {
  404. margin-bottom: 0;
  405. }
  406. .people-menu > .cu-item.arrow:before {
  407. color: #1677ff;
  408. }
  409. .people-menu .menu-icon {
  410. display: inline-flex;
  411. align-items: center;
  412. justify-content: center;
  413. width: 52rpx;
  414. height: 52rpx;
  415. margin-right: 16rpx;
  416. border-radius: 8rpx;
  417. background: linear-gradient(135deg, #80b4ff, #347df3);
  418. color: #fff;
  419. font-size: 30rpx;
  420. vertical-align: middle;
  421. }
  422. .people-menu .content > text[class*="cuIcon"] {
  423. width: 52rpx;
  424. margin-right: 16rpx;
  425. }
  426. .text-grey {
  427. color: #000;
  428. font-weight: bold;
  429. }
  430. /* ===== 退出登录确认弹窗 ===== */
  431. .exit-modal {
  432. width: 620rpx;
  433. background: #f9f9fb;
  434. border-radius: 16rpx;
  435. border: 1px solid #fff;
  436. overflow: hidden;
  437. padding-bottom: 28rpx;
  438. box-sizing: border-box;
  439. }
  440. .exit-modal-header {
  441. display: flex;
  442. flex-direction: row;
  443. align-items: center;
  444. justify-content: space-between;
  445. padding: 28rpx 28rpx 20rpx;
  446. }
  447. .exit-modal-title {
  448. font-size: 32rpx;
  449. font-weight: 700;
  450. color: #1a1a1a;
  451. }
  452. .exit-modal-close {
  453. width: 44rpx;
  454. height: 44rpx;
  455. display: flex;
  456. align-items: center;
  457. justify-content: center;
  458. }
  459. .exit-modal-divider {
  460. height: 1rpx;
  461. background: #eef0f4;
  462. margin: 0 24rpx;
  463. }
  464. .exit-modal-body {
  465. padding: 24rpx 28rpx;
  466. }
  467. /* 内容框 */
  468. .exit-confirm-box {
  469. display: flex;
  470. flex-direction: row;
  471. align-items: center;
  472. justify-content: center;
  473. padding: 36rpx 24rpx;
  474. box-sizing: border-box;
  475. border-radius: 12rpx;
  476. background-color: #eaeefc;
  477. border: 1px solid #fff;
  478. }
  479. /* 退出图标:uni-app image 默认 320x240,必须显式给宽高 */
  480. .exit-confirm-icon {
  481. width: 56rpx;
  482. height: 56rpx;
  483. margin-right: 16rpx;
  484. flex-shrink: 0;
  485. }
  486. .exit-confirm-text {
  487. font-size: 28rpx;
  488. color: #1a1a1a;
  489. white-space: nowrap;
  490. }
  491. .exit-modal-footer {
  492. display: flex;
  493. flex-direction: row;
  494. align-items: center;
  495. gap: 20rpx;
  496. padding: 0 28rpx;
  497. }
  498. .exit-btn {
  499. flex: 1;
  500. height: 64rpx;
  501. border-radius: 8rpx;
  502. display: flex;
  503. align-items: center;
  504. justify-content: center;
  505. box-sizing: border-box;
  506. }
  507. .exit-btn-text {
  508. font-size: 28rpx;
  509. font-weight: 500;
  510. }
  511. .exit-btn-plain {
  512. background: #ffffff;
  513. border: 1rpx solid #0065f8;
  514. }
  515. .exit-btn-plain .exit-btn-text {
  516. color: #0065f8;
  517. }
  518. .exit-btn-primary {
  519. background: #0065f8;
  520. }
  521. .exit-btn-primary .exit-btn-text {
  522. color: #ffffff;
  523. }
  524. </style>