|
| 1 | +<template> |
| 2 | + <q-btn style="position: fixed;z-index: 100001;top: 0;left: 0" round flat @click="router.go(-1)"><q-icon color="white" name="arrow_back"></q-icon></q-btn> |
| 3 | + <q-btn style="position: fixed;z-index: 100001;top: 0;right: 0" round flat> |
| 4 | + <q-icon name="more_vert" color="white"></q-icon> |
| 5 | + <q-menu style="position: fixed;z-index: 100002;top: 0;"> |
| 6 | + <q-list style="min-width: 100px"> |
| 7 | + <q-item clickable v-close-popup @click="delFriend()"> |
| 8 | + <q-item-section>Delete Friends</q-item-section> |
| 9 | + </q-item> |
| 10 | + </q-list> |
| 11 | + </q-menu> |
| 12 | + </q-btn> |
| 13 | + <div class="avatar"> |
| 14 | + <div class="img-container"> |
| 15 | + <img style="width: 100vw" :src="getAvatar()" alt=""> |
| 16 | + </div> |
| 17 | + <div class="username text-h4">{{route.params.id}}</div> |
| 18 | + <q-separator/> |
| 19 | + </div> |
| 20 | +</template> |
| 21 | +<script setup> |
| 22 | +import {useQuasar} from 'quasar'; |
| 23 | +const $q = useQuasar(); |
| 24 | +import {useCheckStore} from 'stores/check'; |
| 25 | +const store = useCheckStore(); |
| 26 | +import {useRoute,useRouter} from 'vue-router'; |
| 27 | +import Swal from "sweetalert2"; |
| 28 | +import axios from "axios"; |
| 29 | +const router = useRouter() |
| 30 | +const route = useRoute(); |
| 31 | +const getAvatar=()=>{ |
| 32 | + if(store.info.username===route.params.id){ |
| 33 | + return store.avatar(store.info.avatar) |
| 34 | + }else |
| 35 | + return store.avatar(store.info.friends.find(item => item.username === route.params.id).avatar); |
| 36 | +} |
| 37 | +const token = $q.localStorage.getItem('token') |
| 38 | +const delFriend=()=>{ |
| 39 | + Swal.fire({title:'Are you sure to delete this friend?',text:'You will not be able to recover this friend!',icon:'warning',showCancelButton:true,reverseButtons:true}).then((res)=>{ |
| 40 | + if(res.isConfirmed) { |
| 41 | + axios.post(`http://8.130.48.157:8081/api/newfriends?operation=delete&username=${route.params.id}`,'',{headers:{Authorization:`Bearer ${token}`}}).then((res)=>{ |
| 42 | + if(res.data.code===200){ |
| 43 | + Swal.fire('Deleted!','Your friend has been deleted.','success').then(()=>{ |
| 44 | + router.push('/chat') |
| 45 | + }) |
| 46 | + } |
| 47 | + }).catch(()=>{ |
| 48 | + Swal.fire('Oops...','Something went wrong!','error') |
| 49 | + }) |
| 50 | + } |
| 51 | + }) |
| 52 | +} |
| 53 | +</script> |
| 54 | +<style scoped lang="scss"> |
| 55 | +.avatar{ |
| 56 | + position: absolute; |
| 57 | + top:0; |
| 58 | + z-index: 100000; |
| 59 | + .img-container { |
| 60 | + position: relative; |
| 61 | +
|
| 62 | + img { |
| 63 | + display: block; |
| 64 | + } |
| 65 | +
|
| 66 | + &:before, |
| 67 | + &:after { |
| 68 | + content: ''; |
| 69 | + position: absolute; |
| 70 | + left: 0; |
| 71 | + right: 0; |
| 72 | + height: 25%; |
| 73 | + } |
| 74 | +
|
| 75 | + &:before { |
| 76 | + top: 0; |
| 77 | + background: linear-gradient(to bottom, rgba(0,0,0,0.5), rgba(0,0,0,0)); |
| 78 | + } |
| 79 | +
|
| 80 | + &:after { |
| 81 | + bottom: 0; |
| 82 | + background: linear-gradient(to top, rgba(0,0,0,0.5), rgba(0,0,0,0)); |
| 83 | + } |
| 84 | + } |
| 85 | + .username{ |
| 86 | + position: relative; |
| 87 | + top: -4rem; |
| 88 | + color:white; |
| 89 | + text-shadow: 3px 3px 2px rgba(127, 127, 127, 0.33);; |
| 90 | + padding: 0 1em; |
| 91 | + } |
| 92 | +} |
| 93 | +
|
| 94 | +</style> |
0 commit comments