login.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template >
  2. <view>
  3. <view class="logo">
  4. <image class="img" src="@/assets/img/logo.png" mode=""></image>
  5. </view>
  6. <view class="logoText">
  7. 荆鹏电管家
  8. </view>
  9. <!-- 手机号/密码 -->
  10. <view class="input-box">
  11. <u-input v-model="phone" style="padding: 0 20px" class="tel-input" type="text" placeholder="请输入手机号码" />
  12. <u-input v-model="password" style="padding: 0 20px" class="password-input" type="password" placeholder="请输入密码" :password-icon="true" />
  13. </view>
  14. <button class="login-disable" :class="{
  15. login:password.length&&phone.length
  16. }" @click="submit" >登录</button>
  17. <view class="reset" @click="gotoUrl('')">
  18. 忘记密码? <span style="color:#387aea ;">点击找回</span>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import * as API from '@/apis/pagejs/e_user.js'
  24. import {
  25. checkPhone
  26. } from '@/apis/utils'
  27. export default {
  28. data() {
  29. return {
  30. phone:"",
  31. password:"",
  32. }
  33. },
  34. methods: {
  35. loginset(response){
  36. var token = response ? response.data.token : '';
  37. this.carhelp.setToken(token);
  38. this.carhelp.setPersonInfo(response.data.regUser);
  39. this.carhelp.setPersonInfoPlus(response.data)
  40. //this.gotoUrl("pages/user/index")
  41. uni.redirectTo({
  42. url: '/'
  43. })
  44. },
  45. query(){
  46. uni.showLoading({
  47. title: "加载中",
  48. mask: true,
  49. })
  50. API.findByOpenId({
  51. noerror:true,
  52. openId: this.carhelp.getOpenId(),
  53. }).then((response) => {
  54. this.loginset(response)
  55. }).catch(error => {
  56. uni.hideLoading();
  57. })
  58. },
  59. submit(){
  60. if(!(this.phone.length&&this.password.length)){
  61. return
  62. }
  63. var checkPhoneResult = checkPhone(this.phone);
  64. if (checkPhoneResult !== true) {
  65. uni.showToast({
  66. icon: "none",
  67. title: checkPhoneResult,
  68. })
  69. return;
  70. }
  71. if(!this.password.length){
  72. uni.showToast({
  73. icon: "none",
  74. title: "请输入密码"
  75. })
  76. return
  77. }
  78. uni.showLoading({
  79. title: "加载中",
  80. mask: true,
  81. })
  82. API.login({
  83. password:this.password,
  84. phone:this.phone,
  85. openId: this.carhelp.getOpenId(),
  86. }).then((response) => {
  87. //this.loginset(response)
  88. }).catch(error => {
  89. uni.hideLoading();
  90. })
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="scss" scoped>
  96. page{
  97. background-color: #fff;
  98. padding-top: 160rpx;
  99. }
  100. .logoText{
  101. width: 160rpx;
  102. margin: 0 auto;
  103. line-height: 46rpx;
  104. color: rgba(16,16,16,1);
  105. font-size: 32rpx;
  106. margin-top: 20rpx;
  107. }
  108. .logo{
  109. margin: 0 auto;
  110. width: 160rpx;
  111. height: 160rpx;
  112. border-radius: 16px;
  113. background: linear-gradient(180deg, rgba(31,85,255,1) 0%,rgba(39,171,255,1) 100%);
  114. display: flex;
  115. align-items: center;
  116. justify-content: center;
  117. .img{
  118. width: 112rpx;
  119. height: 112rpx;
  120. }
  121. }
  122. .input-box{
  123. padding: 0 58rpx;
  124. margin-top: 112rpx;
  125. .tel-input,.password-input{
  126. display: flex;align-items: center;
  127. border-radius: 50px;
  128. background-color: rgba(248,248,248,1);
  129. color: rgba(16,16,16,1);
  130. height: 100rpx;
  131. line-height: 100rpx;
  132. padding: 0 48rpx;
  133. margin-bottom: 40rpx;
  134. }
  135. }
  136. .login-disable{
  137. margin: 80rpx 56rpx 40rpx;
  138. border-radius: 100rpx;
  139. background-color: rgba(223,223,223,1);
  140. color: rgba(255, 255, 255, 1);
  141. }
  142. .login{
  143. background-color: rgba(27,119,251,1);
  144. }
  145. .reset{
  146. color: rgba(119,119,119,1);
  147. text-align: center;
  148. }
  149. </style>