login.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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/h_user.js'
  24. import {
  25. checkPhone
  26. } from '@/apis/utils'
  27. export default {
  28. data() {
  29. return {
  30. phone:"",
  31. password:"",
  32. }
  33. },
  34. onLoad(){
  35. this.query()
  36. },
  37. methods: {
  38. loginset(response){
  39. var token = response ? response.data.token : '';
  40. this.carhelp.setToken(token);
  41. this.carhelp.setPersonInfo(response.data.regUser);
  42. this.carhelp.setPersonInfoPlus(response.data)
  43. //this.gotoUrl("pages/user/index")
  44. uni.redirectTo({
  45. url: '/pages/businessHall/index/index'
  46. })
  47. },
  48. query(){
  49. uni.showLoading({
  50. title: "加载中",
  51. mask: true,
  52. })
  53. API.findByOpenId({
  54. noerror:true,
  55. openId: this.carhelp.getOpenId(),
  56. }).then((response) => {
  57. this.loginset(response)
  58. }).catch(error => {
  59. uni.hideLoading();
  60. })
  61. },
  62. submit(){
  63. if(!(this.phone.length&&this.password.length)){
  64. return
  65. }
  66. var checkPhoneResult = checkPhone(this.phone);
  67. if (checkPhoneResult !== true) {
  68. uni.showToast({
  69. icon: "none",
  70. title: checkPhoneResult,
  71. })
  72. return;
  73. }
  74. if(!this.password.length){
  75. uni.showToast({
  76. icon: "none",
  77. title: "请输入密码"
  78. })
  79. return
  80. }
  81. uni.showLoading({
  82. title: "加载中",
  83. mask: true,
  84. })
  85. API.login({
  86. password:this.password,
  87. phone:this.phone,
  88. openId: this.carhelp.getOpenId(),
  89. }).then((response) => {
  90. this.loginset(response)
  91. }).catch(error => {
  92. uni.hideLoading();
  93. })
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. page{
  100. background-color: #fff;
  101. padding-top: 160rpx;
  102. }
  103. .logoText{
  104. width: 160rpx;
  105. margin: 0 auto;
  106. line-height: 46rpx;
  107. color: rgba(16,16,16,1);
  108. font-size: 32rpx;
  109. margin-top: 20rpx;
  110. }
  111. .logo{
  112. margin: 0 auto;
  113. width: 160rpx;
  114. height: 160rpx;
  115. border-radius: 16px;
  116. background: linear-gradient(180deg, rgba(31,85,255,1) 0%,rgba(39,171,255,1) 100%);
  117. display: flex;
  118. align-items: center;
  119. justify-content: center;
  120. .img{
  121. width: 112rpx;
  122. height: 112rpx;
  123. }
  124. }
  125. .input-box{
  126. padding: 0 58rpx;
  127. margin-top: 112rpx;
  128. .tel-input,.password-input{
  129. display: flex;align-items: center;
  130. border-radius: 50px;
  131. background-color: rgba(248,248,248,1);
  132. color: rgba(16,16,16,1);
  133. height: 100rpx;
  134. line-height: 100rpx;
  135. padding: 0 48rpx;
  136. margin-bottom: 40rpx;
  137. }
  138. }
  139. .login-disable{
  140. margin: 80rpx 56rpx 40rpx;
  141. border-radius: 100rpx;
  142. background-color: rgba(223,223,223,1);
  143. color: rgba(255, 255, 255, 1);
  144. }
  145. .login{
  146. background-color: rgba(27,119,251,1);
  147. }
  148. .reset{
  149. color: rgba(119,119,119,1);
  150. text-align: center;
  151. }
  152. </style>