login.vue 4.1 KB

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