123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <template>
- <transition name="msgbox-fade">
- <div class="pub-wrapper" v-if="visible">
- <div class="pub-mask"></div>
- <div class="pub-modal avater-modal">
- <div class="modal-hd">
- <i class="el-icon-close" @click="visible = false"></i>
- </div>
- <div class="modal-bd" v-if="userInfo">
- <div class="user-top">
- <div class="user-avatar">
- <img v-if="userInfo.cover_photo" :src="userInfo.cover_photo" alt="">
- <div v-else class="user-avatar"
- :class="'avatar_bg' + userInfo.user_id % 9"
- :data-name="userInfo.nick_name.slice(0,2).toUpperCase()"
- ></div>
- </div>
- <div class="r-info">
- <span class="name">{{userInfo.nick_name}}</span>
- <div class="introduce">@{{userInfo.user_id}}</div>
- </div>
- </div>
- <div class="account-wrap min-height-account">
- <div class="title">已绑定账户</div>
- <template v-if="accountList">
- <div class="account-item" v-for="(item, key) in accountList" :key="key">
- <div class="type">
- <strong>{{item.type.toUpperCase()}}</strong>
- </div>
- <p v-if="item.account && item.is_visible" class="key">{{item.account}}</p>
- <p v-else>未绑定或已隐藏</p>
- </div>
- </template>
- </div>
- <button v-if="$store.state.userId != userId" class="send-msg-btn" @click="sendMsg">发消息</button>
- </div>
- </div>
- </div>
- </transition>
- </template>
- <script>
- import { Button, Message, Switch } from 'element-ui'
- import Vue from 'vue'
- import { mapState } from 'vuex'
- import API from '@/api'
- Vue.component(Button.name, Button)
- Vue.component(Message.name, Message)
- Vue.component(Switch.name, Switch)
- export default {
- name: 'infoPopup',
- data () {
- return {
- accountList: null,
- userInfo: null
- }
- },
- computed: {
- ...mapState({
- members: state => state.group.members,
- sessionList: state => state.chat.sessionList,
- meId: state => state.userId,
- meInfo: state => state.userInfo
- })
- },
- methods: {
- sendMsg () {
- let youId = this.userInfo.user_id
- let sessionId = Number(youId) < Number(this.meId)
- ? `${youId}-${this.meId}`
- : `${this.meId}-${youId}`
- let repeatFlag = false
- this.sessionList.forEach(e => {
- if (e.session_id === sessionId) {
- repeatFlag = true
- }
- })
- if (!repeatFlag) {
- let obj = {
- cover_photo: this.userInfo.cover_photo,
- is_group: '0',
- name: this.userInfo.nick_name,
- // read_hash:null
- session_id: sessionId
- }
- this.$store.commit('addSessionItem', obj)
- }
- // 创建members,应对还没聊天记录的情况
- let myId = this.meInfo.user_id
- let members = {}
- members[myId] = {
- cover_photo: this.meInfo.cover_photo,
- nick_name: this.meInfo.nick_name
- }
- members[this.userInfo.user_id] = {
- cover_photo: this.userInfo.cover_photo,
- nick_name: this.userInfo.nick_name
- }
- this.$store.commit('updateGroup', {
- key: 'members',
- data: members
- })
- this.$store.commit('updateGroup', {
- key: 'privateName',
- data: this.userInfo.nick_name
- })
- this.$store.commit('changeSessionId', sessionId)
- this.visible = false
- }
- },
- created () {
- this.userInfo = this.members[this.userId]
- API.user.getOtherInfo({
- user_id: this.userId
- }).then(({ data }) => {
- this.accountList = data.data.binds
- })
- }
- }
- </script>
- <style lang="scss">
- @import "./style.scss";
- .min-height-account{
- min-height: 218px;
- }
- </style>
|