login.vue 4.2 KB

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