login.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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>优电联盟</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. phone:this.userName,
  93. openId: this.jphelp.getOpenId(),
  94. noerror:true,
  95. roleName:'XJ',
  96. //type:2,
  97. }).then((response) => {
  98. if(response.message){
  99. uni.hideLoading();
  100. if(response.message=='没有权限'){
  101. uni.showModal({
  102. title:"提示",
  103. showCancel:false,
  104. content:"没有权限"
  105. })
  106. }else{
  107. uni.showToast({
  108. icon: "none",
  109. title: response.message?response.message:"登录失败"
  110. })
  111. }
  112. }else{
  113. this.loginset(response)
  114. uni.switchTab({
  115. url: '/pages/index/index'
  116. })
  117. }
  118. }).catch(error => {
  119. uni.hideLoading();
  120. uni.showToast({
  121. icon: "none",
  122. title: error?error:"登录失败"
  123. })
  124. })
  125. }
  126. }
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. page{
  131. background: linear-gradient(180deg, rgba(218,238,254,1) 40%,rgba(203,234,255,0) 100%);
  132. padding-top: 160rpx;
  133. }
  134. .logoText{
  135. text-align: center;
  136. width: 160rpx;
  137. margin: 0 auto;
  138. line-height: 46rpx;
  139. color: rgba(16,16,16,1);
  140. font-size: 32rpx;
  141. margin-top: 20rpx;
  142. }
  143. .logo{
  144. margin: 0 auto;
  145. //width: 160rpx;
  146. border-radius: 16px;
  147. //background: linear-gradient(180deg, rgba(31,85,255,1) 0%,rgba(39,171,255,1) 100%);
  148. display: flex;
  149. align-items: center;
  150. justify-content: center;
  151. .img{
  152. width: 144rpx;
  153. height: 144rpx;
  154. border-radius: 16px;
  155. }
  156. }
  157. .input-box{
  158. padding: 0 58rpx;
  159. margin-top: 112rpx;
  160. .tel-input,.password-input{
  161. display: flex;align-items: center;
  162. border-radius: 50px;
  163. background-color: rgba(248,248,248,1);
  164. color: rgba(16,16,16,1);
  165. height: 100rpx;
  166. line-height: 100rpx;
  167. padding: 0 48rpx;
  168. margin-bottom: 40rpx;
  169. }
  170. }
  171. .login-disable{
  172. margin: 80rpx 56rpx 40rpx;
  173. border-radius: 100rpx;
  174. background-color: rgba(223,223,223,1);
  175. color: rgba(255, 255, 255, 1);
  176. }
  177. .login{
  178. background-color: rgba(27,119,251,1);
  179. }
  180. .reset{
  181. color: rgba(119,119,119,1);
  182. text-align: center;
  183. }
  184. </style>