123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <template>
- <div class="chat-at">
- <div class="bar-wrap" v-bar>
- <div ref="container">
- <div class="item"
- v-for="(item, key) in filterList"
- :key="key"
- @click="atPerson(key)"
- :class="{'active': key === curInd}"
- >
- <div class="avatar" :class="`avatar_bg${item.user_id % 9}`">
- {{item.nick_name.slice(0,2).toUpperCase()}}
- </div>
- <span class="name">{{item.nick_name}}</span>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- export default {
- name: 'chatAt',
- props: {
- curInd: {
- type: Number
- },
- filterList: {
- type: Array
- }
- },
- watch: {
- curInd (val) {
- this.scrollIntoView()
- }
- },
- methods: {
- atPerson (key) {
- let item = this.filterList[key]
- this.$emit('atperson', item.nick_name)
- },
- scrollIntoView () {
- let dom = this.$refs.container.children[this.curInd]
- if (dom && dom.scrollIntoView) {
- dom.scrollIntoView({
- behavior: 'smooth',
- block: 'center',
- inline: 'nearest'
- })
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .chat-at {
- position: absolute;
- top: -100px;
- left: 2px;
- right: 2px;
- height: 100px;
- background-color: #ffffff;
- border-top-left-radius: 4px;
- border-top-right-radius: 4px;
- box-shadow: 0 0 2px rgba($color: #3a3a3a, $alpha: .3);
- }
- .bar-wrap{
- height: 100px;
- }
- .item{
- padding: 6px 8px;
- line-height: 20px;
- cursor: pointer;
- &.active{
- background-color: #eeeeee;
- }
- &:hover{
- background-color: #eeeeee;
- }
- }
- .avatar{
- display: inline-block;
- vertical-align: middle;
- margin-right: 10px;
- width: 20px;
- height: 20px;
- border-radius: 2px;
- line-height: 20px;
- text-align: center;
- color: #ffffff;
- font-size: 12px;
- }
- .name{
- font-size: 12px;
- color: #333333;
- display: inline-block;
- }
- </style>
|