login_company_list.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div>
  3. <van-nav-bar title="我的组织" left-text="返回" @click-left="$route_back" left-arrow>
  4. <!-- <template slot="right" class="department_right_nav">
  5. <van-dropdown-menu duration="0.3" text="text" class="head_dropdown_menu">
  6. <van-dropdown-item title="•••" @change="plus_menu" :options="option" />
  7. </van-dropdown-menu>
  8. </template> -->
  9. </van-nav-bar>
  10. <div class="body_com has_header">
  11. <scroller>
  12. <div v-for="(item, index) in list" :key="index" style="padding-top:0.2rem; padding-left:0.2rem; padding-right:0.2rem;">
  13. <van-panel :title="item.site.name" style="box-shadow: 0 2px 4px rgba(140,140,140,0.1);border-radius:0.12rem;" class="company_name">
  14. <div style="padding:0.16rem 0.32rem; font-size:0.28rem; color:#666;">
  15. <p v-if="item.account_id == item.site.account_id">创建时间:{{ item.create_time | datetime }}</p>
  16. <p v-else>加入时间:{{ item.create_time | datetime }}</p>
  17. </div>
  18. <div slot="footer" style="text-align: right;"><van-button size="small" @click="login(item.site.id)" :loading="item.pass_loading" type="info">进入企业</van-button></div>
  19. </van-panel>
  20. </div>
  21. </scroller>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. import { getToken, setToken } from '@/utils/auth';
  27. import Vue from 'vue';
  28. import moment from 'moment';
  29. import { Panel,DropdownMenu,DropdownItem } from 'vant';
  30. Vue.use(Panel).use(DropdownMenu).use(DropdownItem);
  31. export default {
  32. name: 'login_company_list',
  33. data() {
  34. return {
  35. page: 0,
  36. list: [],
  37. option: [{ text: '账号注销', value: 1 }],
  38. };
  39. },
  40. filters: {
  41. datetime(time) {
  42. return moment(time * 1000).format('YYYY-MM-DD HH:mm:ss');
  43. }
  44. },
  45. // created() {
  46. // this.get_site_list();
  47. // },
  48. activated(){
  49. this.get_site_list();
  50. },
  51. methods: {
  52. plus_menu (val) {
  53. if (val) {
  54. this.$router.push('/verify')
  55. }
  56. },
  57. get_site_list() {
  58. this.$toast.loading({
  59. mask: false,
  60. message: '获取企业信息'
  61. });
  62. this.$axios('get', '/api/pro/account/site', '', 'token').then(res => {
  63. this.$toast.clear();
  64. if (res.data.code === 1) {
  65. this.list = res.data.data;
  66. if (this.list.length === 1) {
  67. this.login(this.list[0].site.id);
  68. }
  69. } else {
  70. this.$toast('获取企业失败');
  71. }
  72. });
  73. },
  74. login(id) {
  75. this.$toast.loading({
  76. mask: false,
  77. message: '正在登录,请稍候'
  78. });
  79. this.$axios('post', '/api/pro/employee-login', { site_id: id }).then(res => {
  80. const item = res.data.data;
  81. setToken(item.token);
  82. this.$removeCache('user_info');
  83. this.$store.commit('SET_USERINFO', res.data.data); // 设置员工信息
  84. window.sessionStorage.setItem('__VCKEEPALIVE__', JSON.stringify(['/','/home']))
  85. window.sessionStorage.setItem('routers', '/');
  86. window.location.href = window.location.href.split('#')[0];
  87. }).finally(() => {
  88. this.$toast.clear();
  89. });
  90. }
  91. }
  92. };
  93. </script>
  94. <style scoped>
  95. .body_com {
  96. height: calc(100% - 1rem);
  97. position: relative;
  98. background-color: #f5f5f5;
  99. }
  100. .company_name /deep/ .van-cell__title span {
  101. color: #1c1c1c;
  102. font-weight: bold;
  103. }
  104. .text{
  105. text-align: center;
  106. color: #969799;
  107. font-size: 0.28rem;
  108. padding: 0.2rem 0;
  109. }
  110. /deep/ .van-dropdown-menu__bar {
  111. background-color: transparent;
  112. }
  113. /deep/ .van-dropdown-menu__title{
  114. color: #FFF;
  115. }
  116. /deep/ .van-dropdown-menu__title::after{
  117. display: none;
  118. }
  119. /deep/ .van-nav-bar__right{
  120. overflow: hidden;
  121. }
  122. /deep/ .van-dropdown-menu__title--active{
  123. color: #FFF!important;
  124. }
  125. </style>