index.vue 11 KB

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