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