tabUser.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <ion-page>
  3. <!-- <ion-header>
  4. <ion-toolbar color="secondary">
  5. <ion-title>我的</ion-title>
  6. </ion-toolbar>
  7. </ion-header>
  8. <ion-content :fullscreen="true">
  9. <ion-list>
  10. <ion-item @click="router.push('myInfo')"><ion-label>个人信息</ion-label></ion-item>
  11. <ion-item>
  12. <ion-button slot="end" size="default" fill="outline"
  13. @click="presentAlert">
  14. <ion-icon :icon="walkOutline" size="large" slot="start"></ion-icon>
  15. 退出
  16. </ion-button>
  17. </ion-item>
  18. </ion-list>
  19. </ion-content>-->
  20. <ion-content>
  21. <!-- <div class="mine-toolbar">
  22. <div class="mine-body">
  23. <div class="info-img">
  24. <img class="img-user" src="@/assets/icon/icon-user-2x.png" onerror="this.src='@/assets/icon/icon-user-2x.png'" />
  25. </div>
  26. <div class="info-text">
  27. <div class="info-text-name" style="color: #fff;">
  28. <h3>{{user?.name}}</h3>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. <ion-list>
  34. <ion-item class="item-menu" detail mode="md" style="&#45;&#45;border-style: none;">
  35. <img src="@/assets/icon/grxx.png" >
  36. <ion-label @click="router.push('/tabs/tabUser/myInfo')">个人信息</ion-label>
  37. </ion-item>
  38. <ion-item class="item-menu" detail mode="md" style="&#45;&#45;border-style: none;" v-if="isDev">
  39. <img src="@/assets/icon/tysz.png">
  40. <ion-label @click="router.push('/tabs/tabUser/updatePassword')">密码修改</ion-label>
  41. </ion-item>
  42. <ion-item class="item-menu" detail mode="md" style="&#45;&#45;border-style: none;">
  43. <img src="@/assets/icon/gywm.png">
  44. <ion-label>关于我们</ion-label>
  45. </ion-item>
  46. </ion-list>
  47. <div class="login-out" @click="presentAlert" v-if="isDev">
  48. 退出登录
  49. </div>-->
  50. <div class="tab-user-content">
  51. <div class="user_info">
  52. <div class="user_img">
  53. <b-image v-if="loadImage" :file-ref-id="user.userID" :readonly="true" :is-single="true"></b-image>
  54. </div>
  55. <div class="user_text">
  56. <h2>{{user.name}}</h2>
  57. <p>驿站工作人员</p>
  58. </div>
  59. <div class="qr_img">
  60. <img :src="infoQrcodeUrl" :style="imgStyle">
  61. </div>
  62. </div>
  63. <div class="user_panel">
  64. <div class="panel_title">
  65. 我的设置
  66. </div>
  67. <div class="panel_list">
  68. <ion-item class="item-menu" detail mode="md">
  69. <img src="@/assets/icon/grxx.png" >
  70. <ion-label @click="router.push('/tabs/tabUser/myInfo')">个人信息</ion-label>
  71. </ion-item>
  72. <ion-item class="item-menu" detail mode="md" v-if="isDev">
  73. <img src="@/assets/icon/tysz.png">
  74. <ion-label @click="router.push('/tabs/tabUser/updatePassword')">密码修改</ion-label>
  75. </ion-item>
  76. <ion-item class="item-menu" detail mode="md">
  77. <img src="@/assets/icon/gywm.png">
  78. <ion-label @click="router.push('/tabs/tabUser/about')">关于我们</ion-label>
  79. </ion-item>
  80. <ion-item class="item-menu" detail mode="md">
  81. <img src="@/assets/icon/tc.png">
  82. <ion-label @click="presentAlert">退出登录</ion-label>
  83. </ion-item>
  84. </div>
  85. </div>
  86. </div>
  87. </ion-content>
  88. </ion-page>
  89. </template>
  90. <script setup lang="ts">
  91. import { alertController } from '@ionic/vue';
  92. import { useUserStore } from '@/store/modules/user';
  93. import router from '@/router';
  94. import {getCurrentInstance, onMounted, onUpdated, ref, watch} from "vue";
  95. import {getConfig} from "@/utils/config";
  96. import {getQRCodeUrlToBase64} from "@/api/wechat";
  97. import {base64ToBlob} from "@/utils/imageUtils";
  98. import BImage from "@/components/bImage.vue";
  99. import {useRouter} from "vue-router";
  100. const $router = useRouter();
  101. const infoQrcodeUrl = ref("");
  102. const { appContext : { config: { globalProperties } } } = getCurrentInstance();
  103. const userStore = useUserStore();
  104. const user = ref(userStore.getUserInfo);
  105. const qrCodeUrl = "/jobUserInfo/index";
  106. getQRCodeUrlToBase64(encodeURIComponent(qrCodeUrl), user.value.userID==undefined?"":user.value.userID).then(base64Str => {
  107. infoQrcodeUrl.value = URL.createObjectURL(base64ToBlob("data:image/png;base64," + base64Str));
  108. }, () => {
  109. infoQrcodeUrl.value = "";
  110. });
  111. const imgStyle = ref({
  112. width: '0px',
  113. height: '0px',
  114. margin: '0px 0px 0px 40px'
  115. });
  116. const loadImage = ref(true);
  117. const updateBrowserWidth = () => {
  118. const browserWidth = window.innerWidth;
  119. imgStyle.value.width = (browserWidth - 130) / 3 + 'px';
  120. imgStyle.value.height = (browserWidth - 130) / 3 + 'px';
  121. imgStyle.value.margin = '0px 0px 0px ' + (browserWidth - 200) / 15 + 'px';
  122. }
  123. // 设置初始浏览器宽度
  124. updateBrowserWidth();
  125. // 监听窗口大小变化
  126. window.addEventListener('resize', updateBrowserWidth);
  127. const isDev = ref(false);
  128. const presentAlert = async () => {
  129. const alert = await alertController.create({
  130. header: '是否退出登陆?',
  131. buttons: [
  132. {
  133. text: '取消',
  134. role: 'cancel'
  135. },
  136. {
  137. text: '确定',
  138. role: 'confirm',
  139. handler: () => {
  140. userStore.logout().then(()=>{
  141. globalProperties.$routeActive = false;
  142. router.push("/login");
  143. });
  144. },
  145. },
  146. ],
  147. });
  148. await alert.present();
  149. }
  150. // 监听路由变化
  151. watch(() => $router.currentRoute.value.path, (to, form) => {
  152. if (form == "/tabs/tabUser/myInfo" && to == "/tabs/tabUser") {
  153. loadImage.value = false;
  154. setTimeout(() => {
  155. loadImage.value = true;
  156. }, 500)
  157. }
  158. }, {immediate: true});
  159. onMounted(() => {
  160. getConfig().then((res: any) => {
  161. isDev.value = res.isDev;
  162. }, () => {
  163. isDev.value = true;
  164. })
  165. })
  166. </script>
  167. <style lang="less">
  168. /*.tab-user-content{
  169. --background: #ffffff !important;
  170. .mine-toolbar {
  171. background-image: url("@/assets/icon/user-bg.png");
  172. background-repeat: no-repeat;
  173. background-size: 100% 100%;
  174. height: 220px;
  175. display: flex;
  176. //background: linear-gradient(to bottom, #39A9FF 30%, #ffffff);
  177. .mine-body {
  178. flex-wrap: wrap;
  179. flex-direction: row;
  180. width:100%;
  181. justify-content:center;
  182. div {
  183. text-align: center;
  184. color: var(--ion-color-primary-contrast);
  185. margin-top: 20px;
  186. }
  187. .info-title {
  188. color: var(--ion-color-primary-contrast);
  189. }
  190. .info-img {
  191. text-align: center;
  192. !*margin: 30px 0px;*!
  193. img {
  194. height: 60px;
  195. width: 60px;
  196. border-radius: 10px;
  197. margin-top: 10px;
  198. }
  199. }
  200. .info-text {
  201. flex-direction: column;
  202. .info-text-dp {
  203. font-size:12px;
  204. }
  205. }
  206. }
  207. }
  208. .item-menu {
  209. img {
  210. width: 24px;
  211. height: 24px;
  212. margin-left: 20px;
  213. margin-right: 10px;
  214. }
  215. }
  216. .login-out {
  217. border: 1px solid rgb(233,233,233);
  218. text-align:center;
  219. padding:12px 0px;
  220. margin-top:30px;
  221. width:100%;
  222. }
  223. ion-item::part(native) {
  224. padding: 0;
  225. }
  226. login-out {
  227. border: 1px solid rgb(233,233,233);
  228. text-align:center;
  229. padding:12px 0px;
  230. margin-top:45px;
  231. width:100%;
  232. }
  233. }*/
  234. .tab-user-content{
  235. background-image: url("../../assets/icon/user_bg.png");
  236. width: 100%;
  237. height: 100%;
  238. background-size: contain;
  239. background-repeat: no-repeat;
  240. background-color: #F7F8FC;
  241. background-attachment: local;
  242. overflow: hidden;
  243. .user_info{
  244. display: flex;
  245. align-items: center;
  246. justify-content: space-between;
  247. margin: 90px 10px 10px 10px;
  248. padding: 10px;
  249. border-radius: 10px;
  250. background-color: rgba(255, 255, 255, 0.6);
  251. position: relative;
  252. z-index: 2;
  253. .user_text{
  254. padding-left: 20px;
  255. p{
  256. color: #899099;
  257. }
  258. }
  259. }
  260. .user_info::before{
  261. content: " ";
  262. position: absolute;
  263. top: 0;
  264. left: 0;
  265. width: 100%;
  266. height: 100%;
  267. z-index: -1;
  268. backdrop-filter: blur(2px);
  269. border-radius: 10px;
  270. }
  271. .user_panel{
  272. background-color: white;
  273. border-radius: 10px;
  274. padding: 10px;
  275. margin: 10px;
  276. .panel_title{
  277. font-size: 18px;
  278. padding: 15px;
  279. }
  280. .panel_list{
  281. ion-item{
  282. --inner-border-width: 0;
  283. --inner-padding-end:0px;
  284. ion-label{
  285. padding-left: 10px;
  286. }
  287. }
  288. }
  289. }
  290. }
  291. .user_img {
  292. .img-list {
  293. padding: 0;
  294. }
  295. .img-item {
  296. width: 100%;
  297. }
  298. }
  299. </style>