index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <view class="page mine-container" :style="{ height: `${windowHeight}px` }">
  3. <view class="page-back"></view>
  4. <view class="navgator justify-center align-center">
  5. <view class="nav-title">
  6. {{ $t("app.user") }}
  7. </view>
  8. <view class="nav-actions">
  9. <view class="notice-wrap" @click="navigateToMessage">
  10. <uni-badge :text="messageCount" absolute="rightTop" size="small">
  11. <view class="notice-button">
  12. <image
  13. src="~@/static/home/message.png"
  14. style="
  15. width: 15px;
  16. height: 15px;
  17. background-color: transparent;
  18. " />
  19. </view>
  20. </uni-badge>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="content-section">
  25. <!--顶部个人信息栏-->
  26. <view class="user-info flex-col">
  27. <view class="flex-row" style="padding-bottom: 10px">
  28. <image
  29. class="avatar"
  30. :src="
  31. userInfo?.avatar ? userInfo?.avatar : '/static/user/avatar.png'
  32. "></image>
  33. <view class="info flex-col align-center justify-start">
  34. <view class="text flex-row" style="align-items: center; gap: 10px">
  35. <text class="nickname">{{ userInfo?.nickname }}</text>
  36. <text
  37. style="
  38. background-color: #e6f2fd;
  39. padding: 2px 10px;
  40. color: #1755dc;
  41. border-radius: 20px;
  42. "
  43. >{{ userInfo.username }}</text
  44. >
  45. </view>
  46. <view
  47. class="text flex-row"
  48. style="
  49. margin-top: 10px;
  50. display: flex;
  51. align-items: center;
  52. gap: 5px;
  53. ">
  54. <uni-icons type="phone-filled" size="16" color="#656f85" />
  55. <text>{{ userInfo?.mobile }}</text>
  56. </view>
  57. <!-- 项目部 -->
  58. <view
  59. class="text flex-row"
  60. style="
  61. margin-top: 10px;
  62. display: flex;
  63. align-items: center;
  64. gap: 5px;
  65. ">
  66. <uni-icons type="staff" size="16" color="#656f85" />
  67. <text>{{ userInfo?.dept.name }}</text>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- <view class="info-list flex-row w-full justify-between items-center">
  72. <view class="flex-col justify-center items-center list-item">
  73. <text class="info-text">6</text>
  74. <text class="info-tip">待处理</text>
  75. </view>
  76. <view
  77. class="flex-col justify-center items-center list-item mark-item"
  78. >
  79. <text class="info-text">6</text>
  80. <text class="info-tip">关注设备</text>
  81. </view>
  82. <view class="flex-col justify-center items-center list-item">
  83. <text class="info-text">6</text>
  84. <text class="info-tip">导出报表</text>
  85. </view>
  86. </view> -->
  87. </view>
  88. <!-- 菜单 -->
  89. <view class="menu-list">
  90. <view
  91. class="card-cell flex-row align-center justify-between"
  92. @click="navigateToChange">
  93. <image
  94. src="/static/user/anquanzhongxin.svg"
  95. mode="aspectFill"></image>
  96. <view class="cell-con flex-row align-center justify-between">
  97. <view class="cell-text flex-row align-center justify-start">
  98. <view class="title">
  99. {{ $t("user.securityCenter") }}
  100. </view>
  101. <view class="subtitle">
  102. {{ $t("user.modifyPhoneAndPassword") }}
  103. </view>
  104. </view>
  105. <uni-icons type="right" :color="'#CACCCF'" size="15" />
  106. </view>
  107. </view>
  108. <view class="card-cell flex-row align-center justify-between">
  109. <image src="/static/user/guanyuwomen.svg" mode="aspectFill"></image>
  110. <view class="cell-con flex-row align-center justify-between">
  111. <view class="cell-text flex-row align-center justify-start">
  112. <view class="title">
  113. {{ $t("user.aboutUs") }}
  114. </view>
  115. <view class="subtitle">
  116. {{ $t("user.currentVersion") + " " + version }}
  117. </view>
  118. </view>
  119. <uni-icons type="right" :color="'#CACCCF'" size="15" />
  120. </view>
  121. </view>
  122. <!-- <view
  123. class="card-cell flex-row align-center justify-between"
  124. @click="logout"
  125. >
  126. <image src="/static/user/tuichu.svg" mode="aspectFill"></image>
  127. <view class="cell-con flex-row align-center justify-between">
  128. <view class="cell-text flex-row align-center justify-start">
  129. <view class="title">
  130. {{ $t("user.logout") }}
  131. </view>
  132. </view>
  133. <uni-icons type="right" :color="'#CACCCF'" size="15" />
  134. </view>
  135. </view> -->
  136. </view>
  137. <button
  138. type="warn"
  139. plain="true"
  140. @click="logout"
  141. style="
  142. background-color: #fff;
  143. border: 0.5px solid #f2f4f7;
  144. margin-top: 10px;
  145. display: flex;
  146. align-items: center;
  147. justify-content: center;
  148. ">
  149. <image
  150. style="width: 22px; height: 22px; padding-right: 8px"
  151. src="/static/user/logout.png"></image>
  152. <text>{{ $t("user.logout") }}</text>
  153. </button>
  154. </view>
  155. </view>
  156. </template>
  157. <script setup>
  158. import { getCurrentWgtInfo } from "@/utils/hot-update";
  159. import { onMounted, ref } from "vue";
  160. import { useI18n } from "vue-i18n";
  161. import { getLoginUserInfo } from "@/api/login";
  162. import { getUnreadMessageCount } from "@/api/message";
  163. import { onShow } from "@dcloudio/uni-app";
  164. const { t } = useI18n({
  165. useScope: "global",
  166. });
  167. import $store from "@/store";
  168. // const userStore = $store('user');
  169. //
  170. // const userInfo = ref(JSON.parse(getUserInfo()))
  171. // userInfo.value = JSON.parse(userInfo.value).user
  172. // console.log('useer---', userInfo.value)
  173. // const avatar = userInfo.value.avatar
  174. // const name = userInfo.value.nickname
  175. // const phone = userInfo.value.phone || ''
  176. const windowHeight = ref(0);
  177. uni.getSystemInfo({
  178. success: function (res) {
  179. windowHeight.value = res.windowHeight;
  180. },
  181. });
  182. const navigateToChange = () => {
  183. uni.navigateTo({
  184. url: "/pages/user/change?info=" + JSON.stringify(userInfo.value),
  185. });
  186. };
  187. const navigateToMessage = () => {
  188. uni.navigateTo({
  189. url: "/pages/message/index",
  190. });
  191. };
  192. const userStore = $store("user");
  193. const logout = () => {
  194. uni.showModal({
  195. title: t("api.message"),
  196. content: `${t("login.logoutConfirm")}?`,
  197. success: async function (res) {
  198. if (res.confirm) {
  199. await userStore.LogOut();
  200. await uni.reLaunch({
  201. url: "/pages/user/login",
  202. });
  203. } else if (res.cancel) {
  204. console.log("用户点击取消");
  205. }
  206. },
  207. });
  208. };
  209. const userInfo = ref({});
  210. const version = ref("");
  211. const messageCount = ref(0);
  212. const loadUserPageData = async () => {
  213. const [userRes, messageRes] = await Promise.all([
  214. getLoginUserInfo(),
  215. getUnreadMessageCount(),
  216. ]);
  217. userInfo.value = userRes?.data || {};
  218. messageCount.value = messageRes?.code === 0 ? messageRes.data || 0 : 0;
  219. };
  220. onMounted(async () => {
  221. await loadUserPageData();
  222. const wgtInfo = await getCurrentWgtInfo();
  223. version.value = wgtInfo?.version || "";
  224. uni.$once("updateUserInfo", async () => {
  225. userInfo.value = (await getLoginUserInfo()).data;
  226. });
  227. });
  228. onShow(() => {
  229. loadUserPageData();
  230. });
  231. </script>
  232. <style lang="scss" scoped>
  233. .page {
  234. padding: 10px !important;
  235. }
  236. .mine-container {
  237. width: 100%;
  238. height: 100%;
  239. position: relative;
  240. box-sizing: border-box;
  241. overflow: hidden;
  242. }
  243. .page-back {
  244. background-image: url("/static/entry/bg.png");
  245. background-repeat: no-repeat;
  246. background-size: 100% 100%;
  247. position: fixed;
  248. top: 0;
  249. left: 0;
  250. width: 100%;
  251. height: 200px;
  252. z-index: 0;
  253. }
  254. .navgator {
  255. position: fixed;
  256. top: 1.5625rem;
  257. left: 0;
  258. width: 100%;
  259. height: 55px;
  260. padding: 15px 0;
  261. z-index: 2;
  262. // background-image: url('/static/common/nav-back.png');
  263. }
  264. .nav-actions {
  265. position: absolute;
  266. right: 30px;
  267. display: flex;
  268. align-items: center;
  269. gap: 12px;
  270. }
  271. .nav-title {
  272. font-family: PingFang-SC, PingFang-SC;
  273. padding-bottom: 10rpx;
  274. font-size: 18px;
  275. color: #ffffff;
  276. line-height: 22px;
  277. text-align: right;
  278. // font-style: normal;
  279. }
  280. .content-section {
  281. position: relative;
  282. margin-top: 100px;
  283. width: 100%;
  284. height: calc(100% - 55px - 20px);
  285. overflow-y: auto;
  286. }
  287. .notice-wrap {
  288. display: flex;
  289. align-items: center;
  290. }
  291. .notice-button {
  292. width: 30rpx;
  293. height: 30rpx;
  294. display: flex;
  295. align-items: center;
  296. justify-content: center;
  297. }
  298. .user-info {
  299. width: 100%;
  300. height: 120px;
  301. padding: 14px 20px;
  302. padding-top: 20px;
  303. box-sizing: border-box;
  304. background: #ffffff;
  305. border-radius: 6px;
  306. font-size: 14px;
  307. color: #333333;
  308. .avatar {
  309. width: 72px;
  310. height: 72px;
  311. border-radius: 50%;
  312. margin-right: 18px;
  313. }
  314. .info {
  315. width: calc(100% - 52px - 18px);
  316. }
  317. }
  318. .info-list {
  319. // margin-top: 50rpx;
  320. border-top: 1px solid #e2e6ee;
  321. padding-top: 10px;
  322. padding-right: 20px;
  323. padding-left: 20px;
  324. .list-item {
  325. text-align: center;
  326. }
  327. .mark-item {
  328. border-left: 1px solid #e2e6ee;
  329. border-right: 1px solid #e2e6ee;
  330. padding-left: 30px;
  331. padding-right: 30px;
  332. }
  333. .info-text {
  334. font-size: 48rpx;
  335. font-weight: 500;
  336. color: #0355ed;
  337. }
  338. .info-tip {
  339. color: #657085;
  340. }
  341. }
  342. .text {
  343. height: 19px;
  344. width: 100%;
  345. .span {
  346. display: block;
  347. min-width: 70px;
  348. }
  349. }
  350. .nickname {
  351. font-size: 20px;
  352. font-weight: bold;
  353. }
  354. .menu-list {
  355. height: 274px;
  356. background: #ffffff;
  357. border-radius: 6px;
  358. margin-top: 10px;
  359. padding: 20px;
  360. box-sizing: border-box;
  361. }
  362. .card-cell {
  363. width: 100%;
  364. height: 50px;
  365. image {
  366. width: 32px;
  367. height: 32px;
  368. }
  369. }
  370. .cell-con {
  371. margin-left: 20px;
  372. margin-right: 10px;
  373. width: calc(100% - 32px - 20px - 10px);
  374. height: 100%;
  375. border-bottom: 0.5px solid #cacccf;
  376. }
  377. .cell-text {
  378. font-weight: 500;
  379. .title {
  380. font-size: 14px;
  381. color: #333333;
  382. line-height: 20px;
  383. }
  384. .subtitle {
  385. font-size: 12px;
  386. color: #999999;
  387. line-height: 17px;
  388. margin-left: 10px;
  389. }
  390. .icon {
  391. width: 6px;
  392. height: 10px;
  393. }
  394. }
  395. </style>