login.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class="container">
  3. <view class="wjmm" style="text-align: right;padding-right: 30rpx;font-size: 36rpx;" @click="zc()">
  4. 注冊
  5. </view>
  6. <view class="tit" style="padding-top:120rpx;">
  7. 郵箱
  8. </view>
  9. <input type="text" class="shuru" placeholder="請翰入郵箱" v-model="email">
  10. <view class="tit">
  11. 密碼
  12. </view>
  13. <input type="password" class="shuru" placeholder="請翰入密碼" v-model="lpwd" >
  14. <view class="" style="padding:20rpx 48rpx;">
  15. <view class="wjmm" @click="wjmm()">
  16. 忘記密碼?
  17. </view>
  18. </view>
  19. <view class="flex" style="justify-content: flex-end;padding: 0 48rpx;">
  20. <view class="gologin" @click="gologin">
  21. 登錄
  22. </view>
  23. </view>
  24. <!-- <view class="login_text">
  25. <view class="login_input flex">
  26. <view class="login_img">
  27. <image src="/static/icon/img03.png"></image>
  28. </view>
  29. <view class="login_name"><input class="uni-input" v-model="username" focus placeholder="请输入手机号" />
  30. </view>
  31. </view>
  32. <view class="login_input flex">
  33. <view class="login_img">
  34. <image src="/static/icon/img04.png"></image>
  35. </view>
  36. <view class="login_name"><input class="uni-input" type="password" v-model="passward" focus
  37. placeholder="请输入密码" /></view>
  38. </view>
  39. <view><button type="green" class="uni-button uni-button-green" @click="toLogin">登录</button></view>
  40. <view><button type="green" class="uni-button uni-button-green uni-button-green-plain" plain="true"
  41. hover-class="none" @click="register">注册</button></view>
  42. <navigator url="./forget">
  43. <view class="forget">忘记密码</view>
  44. </navigator>
  45. <view class="flex other">
  46. <view class="fenge"></view>
  47. <view class="qita">其他方式登录</view>
  48. <view class="fenge"></view>
  49. </view>
  50. </view> -->
  51. </view>
  52. </template>
  53. <script>
  54. import {
  55. loginWx,
  56. gologin
  57. } from '@/api/login.js';
  58. export default {
  59. data() {
  60. return {
  61. email: '',
  62. lpwd: ''
  63. };
  64. },
  65. onLoad() {
  66. },
  67. methods: {
  68. zc() {
  69. uni.navigateTo({
  70. url: '/pages/public/register',
  71. })
  72. },
  73. wjmm() {
  74. uni.navigateTo({
  75. url: '/pages/public/forget',
  76. })
  77. },
  78. gologin() {
  79. let obj = this
  80. if(obj.loadingType == 'loading') {
  81. return
  82. }
  83. if(!obj.isEmailAvailable(obj.email)) {
  84. return obj.$api.msg('請輸入正確的郵箱!')
  85. }
  86. obj.loadingType = 'loading'
  87. gologin({
  88. email: obj.email,
  89. lpwd: obj.lpwd
  90. }).then(res => {
  91. console.log(res)
  92. obj.loadingType = 'no'
  93. }).catch(err => {
  94. console.log(err)
  95. obj.loadingType = 'no'
  96. })
  97. },
  98. isEmailAvailable(obj) {
  99. let email = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
  100. if (!email.test(obj)) {
  101. return false;
  102. }
  103. return true;
  104. },
  105. }
  106. };
  107. </script>
  108. <style lang="scss">
  109. page {
  110. height: 100%;
  111. background-color: #fff;
  112. font-size: 32rpx;
  113. }
  114. .container {
  115. width: 100%;
  116. height: 100%;
  117. background-size: 100%;
  118. }
  119. .shuru {
  120. display: block;
  121. background-color: #f5f5f5;
  122. width: 673rpx;
  123. height: 95rpx;
  124. margin: auto;
  125. padding-left: 30rpx;
  126. text-align: 95rpx;
  127. }
  128. .tit {
  129. padding:60rpx 48rpx 20rpx;
  130. }
  131. .gologin {
  132. width: 204rpx;
  133. height: 98rpx;
  134. line-height: 98rpx;
  135. background-color: #fcd535;
  136. text-align: center;
  137. border-radius: 20rpx;
  138. }
  139. .wjmm {
  140. color: #fcd535;
  141. }
  142. </style>