index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="login">
  3. <van-row>
  4. <van-col span="24">
  5. <div class="dk-banner"></div>
  6. </van-col>
  7. </van-row>
  8. <div>
  9. <van-cell-group style="margin-top: 60px;" :border="false">
  10. <!-- 输入手机号,调起手机号键盘 -->
  11. <van-row type="flex" justify="center">
  12. <van-col span="20">
  13. <van-field
  14. class="dk-border"
  15. v-model="phone"
  16. center
  17. clearable
  18. type="tel"
  19. left-icon="smile-o"
  20. placeholder="请输入手机号"
  21. ></van-field>
  22. </van-col>
  23. </van-row>
  24. <!-- 允许输入整数,调起数字键盘 -->
  25. <van-row type="flex" justify="center" align="center" style="margin-top: 40px">
  26. <van-col span="20">
  27. <van-field
  28. v-model="code"
  29. maxlength="6"
  30. type="digit"
  31. left-icon="smile-o"
  32. placeholder="请输入验证码"
  33. class="dk-border">
  34. <van-button
  35. :disabled="state.smsSendBtn"
  36. slot="button"
  37. size="small"
  38. type="default"
  39. @click="sendCode"
  40. style="border:none"
  41. class="dk-button "
  42. :class="state.smsSendBtn&&'dk-color'">
  43. {{!state.smsSendBtn && '获取验证码' || ('重发 '+state.time+' s')}}
  44. </van-button>
  45. </van-field>
  46. </van-col>
  47. </van-row>
  48. </van-cell-group>
  49. <van-row type="flex" justify="center">
  50. <van-col span="20">
  51. <van-button
  52. :loading="loading"
  53. type="small"
  54. size="large"
  55. :color="!phone||!code?'#DDDDDD':'#0177FF'"
  56. @cick="login"
  57. text="登录"
  58. style="height:47px;margin-top: 65px;border-radius: 47px;font-size: 16px;border-width: 0">
  59. </van-button>
  60. </van-col>
  61. </van-row>
  62. <van-row type="flex" justify="center" style="margin-top: 10px">
  63. <span class="dk-join" @click="join">企业入驻 >>></span>
  64. </van-row>
  65. </div>
  66. <van-row>
  67. <van-col span="24">
  68. <div class="dk-qrcode"></div>
  69. </van-col>
  70. </van-row>
  71. </div>
  72. </template>
  73. <script>
  74. // import {postAction} from '@/api/manage'
  75. import {Button, Cell, CellGroup, Field, Toast, Col, Row} from 'vant';
  76. import {setStore, getStore} from "@/utils/storage";
  77. export default {
  78. name: "index",
  79. components: {
  80. [Button.name]: Button,
  81. [Cell.name]: Cell,
  82. [CellGroup.name]: CellGroup,
  83. [Field.name]: Field,
  84. [Col.name]: Col,
  85. [Row.name]: Row,
  86. },
  87. data() {
  88. return {
  89. loading: false,
  90. text: "登录",
  91. phone: '',
  92. code: '',
  93. state: {
  94. time: 60,
  95. smsSendBtn: false,
  96. },
  97. url: {
  98. getSmsCaptcha: '/f/api/login/getAuthCode',
  99. }
  100. };
  101. },
  102. created() {
  103. //企业已登录,跳转企业首页
  104. if (getStore('login')) {
  105. this.$router.replace({name: 'user', params: {enterprise_id: 123}});
  106. }
  107. },
  108. methods: {
  109. login() {
  110. this.loading = true;
  111. //登录成功,缓存用户信息,跳转相应页面
  112. setStore('login', "123");
  113. this.$router.replace('goods');
  114. },
  115. //获取验证码
  116. sendCode() {
  117. if (!this.phone) {
  118. Toast('请输入手机号~');
  119. return;
  120. }
  121. this.state.smsSendBtn = true;
  122. let interval = window.setInterval(() => {
  123. if (this.state.time-- <= 0) {
  124. this.state.time = 60;
  125. this.state.smsSendBtn = false;
  126. window.clearInterval(interval);
  127. }
  128. }, 1000);
  129. let smsParams = {};
  130. smsParams.phone = this.phone;
  131. // postAction(this.url.getSmsCaptcha, smsParams)
  132. // .then(() => {
  133. // setTimeout(Toast('验证码发送中~'), 500);
  134. // })
  135. // .catch(() => {
  136. // setTimeout(Toast('验证码发送失败~'), 500);
  137. // clearInterval(interval);
  138. // this.state.time = 60;
  139. // this.state.smsSendBtn = false;
  140. // });
  141. },
  142. join() {
  143. this.$router.push({name: 'join'})
  144. }
  145. }
  146. }
  147. </script>
  148. <style scoped>
  149. .login {
  150. display: flex;
  151. flex-direction: column;
  152. justify-content: space-between;
  153. }
  154. .dk-banner {
  155. height: 160px;
  156. background: #ccc;
  157. }
  158. .dk-border {
  159. font-size: 14px;
  160. border: 1px solid #0177FF;
  161. border-radius: 47px;
  162. box-sizing: border-box;
  163. }
  164. .dk-button {
  165. height: auto;
  166. width: auto;
  167. font-size: 14px;
  168. color: #999999;
  169. opacity: 1;
  170. }
  171. .dk-color {
  172. color: #0177FF;
  173. }
  174. .dk-join {
  175. font-size: 12px;
  176. color: #0177FF;
  177. }
  178. .dk-qrcode {
  179. margin-top: 90px;
  180. height: 135px;
  181. background: #ccc;
  182. }
  183. </style>