index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <view class="uni-app">
  3. <view class="status-bar" />
  4. <view class="main-container">
  5. <view class="logo-box">
  6. <image :src="$static('images/logo.png')" alt="" class="logo" />
  7. </view>
  8. <view class="app-name">
  9. {{ appName }}
  10. </view>
  11. <view class="subhead">
  12. 实现企业『销售+管理』全流程
  13. </view>
  14. <login-form v-model="form" />
  15. <view
  16. class="form-btn linear-gradient"
  17. @click="loginByUsername">
  18. 登&nbsp;&nbsp;录
  19. </view>
  20. <view class="law">
  21. <text class="wk wk-check-fill icon" :class="{active: agreeLaw}" />
  22. 我已阅读并同意
  23. <text class="special" @click.stop="handleTo('/pages_law/service')">
  24. 《用户协议》
  25. </text>
  26. <text class="special" @click.stop="handleTo('/pages_law/privacy')">
  27. 《隐私声明》
  28. </text>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import LoginForm from './components/loginForm.vue'
  35. import {
  36. appName,
  37. appVersion
  38. } from '@/config'
  39. import {
  40. mapActions
  41. } from 'vuex'
  42. import request from 'UTIL/request'
  43. export default {
  44. name: 'LoginIndex',
  45. components: {
  46. LoginForm
  47. },
  48. data() {
  49. return {
  50. appName: appName,
  51. form: {
  52. username: '',
  53. password: ''
  54. },
  55. agreeLaw: true
  56. }
  57. },
  58. onLoad() {
  59. this.$clearStorage()
  60. const username = uni.getStorageSync('username') || ''
  61. this.$set(this.form, 'username', username)
  62. },
  63. onShow() {
  64. this.$clearStorage()
  65. },
  66. methods: {
  67. ...mapActions({
  68. login: 'user/login'
  69. }),
  70. /**
  71. * 账号登陆
  72. */
  73. loginByUsername() {
  74. // const mobileReg = /1[1-9]\d{9}$/
  75. if (!this.form.username || this.form.username == '') {
  76. this.$toast('登录账号不能为空')
  77. return
  78. }
  79. if (!this.form.password || this.form.password == '') {
  80. this.$toast('密码不能为空')
  81. return
  82. }
  83. this.login(this.form).then(res => {
  84. console.log('ok')
  85. if (res === 1) {
  86. this.$Router.reLaunch('/pages/home/index')
  87. } else if (res === 2) {
  88. // this.$router.push('/choose')
  89. }
  90. }).catch(() => {})
  91. },
  92. /**
  93. * 短信验证码
  94. */
  95. toSmsCode(type) {
  96. // type login 短信登录 forget 忘记密码 register 注册新企业
  97. },
  98. handleTo(url, query) {
  99. this.$Router.navigateTo({
  100. url,
  101. query
  102. })
  103. },
  104. clearSite() {}
  105. }
  106. }
  107. </script>
  108. <style scoped lang="scss">
  109. @import "./style/style.scss";
  110. .placehoder {
  111. font-size: 30rpx;
  112. }
  113. .status-bar {
  114. background: white;
  115. }
  116. .main-container {
  117. width: 100%;
  118. height: 100%;
  119. padding: 0 40rpx;
  120. font-size: 32rpx;
  121. background-color: white;
  122. .logo-box {
  123. margin: 66rpx auto 0;
  124. }
  125. }
  126. </style>