login.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template >
  2. <view>
  3. <view class="logo">
  4. <image class="img" src="@/assets/img/logo/logo1.png" mode=""></image>
  5. </view>
  6. <!-- <view class="logoText">
  7. e家能源
  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('/pages/mine/findBackPassword')" >
  18. 忘记密码? <span style="color:#387aea ;">点击找回</span>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import * as API from '@/apis/pagejs/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.tenantInfo);
  42. this.carhelp.setPersonInfoPlus(response.data)
  43. //this.gotoUrl("pages/user/index")
  44. uni.redirectTo({
  45. url: '/pages/index/index'
  46. })
  47. },
  48. query(){
  49. uni.showLoading({
  50. title: "加载中",
  51. mask: true,
  52. })
  53. var getOtherUserId=this.carhelp.getOtherUserId()
  54. var uid=this.carhelp.getUID()
  55. var openId=this.carhelp.getOpenId()
  56. API.findByOpenId({
  57. noerror:true,
  58. openId: uid?uid:openId,
  59. otherUserId:getOtherUserId
  60. }).then((response) => {
  61. this.loginset(response)
  62. }).catch(error => {
  63. uni.hideLoading();
  64. uni.showToast({
  65. icon: "none",
  66. title: error
  67. })
  68. })
  69. },
  70. submit(){
  71. if(!(this.phone.length&&this.password.length)){
  72. return
  73. }
  74. var checkPhoneResult = checkPhone(this.phone);
  75. if (checkPhoneResult !== true) {
  76. uni.showToast({
  77. icon: "none",
  78. title: checkPhoneResult,
  79. })
  80. return;
  81. }
  82. if(!this.password.length){
  83. uni.showToast({
  84. icon: "none",
  85. title: "请输入密码"
  86. })
  87. return
  88. }
  89. uni.showLoading({
  90. title: "加载中",
  91. mask: true,
  92. })
  93. API.login({
  94. password:this.password,
  95. phone:this.phone,
  96. openId: this.carhelp.getOpenId(),
  97. }).then((response) => {
  98. this.loginset(response)
  99. }).catch(error => {
  100. uni.hideLoading();
  101. uni.showToast({
  102. icon: "none",
  103. title: error?error:"登录失败"
  104. })
  105. })
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. page{
  112. background-color: #fff;
  113. padding-top: 160rpx;
  114. }
  115. .logoText{
  116. width: 160rpx;
  117. margin: 0 auto;
  118. line-height: 46rpx;
  119. color: rgba(16,16,16,1);
  120. font-size: 32rpx;
  121. margin-top: 20rpx;
  122. }
  123. .logo{
  124. margin: 0 auto;
  125. //width: 160rpx;
  126. border-radius: 16px;
  127. //background: linear-gradient(180deg, rgba(31,85,255,1) 0%,rgba(39,171,255,1) 100%);
  128. display: flex;
  129. align-items: center;
  130. justify-content: center;
  131. .img{
  132. width: 282rpx;
  133. height: 66rpx;
  134. }
  135. }
  136. .input-box{
  137. padding: 0 58rpx;
  138. margin-top: 112rpx;
  139. .tel-input,.password-input{
  140. display: flex;align-items: center;
  141. border-radius: 50px;
  142. background-color: rgba(248,248,248,1);
  143. color: rgba(16,16,16,1);
  144. height: 100rpx;
  145. line-height: 100rpx;
  146. padding: 0 48rpx;
  147. margin-bottom: 40rpx;
  148. }
  149. }
  150. .login-disable{
  151. margin: 80rpx 56rpx 40rpx;
  152. border-radius: 100rpx;
  153. background-color: rgba(223,223,223,1);
  154. color: rgba(255, 255, 255, 1);
  155. }
  156. .login{
  157. background-color: rgba(27,119,251,1);
  158. }
  159. .reset{
  160. color: rgba(119,119,119,1);
  161. text-align: center;
  162. }
  163. </style>