aboutMe.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div class="about-me">
  3. <div class="pub-user-top" @click="$router.push('/editMe')" v-if="userInfo">
  4. <div class="avatar-wrap">
  5. <img class="user-avatar" v-if="userInfo.cover_photo" :src="userInfo.cover_photo" alt="" @click.stop="$showImgPreview(userInfo.cover_photo)">
  6. <div v-else class="user-avatar"
  7. :class="'avatar_bg' + userInfo.user_id % 9"
  8. :data-name="userInfo.nick_name.slice(0,2).toUpperCase()"
  9. ></div>
  10. </div>
  11. <div class="top-info">
  12. <div class="name">{{userInfo.nick_name}}</div>
  13. <div class="code">{{$t('h5.username')}}:@{{userInfo.user_name}}</div>
  14. </div>
  15. <i class="arrow-icon el-icon-arrow-right"></i>
  16. </div>
  17. <ul class="pub-account-list" v-if="userInfo">
  18. <li class="list-item" v-for="(item, key) in userInfo.binds" :key="key">
  19. <div class="icon-wrap">
  20. <i :class="`${item.type}-icon`"></i>
  21. </div>
  22. <div class="info">
  23. <div class="title-wrap">
  24. <h4>{{item.type.toUpperCase()}}</h4>
  25. <p>{{item.account || $t('h5.notBind')}}</p>
  26. </div>
  27. <div class="btn-unbind" v-if="item.account" @click.stop="unbindAccount(item.type)">{{$t('userinfo.unbind')}}</div>
  28. <el-button @click="bindAccount(item.type)" v-else>{{$t('userinfo.bind')}}</el-button>
  29. <div class="opetate" v-if="item.account" @click.stop="hanldeChange(item)">
  30. <i :class="item.is_visible === 0 ? 'unopen' : 'open'"></i>
  31. <p>{{item.is_visible === 0 ? $t('userinfo.private') : $t('userinfo.public')}}</p>
  32. </div>
  33. </div>
  34. </li>
  35. <!-- <li class="list-item ext-psw" @click="handlePsw">
  36. <div class="icon-wrap">
  37. <i class="psw-icon"></i>
  38. </div>
  39. <div class="info">
  40. <div class="title">{{$t('public.pswSetting')}}</div>
  41. <i class="arrow-icon el-icon-arrow-right"></i>
  42. </div>
  43. </li> -->
  44. </ul>
  45. <div class="pub-bottom-btn ext-lang" @click="changeLang"><i class="icon-change"></i>{{curLang=="en"?$t('public.chinese'):$t('public.english')}}</div>
  46. <div class="pub-bottom-btn" @click="loginOut">{{$t('h5.logout')}}</div>
  47. </div>
  48. </template>
  49. <script>
  50. import Vue from 'vue'
  51. import { Button } from 'element-ui'
  52. import { mapState } from 'vuex'
  53. import API from '@/api'
  54. import { changeLangMixin } from '@/mixins'
  55. import { bindAccountMixins } from '@/mixins/user'
  56. Vue.component(Button.name, Button)
  57. export default {
  58. name: 'aboutMe',
  59. mixins: [changeLangMixin, bindAccountMixins],
  60. data () {
  61. return {
  62. }
  63. },
  64. computed: {
  65. ...mapState({
  66. userInfo: state => {
  67. return state.userInfo
  68. }
  69. })
  70. },
  71. methods: {
  72. bindAccount (type) {
  73. switch (type) {
  74. case 'eos':
  75. this.bindEos()
  76. break
  77. case 'tg':
  78. this.bindTg()
  79. break
  80. }
  81. },
  82. loginOut () {
  83. this.$store.dispatch('doScatterLogout').then(() => {
  84. // this.$router.replace({ name: 'login', query: { from: '/me' } })
  85. this.$store.commit('setUserInfo', null)
  86. this.$store.commit('initChatData')
  87. this.$store.commit('initGroupData')
  88. this.$store.commit('chatAppLogin', false)
  89. // this.$store.commit('toApp', true)
  90. location.reload()
  91. })
  92. },
  93. // 账号显示与隐藏
  94. hanldeChange (item) {
  95. let type = item.type
  96. let val = item.is_visible == 0 ? 1 : 0
  97. API.user.setVisible({
  98. type,
  99. is_visible: val
  100. }).then(({ data }) => {
  101. this.$store.dispatch('getUserInfo')
  102. })
  103. },
  104. handlePsw () {
  105. this.$router.push('/password')
  106. }
  107. },
  108. created () {
  109. this.$store.dispatch('getUserInfo')
  110. }
  111. }
  112. </script>