index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view>
  3. <!-- 头部 -->
  4. <headContent>
  5. <template #left>
  6. <view class="head-revers-back iconfont" @click.stop="reversBackBtn()">&#xe604;</view>
  7. </template>
  8. </headContent>
  9. <view class="page-content">
  10. <text class="login-title">登录</text>
  11. <text class="login-content">Hi, 欢迎来到币王</text>
  12. <tabList ref="tabListRef" :tabIndex.sync="tabIndexs" />
  13. <!-- <component :is="phoneLogin"/> -->
  14. <phoneLogin v-show="tabIndexs === 0" :formData="formData" :areaCode="areaCode" />
  15. <emailLogin v-show="tabIndexs === 1" :formData="formData" />
  16. <view class="form-btn" style="margin-top: 28rpx;" @click.stop="formSubmit">
  17. 登录
  18. </view>
  19. <view class="form-hint">
  20. <text @click.stop="retrievePswd()">忘记密码?</text>
  21. <text class="form-hint-link"></text>
  22. <text @click.stop="register">立即注册</text>
  23. </view>
  24. </view>
  25. <load ref="loadRef" />
  26. <slider-verify ref="sliderVerifyRef" @slideImgSuccess="slideImgSuccess" />
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. reverseBack
  32. } from "@/utils/common.js"
  33. import {
  34. Api_userLogin
  35. } from "@/api/index.js"
  36. import phoneLogin from "./modules/phone.vue"
  37. import emailLogin from "./modules/email.vue"
  38. import mailboxLogin from "./modules/mailbox.vue"
  39. import tabList from "./modules/tab.vue"
  40. export default {
  41. name: 'login',
  42. components: {
  43. phoneLogin,
  44. emailLogin,
  45. mailboxLogin,
  46. tabList
  47. },
  48. data() {
  49. return {
  50. limina: false,
  51. tabIndexs: 0,
  52. areaCode: 86,
  53. formData: {
  54. user_string: '123456',
  55. password: 'Aa123456'
  56. }
  57. };
  58. },
  59. methods: {
  60. setAreaCode(e) {
  61. if (e) {
  62. this.areaCode = e.area_code;
  63. }
  64. },
  65. reversBackBtn() {
  66. reverseBack()
  67. },
  68. register() {
  69. uni.navigateTo({
  70. url: '/pages/login/register'
  71. })
  72. },
  73. // 忘记密码
  74. retrievePswd() {
  75. uni.navigateTo({
  76. url: '/pages/login/retrieve-pswd'
  77. })
  78. },
  79. // 提交登录
  80. formSubmit() {
  81. this.$nextTick(() => {
  82. this.$refs.loadRef.open();
  83. })
  84. setTimeout(() => {
  85. this.$refs.loadRef.close();
  86. setTimeout(() => {
  87. this.$nextTick(() => {
  88. this.$refs.sliderVerifyRef.open()
  89. })
  90. }, 100)
  91. }, 1500)
  92. },
  93. slideImgSuccess() {
  94. if (this.limina) {
  95. return false
  96. };
  97. this.limina = true
  98. Api_userLogin(this.formData).then(res => {
  99. if (res) {
  100. this.$store.dispatch("app/setToken", res)
  101. reverseBack()
  102. }
  103. }).catch(err => {
  104. }).finally(() => {
  105. this.limina = false;
  106. })
  107. }
  108. }
  109. }
  110. </script>
  111. <style>
  112. page {
  113. background-color: #fff;
  114. }
  115. </style>
  116. <style lang="scss" scoped>
  117. @import "~./common.scss"
  118. </style>