heads.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. methods: {
  62. ...login({ loginUpdate: 'update', logout: 'logout' }),
  63. // 绑定微信
  64. bindBtn() {
  65. this.bindDia = true;
  66. },
  67. // 绑定微信关闭
  68. bindDown() {
  69. this.bindDia = false;
  70. },
  71. // 修改密码
  72. passwdBtn() {
  73. this.passwdDia = true;
  74. },
  75. // 修改密码提交
  76. submitForm({ data }) {
  77. data.id = this.user.id;
  78. let res = this.loginUpdate(data);
  79. if (this.$checkRes(res)) {
  80. this.passwdDia = false;
  81. this.$message({
  82. message: '修改密码成功',
  83. type: 'success',
  84. });
  85. this.$router.push({ path: '/login' });
  86. }
  87. },
  88. // 退出登录
  89. logoutBtn() {
  90. this.logout();
  91. this.$router.push({ path: '/login' });
  92. },
  93. handleClose(done) {
  94. done();
  95. },
  96. },
  97. computed: {
  98. ...mapState(['user']),
  99. pageTitle() {
  100. return `${this.$route.meta.title}`;
  101. },
  102. },
  103. metaInfo() {
  104. return { title: this.$route.meta.title };
  105. },
  106. };
  107. </script>
  108. <style lang="less" scoped>
  109. .left {
  110. padding: 0 20px;
  111. .el-image {
  112. float: left;
  113. width: 50px;
  114. height: 50px;
  115. margin: 5px 0 0 0;
  116. }
  117. span {
  118. height: 64px;
  119. line-height: 60px;
  120. font-size: 30px;
  121. color: #fff;
  122. padding: 0 10px;
  123. text-shadow: cornflowerblue 3px 3px 3px;
  124. font-family: cursive;
  125. }
  126. }
  127. .right {
  128. float: right;
  129. padding: 0 20px;
  130. text-align: right;
  131. height: 63px;
  132. line-height: 63px;
  133. span {
  134. border-right: 1px solid #000;
  135. padding: 0 15px;
  136. color: #000;
  137. .iconfont {
  138. margin: 0 5px 0 0;
  139. }
  140. }
  141. span:hover {
  142. cursor: pointer;
  143. }
  144. span:last-child {
  145. border-right: 0;
  146. }
  147. }
  148. /deep/.el-link.el-link--default {
  149. color: #000;
  150. font-size: 16px;
  151. top: -2px;
  152. }
  153. </style>