login.vue 4.0 KB

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