123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <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" @click="$editUserAvatar(userInfo.cover_photo)">
- <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>
- <p>更改头像</p>
- </div>
- <div class="r-info">
- <span class="name" v-if="!isEditName" @click="isEditName = true">{{userInfo.nick_name}} <i class="el-icon-edit"></i></span>
- <input class="edit-name-input" type="text" v-else
- v-model="newNickName"
- v-focus
- @blur="handleEditName">
- <div class="introduce">@{{userInfo.user_id}}</div>
- </div>
- </div>
- <div class="account-wrap">
- <div class="title">已绑定账户</div>
- <div class="account-item" v-for="(item, key) in userInfo.binds" :key="key">
- <div class="type">
- <strong>{{item.type.toUpperCase()}}</strong>
- <div class="fr" v-if="item.account">
- <span v-if="item.is_visible === 0">已隐藏</span>
- <el-switch
- v-model="item.is_visible"
- :active-value="0"
- :inactive-value="1"
- @change="hanldeChange(item, $event)"
- active-color="#2298f0"
- inactive-color="#cbcbcb">
- </el-switch>
- </div>
- </div>
- <p v-if="item.account" class="key">{{item.account}}</p>
- <el-button @click="bindAccount(item.type)" v-else>绑定</el-button>
- </div>
- </div>
- <!-- <button class="send-msg-btn">发消息</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 {
- isMe: true,
- newNickName: '', // 新用户名
- isEditName: false // 编辑用户名
- }
- },
- computed: {
- ...mapState({
- userInfo: state => state.userInfo
- })
- },
- methods: {
- // 账号显示与隐藏
- hanldeChange (item, val) {
- let type = item.type
- API.user.setVisible({
- type,
- is_visible: val
- }).then(({ data }) => {
- })
- },
- bindAccount (type) {
- },
- // 编辑用户名
- handleEditName () {
- this.isEditName = false
- if (this.newNickName.length) {
- API.user.changeNickName({
- nick_name: this.newNickName
- }).then(({ data }) => {
- this.$store.commit('setUserNickName', this.newNickName)
- this.$store.commit('updateMemberNickName', {
- userId: this.$store.state.userId,
- nickName: this.newNickName
- })
- this.$showTips('修改成功')
- })
- }
- }
- }
- }
- </script>
- <style lang="scss">
- @import "./style.scss";
- </style>
|