login.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view style="height: 100vh;">
  3. <view class="status_bar"></view>
  4. <view class="logo">
  5. <image src="../../static/image/login/8eef2e54055a5b072a5dc000919a7ae.png" mode=""></image>
  6. </view>
  7. <form @submit="formSubmit">
  8. <view class="uni-form-item uni-column">
  9. <view class="username">
  10. <u-icon name="account" size="36" style="margin-right:30rpx;color: #72CD9C;"></u-icon>
  11. <!-- <input class="uni-input" name="username" placeholder-class="icon iconfont icon-bianji1" placeholder="请输入用户名" /> -->
  12. <u-input class="uni-input" name="username" v-model="formdata.username" placeholder-class="icon iconfont icon-bianji1"
  13. placeholder="请输入用户名" />
  14. </view>
  15. <view class="passwold">
  16. <u-icon name="lock" size="36" style="margin-right:30rpx;color: #72CD9C;"></u-icon>
  17. <u-input v-model="formdata.passwold" type="password" :password-icon="true" :clearable="false" placeholder="请输入密码"
  18. @confirm="formSubmit" @input="passwoldddata" />
  19. </view>
  20. <view class="aboutpass">
  21. <u-checkbox-group>
  22. <u-checkbox v-model="checked" :label-disabled="false" size="22" @change="rempass">记住密码</u-checkbox>
  23. </u-checkbox-group>
  24. </view>
  25. <view class="uni-btn-v">
  26. <button form-type="submit">登 录</button>
  27. </view>
  28. </view>
  29. </form>
  30. <view class="bg">
  31. <image src="../../static/image/login/850c9307f4ef2d7dc6db1049711ab55.jpg" mode=""></image>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. checked: false,
  40. formdata: {
  41. username: '',
  42. passwold: ''
  43. }
  44. }
  45. },
  46. onLoad() {
  47. uni.getStorage({
  48. key: 'user_pass',
  49. success: (res) => {
  50. if(res.data){
  51. this.formdata.passwold = res.data
  52. this.checked =true
  53. }else{
  54. this.checked =false
  55. }
  56. }
  57. })
  58. },
  59. methods: {
  60. async formSubmit() {
  61. const res = await this.$myRequest({
  62. url: '/api/api_gateway?method=user.login.login_user',
  63. data: {
  64. username: this.formdata.username,
  65. password: this.formdata.passwold
  66. }
  67. })
  68. let session_key = res.session_key
  69. uni.setStorage({
  70. key: 'session_key',
  71. data: session_key,
  72. success: () => {
  73. uni.switchTab({
  74. url: "../index/index"
  75. })
  76. }
  77. })
  78. },
  79. passwoldddata() {
  80. this.formdata.passwold = this.formdata.passwold.replace(/[\u4E00-\u9FA5]/g, '')
  81. },
  82. rempass(val) {
  83. if(val.value){
  84. uni.setStorage({
  85. key: 'user_pass',
  86. data: this.formdata.passwold,
  87. success: function() {
  88. console.log('success');
  89. }
  90. })
  91. }else{
  92. uni.removeStorage({
  93. key: 'user_pass',
  94. success: function() {
  95. console.log('success');
  96. }
  97. })
  98. }
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss">
  104. .logo {
  105. width: 100%;
  106. height: 340rpx;
  107. text-align: center;
  108. display: flex;
  109. align-items: center;
  110. padding-top: 240rpx;
  111. image {
  112. width: 280rpx;
  113. margin: 0 auto;
  114. height: 120rpx;
  115. }
  116. }
  117. .bg {
  118. width: 100%;
  119. position: fixed;
  120. bottom: 0;
  121. z-index: -1;
  122. image {
  123. width: 100%;
  124. }
  125. }
  126. /deep/.u-input__right-icon {
  127. line-height: 35px !important;
  128. }
  129. .uni-form-item {
  130. width: 100%;
  131. .username {
  132. width: 80%;
  133. margin: 0 auto;
  134. display: flex;
  135. margin-bottom: 40rpx;
  136. padding-bottom: 10rpx;
  137. border-bottom: 2rpx solid #C3C3C3;
  138. }
  139. .passwold {
  140. width: 80%;
  141. margin: 0 auto;
  142. display: flex;
  143. margin-bottom: 40rpx;
  144. padding-bottom: 10rpx;
  145. border-bottom: 2rpx solid #C3C3C3;
  146. }
  147. .aboutpass {
  148. width: 80%;
  149. margin: 0 auto;
  150. display: flex;
  151. justify-content: flex-end;
  152. p {
  153. color: #C0C0C0;
  154. font-size: 28rpx;
  155. }
  156. /deep/.u-checkbox__label {
  157. font-size: 28rpx;
  158. color: #C0C0C0;
  159. margin-right: 0;
  160. }
  161. }
  162. .uni-btn-v {
  163. width: 80%;
  164. margin: 112rpx auto 0;
  165. position: relative;
  166. z-index: 100;
  167. button {
  168. width: 100%;
  169. height: 72rpx;
  170. line-height: 75rpx;
  171. background-color: #5DC18B;
  172. color: #FFFFFF;
  173. border-radius: 36rpx;
  174. font-size: 28rpx;
  175. }
  176. }
  177. }
  178. </style>