login.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="style">
  5. <el-col :span="24" class="top">
  6. <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
  7. </el-col>
  8. <el-col :span="24" class="main">
  9. <van-tabs>
  10. <van-tab title="平台登录">
  11. <el-col :span="24">
  12. <van-form>
  13. <van-field v-model="webform.phone" name="手机/统一社会信用代码" label="手机/统一社会信用代码" placeholder="手机/统一社会信用代码" />
  14. <van-field v-model="webform.passwd" type="password" name="密码" label="密码" placeholder="密码" />
  15. <van-field name="radio" label="用户类别">
  16. <template #input>
  17. <van-radio-group v-model="webform.role" direction="horizontal">
  18. <van-radio name="4">个人</van-radio>
  19. <van-radio name="5">机构</van-radio>
  20. <van-radio name="6">专家</van-radio>
  21. <van-radio name="2">VIP用户</van-radio>
  22. </van-radio-group>
  23. </template>
  24. </van-field>
  25. <div style="margin: 16px;">
  26. <van-button round block type="info" @click="onwebSubmit">
  27. 登录
  28. </van-button>
  29. </div>
  30. </van-form>
  31. </el-col>
  32. </van-tab>
  33. <van-tab title="管理登录">
  34. <el-col :span="24">
  35. <van-form>
  36. <van-field v-model="form.phone" name="手机/机构代码" label="手机/机构代码" placeholder="手机/机构代码" />
  37. <van-field v-model="form.passwd" type="password" name="密码" label="密码" placeholder="密码" />
  38. <van-field name="radio" label="用户类别">
  39. <template #input>
  40. <van-radio-group v-model="form.role">
  41. <van-radio name="1">合作机构/业务管理员</van-radio>
  42. </van-radio-group>
  43. </template>
  44. </van-field>
  45. <div style="margin: 16px;">
  46. <van-button round block type="info" @click="onSubmit">
  47. 登录
  48. </van-button>
  49. </div>
  50. </van-form>
  51. </el-col>
  52. </van-tab>
  53. </van-tabs>
  54. </el-col>
  55. </el-col>
  56. </el-row>
  57. </div>
  58. </template>
  59. <script>
  60. import NavBar from '@/layout/common/topInfo.vue';
  61. import { mapState, createNamespacedHelpers } from 'vuex';
  62. const { mapActions: login } = createNamespacedHelpers('login');
  63. export default {
  64. name: 'index',
  65. props: {},
  66. components: {
  67. NavBar,
  68. },
  69. data: function() {
  70. return {
  71. // 头部标题
  72. title: '',
  73. // meta为true
  74. isleftarrow: '',
  75. // 返回
  76. navShow: true,
  77. // 平台登录
  78. webform: {},
  79. // 管理登录
  80. form: {},
  81. };
  82. },
  83. created() {},
  84. methods: {
  85. ...login({ toLogin: 'login' }),
  86. // 平台登录
  87. async onwebSubmit() {
  88. let data = this.webform;
  89. const res = await this.toLogin({ user: data });
  90. if (res.uid) {
  91. this.$router.push({ path: '/user/index' });
  92. }
  93. },
  94. // 管理登录
  95. async onSubmit() {
  96. let data = this.form;
  97. if (data.role == null) {
  98. data.role = '0';
  99. const res = await this.toLogin({ user: data });
  100. if (res.uid) {
  101. this.$router.push({ path: '/user/index' });
  102. }
  103. } else {
  104. const res = await this.toLogin({ user: data });
  105. if (res.uid) {
  106. this.$router.push({ path: '/user/index' });
  107. }
  108. }
  109. },
  110. },
  111. computed: {
  112. ...mapState(['user']),
  113. },
  114. mounted() {
  115. this.title = this.$route.meta.title;
  116. this.isleftarrow = this.$route.meta.isleftarrow;
  117. },
  118. metaInfo() {
  119. return { title: this.$route.meta.title };
  120. },
  121. };
  122. </script>
  123. <style lang="less" scoped>
  124. .style {
  125. width: 100%;
  126. min-height: 667px;
  127. position: relative;
  128. background-color: #f9fafc;
  129. }
  130. .top {
  131. height: 46px;
  132. overflow: hidden;
  133. }
  134. .main {
  135. min-height: 570px;
  136. }
  137. /deep/.van-field__label {
  138. width: 7.2em;
  139. }
  140. /deep/.van-radio--horizontal {
  141. margin: 0 15px 10px 0;
  142. }
  143. /deep/.van-field__label {
  144. text-align: center;
  145. }
  146. </style>