index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <script setup lang="ts">
  2. /* route */
  3. import { useRoute } from 'vue-router'
  4. /* 取用户头像 */
  5. import router from '@/router'
  6. import highlightConversation from '@/assets/imgs/tabbar/highlightconversation.png'
  7. import grayConversation from '@/assets/imgs/tabbar/grayconversation.png'
  8. import highlightContacts from '@/assets/imgs/tabbar/higtlightcontacts.png'
  9. import grayContacts from '@/assets/imgs/tabbar/graycontacts.png'
  10. import avatarImg from '@/assets/imgs/avatar.gif'
  11. import { useUserStore } from '@/store/modules/user'
  12. const userStore = useUserStore()
  13. const avatar = computed(() => userStore.user.avatar ?? avatarImg)
  14. /* tabular icon 路由跳转 */
  15. const skipRouterName = ref('conversation')
  16. const changeSkipRouterName = (routerName: string) => {
  17. router.push(`/im/${routerName}`)
  18. }
  19. const route = useRoute()
  20. // 监听路由变化
  21. watch(
  22. () => route.path,
  23. (newPath) => {
  24. console.log('>>>>>newPath', newPath)
  25. if (newPath.includes('/im/conversation')) {
  26. skipRouterName.value = 'conversation'
  27. }
  28. if (newPath.includes('/im/contacts')) {
  29. console.log('>>>>>存在赋值为联系人样式')
  30. skipRouterName.value = 'contacts'
  31. }
  32. }
  33. )
  34. </script>
  35. <template>
  36. <!-- 头像 -->
  37. <div class="chat_avatar">
  38. <ElAvatar :src="avatar" alt="" class="w-[calc(var(--logo-height)-25px)] rounded-[50%]" />
  39. </div>
  40. <!-- 去往会话 -->
  41. <div class="chat_conversation chat_icon_box" @click="changeSkipRouterName('conversation')">
  42. <div class="img_box">
  43. <img
  44. :src="skipRouterName === 'conversation' ? highlightConversation : grayConversation"
  45. alt=""
  46. />
  47. </div>
  48. </div>
  49. <!-- 去往联系人 -->
  50. <div class="chat_contacts chat_icon_box" @click="changeSkipRouterName('contacts')">
  51. <img
  52. class="chat_contacts_icon"
  53. :src="skipRouterName === 'contacts' ? highlightContacts : grayContacts"
  54. alt=""
  55. />
  56. </div>
  57. </template>
  58. <style lang="scss" scoped>
  59. .chat_avatar {
  60. margin-top: 43px;
  61. position: relative;
  62. width: 44px;
  63. height: 44px;
  64. transition: all 0.3s;
  65. &:hover {
  66. transform: scale(1.3);
  67. }
  68. span {
  69. display: inline-block;
  70. width: 100%;
  71. height: 100%;
  72. }
  73. .online_status {
  74. position: absolute;
  75. right: 2px;
  76. bottom: 2px;
  77. display: inline-block;
  78. width: 6px;
  79. height: 6px;
  80. border: 2px solid #fff;
  81. background: #fff;
  82. border-radius: 50%;
  83. transition: all 0.3s;
  84. cursor: pointer;
  85. &:hover {
  86. transform: scale(1.2);
  87. }
  88. }
  89. }
  90. .chat_icon_box {
  91. display: flex;
  92. flex-direction: column;
  93. align-items: center;
  94. justify-content: center;
  95. width: 100%;
  96. height: 67px;
  97. text-align: center;
  98. line-height: 67px;
  99. margin: 4px 0;
  100. }
  101. .chat_conversation {
  102. .img_box {
  103. position: relative;
  104. display: flex;
  105. align-items: center;
  106. justify-content: center;
  107. width: 30px;
  108. height: 30px;
  109. img {
  110. display: inline-block;
  111. width: 27px;
  112. height: 27px;
  113. transition: all 0.5s;
  114. &:hover {
  115. transform: scale(1.3);
  116. }
  117. }
  118. .badge {
  119. position: absolute;
  120. right: 0;
  121. top: 8px;
  122. display: inline-block;
  123. width: 7px;
  124. height: 7px;
  125. border-radius: 50%;
  126. background: red;
  127. }
  128. }
  129. }
  130. .chat_contacts {
  131. img {
  132. display: inline-block;
  133. width: 27px;
  134. height: 27px;
  135. transition: all 0.5s;
  136. &:hover {
  137. transform: scale(1.3);
  138. }
  139. }
  140. }
  141. .chat_settings {
  142. position: absolute;
  143. bottom: 92px;
  144. font-size: 30px;
  145. color: #8e8e8e;
  146. cursor: pointer;
  147. transition: all 0.5s;
  148. &:hover {
  149. color: #1b83f9;
  150. transform: scale(1.3);
  151. }
  152. .chat_setting_item {
  153. width: 100%;
  154. height: 30px;
  155. }
  156. }
  157. .more_settings {
  158. position: absolute;
  159. bottom: 46px;
  160. color: #8e8e8e;
  161. cursor: pointer;
  162. transition: all 0.5s;
  163. &:hover {
  164. transform: scale(1.3);
  165. }
  166. }
  167. .setting_fun_list {
  168. display: flex;
  169. flex-direction: column;
  170. justify-content: center;
  171. align-items: center;
  172. .func_item {
  173. display: flex;
  174. flex-direction: row;
  175. align-items: center;
  176. // justify-content: space-around;
  177. width: 101px;
  178. height: 40px;
  179. border-radius: 3px;
  180. &:hover {
  181. background-color: #f2f2f2;
  182. }
  183. .settting_fun_icon {
  184. display: flex;
  185. align-items: center;
  186. justify-content: center;
  187. margin-left: 5px;
  188. img {
  189. width: 20px;
  190. height: 20px;
  191. }
  192. }
  193. .setting_fun_text {
  194. display: inline-block;
  195. text-align: center;
  196. margin-left: 12px;
  197. height: 20px;
  198. width: 58px;
  199. font-weight: 400;
  200. font-size: 14px;
  201. line-height: 20px;
  202. letter-spacing: 0.4px;
  203. color: #333333;
  204. cursor: pointer;
  205. }
  206. .apply_groups {
  207. display: flex;
  208. flex-direction: column;
  209. }
  210. }
  211. }
  212. .settting_fun_icon {
  213. font-size: 20px;
  214. }
  215. .line {
  216. display: inline-block;
  217. width: 69px;
  218. height: 1px;
  219. border: 1px solid rgba(0, 0, 0, 0.0462467);
  220. }
  221. .components {
  222. ::v-deep .edit_userinfo_diglog {
  223. border-radius: 4px;
  224. overflow: hidden;
  225. }
  226. ::v-deep .setting_func_diglog > .el-dialog__body {
  227. padding: 28px 24px 24px 24px;
  228. }
  229. ::v-deep .setting_func_diglog > .el-dialog__header {
  230. background: #f2f2f2;
  231. margin: 0;
  232. }
  233. ::v-deep .edit_userinfo_diglog > .el-dialog__header {
  234. padding: 0;
  235. margin-right: 0;
  236. }
  237. ::v-deep .edit_userinfo_diglog > .el-dialog__body {
  238. padding: 0;
  239. border-radius: 4px;
  240. }
  241. ::v-deep .login_diglog > .el-dialog__header {
  242. background: #f2f2f2;
  243. margin: 0;
  244. }
  245. ::v-deep .personal_setting_card > .el-dialog__header {
  246. background: #f2f2f2;
  247. margin: 0;
  248. }
  249. }
  250. </style>