login.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <!-- 蓝色登录页面2 -->
  2. <template>
  3. <view>
  4. <view class="img-a">
  5. <view class="t-b">
  6. 您好,
  7. <br />
  8. 欢迎使用WMS
  9. </view>
  10. </view>
  11. <view class="login-view" style="">
  12. <view class="t-login">
  13. <form class="cl">
  14. <view class="t-a">
  15. <text class="txt">用户名</text>
  16. <input type="text" name="username" placeholder="请输入您的用户名" v-model="username" />
  17. </view>
  18. <view class="t-a">
  19. <text class="txt">密码</text>
  20. <input type="password" name="password" maxlength="18" placeholder="请输入您的密码" v-model="pwd" />
  21. </view>
  22. <button @tap="login()">登 录</button>
  23. <!-- <view class="reg" @tap="reg()">注 册</view> -->
  24. </form>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. var reqRootUrl = plus.storage.getItem("reqRootUrl");
  31. export default {
  32. data() {
  33. return {
  34. username: 'sysadmin', //用户名
  35. pwd: 'abcd1234' //密码
  36. };
  37. },
  38. onLoad() {},
  39. methods: {
  40. //当前登录按钮操作
  41. login() {
  42. var that = this;
  43. if (!that.username) {
  44. uni.showToast({
  45. title: '请输入您的用户名',
  46. icon: 'none'
  47. });
  48. return;
  49. }
  50. if (!that.pwd) {
  51. uni.showToast({
  52. title: '请输入您的密码',
  53. icon: 'none'
  54. });
  55. return;
  56. }
  57. uni.request({
  58. url: reqRootUrl + '/login',
  59. data: {
  60. rememberMe: true,
  61. },
  62. type: 'POST',
  63. timeout: 30000, //超时时间设置为30秒;
  64. beforeSend: function(xhr) {
  65. xhr.setRequestHeader('Authorization', 'Basic ' + btoa(usernameBox.value +
  66. ':' + codeBox.value));
  67. },
  68. complete: function() {
  69. plus.nativeUI.closeWaiting(); //关于加载提示
  70. },
  71. success: (ret) => {
  72. uni.showToast({
  73. title: '登录成功!',
  74. icon: 'none'
  75. });
  76. setTimeout(() => {
  77. uni.redirectTo({
  78. url: '/pages/sample/main',
  79. })
  80. }, 500);
  81. },
  82. fail: (err) => {
  83. // console.log('request fail', err);
  84. },
  85. complete: () => {
  86. // console.log('complete');
  87. }
  88. })
  89. },
  90. //注册按钮点击
  91. // reg() {
  92. // uni.showToast({ title: '注册跳转', icon: 'none' });
  93. // },
  94. }
  95. };
  96. </script>
  97. <style>
  98. .txt {
  99. font-size: 32rpx;
  100. font-weight: bold;
  101. color: #333333;
  102. }
  103. .img-a {
  104. width: 100%;
  105. height: 450rpx;
  106. background-image: url(../../../static/head.png);
  107. background-size: 100%;
  108. }
  109. .reg {
  110. font-size: 28rpx;
  111. color: #fff;
  112. height: 90rpx;
  113. line-height: 90rpx;
  114. border-radius: 50rpx;
  115. font-weight: bold;
  116. background: #f5f6fa;
  117. color: #000000;
  118. text-align: center;
  119. margin-top: 30rpx;
  120. }
  121. .login-view {
  122. width: 100%;
  123. position: relative;
  124. margin-top: -120rpx;
  125. background-color: #ffffff;
  126. border-radius: 8% 8% 0% 0;
  127. }
  128. .t-login {
  129. width: 600rpx;
  130. margin: 0 auto;
  131. font-size: 28rpx;
  132. padding-top: 80rpx;
  133. }
  134. .t-login button {
  135. font-size: 28rpx;
  136. background: #2796f2;
  137. color: #fff;
  138. height: 90rpx;
  139. line-height: 90rpx;
  140. border-radius: 50rpx;
  141. font-weight: bold;
  142. }
  143. .t-login input {
  144. height: 90rpx;
  145. line-height: 90rpx;
  146. margin-bottom: 50rpx;
  147. border-bottom: 1px solid #e9e9e9;
  148. font-size: 28rpx;
  149. }
  150. .t-login .t-a {
  151. position: relative;
  152. }
  153. .t-b {
  154. text-align: left;
  155. font-size: 42rpx;
  156. color: #ffffff;
  157. padding: 130rpx 0 0 70rpx;
  158. font-weight: bold;
  159. line-height: 70rpx;
  160. }
  161. .t-login .t-c {
  162. position: absolute;
  163. right: 22rpx;
  164. top: 22rpx;
  165. background: #5677fc;
  166. color: #fff;
  167. font-size: 24rpx;
  168. border-radius: 50rpx;
  169. height: 50rpx;
  170. line-height: 50rpx;
  171. padding: 0 25rpx;
  172. }
  173. .t-login .t-d {
  174. text-align: center;
  175. color: #999;
  176. margin: 80rpx 0;
  177. }
  178. .t-login .t-e {
  179. text-align: center;
  180. width: 250rpx;
  181. margin: 80rpx auto 0;
  182. }
  183. .t-login .t-g {
  184. float: left;
  185. width: 50%;
  186. }
  187. .t-login .t-e image {
  188. width: 50rpx;
  189. height: 50rpx;
  190. }
  191. .t-login .t-f {
  192. text-align: center;
  193. margin: 150rpx 0 0 0;
  194. color: #666;
  195. }
  196. .t-login .t-f text {
  197. margin-left: 20rpx;
  198. color: #aaaaaa;
  199. font-size: 27rpx;
  200. }
  201. .t-login .uni-input-placeholder {
  202. color: #aeaeae;
  203. }
  204. .cl {
  205. zoom: 1;
  206. }
  207. .cl:after {
  208. clear: both;
  209. display: block;
  210. visibility: hidden;
  211. height: 0;
  212. content: '\20';
  213. }
  214. </style>