index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <transition name="msgbox-fade">
  3. <div class="pub-wrapper" v-if="visible">
  4. <div class="pub-mask"></div>
  5. <div class="pub-modal avater-modal">
  6. <div class="modal-hd">
  7. <i class="el-icon-close" @click="visible = false"></i>
  8. </div>
  9. <div class="modal-bd" v-if="userInfo">
  10. <div class="user-top">
  11. <div class="user-avatar" @click="$editUserAvatar(userInfo.cover_photo)">
  12. <img v-if="userInfo.cover_photo" :src="userInfo.cover_photo" alt="">
  13. <div v-else class="user-avatar"
  14. :class="'avatar_bg' + userInfo.user_id % 9"
  15. :data-name="userInfo.nick_name.slice(0,2).toUpperCase()"
  16. ></div>
  17. <p>更改头像</p>
  18. </div>
  19. <div class="r-info">
  20. <span class="name" v-if="!isEditName" @click="isEditName = true">{{userInfo.nick_name}} <i class="el-icon-edit"></i></span>
  21. <input class="edit-name-input" type="text" v-else
  22. v-model="newNickName"
  23. v-focus
  24. @blur="handleEditName">
  25. <div class="introduce">@{{userInfo.user_id}}</div>
  26. </div>
  27. </div>
  28. <div class="account-wrap">
  29. <div class="title">已绑定账户</div>
  30. <div class="account-item" v-for="(item, key) in userInfo.binds" :key="key">
  31. <div class="type">
  32. <strong>{{item.type.toUpperCase()}}</strong>
  33. <div class="fr" v-if="item.account">
  34. <span v-if="item.is_visible === 0">已隐藏</span>
  35. <el-switch
  36. v-model="item.is_visible"
  37. :active-value="0"
  38. :inactive-value="1"
  39. @change="hanldeChange(item, $event)"
  40. active-color="#2298f0"
  41. inactive-color="#cbcbcb">
  42. </el-switch>
  43. </div>
  44. </div>
  45. <p v-if="item.account" class="key">{{item.account}}</p>
  46. <el-button @click="bindAccount(item.type)" v-else>绑定</el-button>
  47. </div>
  48. </div>
  49. <!-- <button class="send-msg-btn">发消息</button> -->
  50. </div>
  51. </div>
  52. </div>
  53. </transition>
  54. </template>
  55. <script>
  56. import { Button, Message, Switch } from 'element-ui'
  57. import Vue from 'vue'
  58. import { mapState } from 'vuex'
  59. import API from '@/api'
  60. Vue.component(Button.name, Button)
  61. Vue.component(Message.name, Message)
  62. Vue.component(Switch.name, Switch)
  63. export default {
  64. name: 'infoPopup',
  65. data () {
  66. return {
  67. isMe: true,
  68. newNickName: '', // 新用户名
  69. isEditName: false // 编辑用户名
  70. }
  71. },
  72. computed: {
  73. ...mapState({
  74. userInfo: state => state.userInfo
  75. })
  76. },
  77. methods: {
  78. // 账号显示与隐藏
  79. hanldeChange (item, val) {
  80. let type = item.type
  81. API.user.setVisible({
  82. type,
  83. is_visible: val
  84. }).then(({ data }) => {
  85. })
  86. },
  87. bindAccount (type) {
  88. },
  89. // 编辑用户名
  90. handleEditName () {
  91. this.isEditName = false
  92. if (this.newNickName.length) {
  93. API.user.changeNickName({
  94. nick_name: this.newNickName
  95. }).then(({ data }) => {
  96. this.$store.commit('setUserNickName', this.newNickName)
  97. this.$store.commit('updateMemberNickName', {
  98. userId: this.$store.state.userId,
  99. nickName: this.newNickName
  100. })
  101. this.$showTips('修改成功')
  102. })
  103. }
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="scss">
  109. @import "./style.scss";
  110. </style>