index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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: '14100000001',
  55. password: '123456'
  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. uni.showLoading({
  99. title: '',
  100. mask: true
  101. });
  102. Api_userLogin(this.formData).then(res => {
  103. setTimeout(() => {
  104. if (res) {
  105. uni.showToast({
  106. title: '登录成功',
  107. icon: "none"
  108. })
  109. this.$store.dispatch("app/setToken", res)
  110. setTimeout(() => {
  111. uni.reLaunch({
  112. url: '/pages/index/index'
  113. });
  114. }, 500)
  115. }
  116. }, 300)
  117. }).catch(err => {
  118. }).finally(() => {
  119. setTimeout(() => {
  120. this.limina = false;
  121. uni.hideLoading({
  122. title: '',
  123. mask: true
  124. });
  125. },200)
  126. })
  127. }
  128. }
  129. }
  130. </script>
  131. <style>
  132. page {
  133. background-color: #fff;
  134. }
  135. </style>
  136. <style lang="scss" scoped>
  137. @import "~./common.scss"
  138. </style>