heads.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <div id="heads">
  3. <el-row>
  4. <el-col :span="24" class="heads">
  5. <el-col :span="12" class="left">
  6. <el-image :src="afterInfo.logo"></el-image>
  7. <span>{{ afterInfo.title }}</span>
  8. </el-col>
  9. <el-col :span="12" class="right">
  10. <!-- <span @click="bindBtn()"><i class="iconfont iconbangding"></i>绑定微信</span> -->
  11. <span @click="passwdBtn()"><i class="iconfont iconmima_huaban1"></i>修改密码</span>
  12. <span
  13. ><i class="iconfont iconicon-person"></i>
  14. <span v-if="user.id">
  15. {{ user.name }}
  16. </span>
  17. <span v-else>
  18. <el-link href="/login" :underline="false">登录</el-link>
  19. </span>
  20. </span>
  21. <span @click="logoutBtn()"><i class="iconfont iconiconfront-"></i>退出登录</span>
  22. </el-col>
  23. </el-col>
  24. </el-row>
  25. <el-dialog title="绑定" :visible.sync="bindDia" width="30%" :before-close="handleClose">
  26. <bind @bindDown="bindDown"></bind>
  27. </el-dialog>
  28. <el-dialog title="修改密码" :visible.sync="passwdDia" width="30%" :before-close="handleClose">
  29. <passwdDias :form="form" @submitForm="submitForm"></passwdDias>
  30. </el-dialog>
  31. </div>
  32. </template>
  33. <script>
  34. import { mapState, createNamespacedHelpers } from 'vuex';
  35. const { mapActions: login } = createNamespacedHelpers('login');
  36. import bind from './parts/bind.vue';
  37. import passwdDias from './parts/passwdDia.vue';
  38. export default {
  39. name: 'heads',
  40. props: {},
  41. components: {
  42. // 绑定微信
  43. bind,
  44. // 修改密码
  45. passwdDias,
  46. },
  47. data: function() {
  48. return {
  49. afterInfo: {
  50. logo: require('@/assets/logo.png'),
  51. title: '管理后台',
  52. },
  53. // 绑定微信
  54. bindDia: false,
  55. // 修改密码
  56. passwdDia: false,
  57. form: {},
  58. };
  59. },
  60. created() {
  61. console.log(this.user);
  62. },
  63. methods: {
  64. ...login({ loginUpdate: 'update', logout: 'logout' }),
  65. // 绑定微信
  66. bindBtn() {
  67. this.bindDia = true;
  68. },
  69. // 绑定微信关闭
  70. bindDown() {
  71. this.bindDia = false;
  72. },
  73. // 修改密码
  74. passwdBtn() {
  75. this.passwdDia = true;
  76. },
  77. // 修改密码提交
  78. submitForm({ data }) {
  79. data.id = this.user.id;
  80. let res = this.loginUpdate(data);
  81. if (this.$checkRes(res)) {
  82. this.passwdDia = false;
  83. this.$message({
  84. message: '修改密码成功',
  85. type: 'success',
  86. });
  87. this.$router.push({ path: '/login' });
  88. }
  89. },
  90. // 退出登录
  91. logoutBtn() {
  92. this.logout();
  93. this.$router.push({ path: '/login' });
  94. },
  95. handleClose(done) {
  96. done();
  97. },
  98. },
  99. computed: {
  100. ...mapState(['user']),
  101. pageTitle() {
  102. return `${this.$route.meta.title}`;
  103. },
  104. },
  105. metaInfo() {
  106. return { title: this.$route.meta.title };
  107. },
  108. };
  109. </script>
  110. <style lang="less" scoped>
  111. .left {
  112. padding: 0 20px;
  113. .el-image {
  114. float: left;
  115. width: 50px;
  116. height: 50px;
  117. margin: 5px 0 0 0;
  118. }
  119. span {
  120. height: 64px;
  121. line-height: 60px;
  122. font-size: 30px;
  123. color: #fff;
  124. padding: 0 10px;
  125. text-shadow: cornflowerblue 3px 3px 3px;
  126. font-family: cursive;
  127. }
  128. }
  129. .right {
  130. float: right;
  131. padding: 0 20px;
  132. text-align: right;
  133. height: 63px;
  134. line-height: 63px;
  135. span {
  136. border-right: 1px solid #000;
  137. padding: 0 15px;
  138. color: #000;
  139. .iconfont {
  140. margin: 0 5px 0 0;
  141. }
  142. }
  143. span:hover {
  144. cursor: pointer;
  145. }
  146. span:last-child {
  147. border-right: 0;
  148. }
  149. }
  150. /deep/.el-link.el-link--default {
  151. color: #000;
  152. font-size: 16px;
  153. top: -2px;
  154. }
  155. </style>