自主项目,食堂系统,前端uniapp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
3.1 KiB

  1. <template>
  2. <view>
  3. <view class="head"></view>
  4. <view class="content">
  5. <view>
  6. <!-- 账号 -->
  7. <view class="lf-flex lf-m-b-10">
  8. <u-icon name="account-fill"></u-icon>
  9. <text class="lf-m-l-10 lf-font-28 lf-color-333">登录账号</text>
  10. </view>
  11. <input class="input"
  12. maxlength="11"
  13. v-model="user_key"
  14. :adjust-position="false"
  15. :auto-blur="true"
  16. placeholder="请输入账号"
  17. @focus="inputFocus(170)"
  18. @blur="inputBlur" />
  19. <!-- 密码 -->
  20. <view class="lf-flex lf-m-b-10 lf-m-t-60">
  21. <u-icon name="lock-fill"></u-icon>
  22. <text class="lf-m-l-10 lf-font-28 lf-color-333">登录密码</text>
  23. </view>
  24. <input class="input"
  25. maxlength="11"
  26. v-model="user_pw"
  27. :adjust-position="false"
  28. :auto-blur="true"
  29. placeholder="请输入密码"
  30. :password="true"
  31. @focus="inputFocus(220)"
  32. @blur="inputBlur"
  33. @confirm="login" />
  34. </view>
  35. <view>
  36. <!-- 登录按钮 -->
  37. <button class="button" @click="login">登录</button>
  38. </view>
  39. </view>
  40. <view :style="is_focus ? 'height: 540rpx' : 'height: 40rpx'"></view>
  41. </view>
  42. </template>
  43. <script>
  44. let time = null;
  45. export default {
  46. data(){
  47. return {
  48. is_focus: false,
  49. user_key: '',
  50. user_pw: ''
  51. }
  52. },
  53. onReady(){
  54. // #ifndef MP
  55. var a = document.getElementsByClassName('uni-page-head-hd')[0];
  56. a.style.display = 'none';
  57. // #endif
  58. },
  59. methods: {
  60. inputFocus(scrollTop){
  61. time = setTimeout(() => {
  62. this.is_focus = true;
  63. }, 0); // 给blur事件留出时间
  64. setTimeout(() => {
  65. uni.pageScrollTo({
  66. scrollTop: scrollTop,
  67. duration: 100
  68. })
  69. }, 200);
  70. },
  71. inputBlur(){
  72. time = setTimeout(() => {
  73. this.is_focus = false;
  74. }, 0); // 给click事件留出时间
  75. },
  76. login(){
  77. if(!this.user_key){
  78. this.$msg('账号不能为空');
  79. }else if(!this.user_pw){
  80. this.$msg('密码不能为空');
  81. }else{
  82. this.$http(this.API.API_SUPPLIER_LOGIN, {
  83. username: this.user_key,
  84. password: this.user_pw
  85. }).then(res => {
  86. console.log("login", res);
  87. uni.setStorageSync('supply_token', res.data.token);
  88. this.$url('/pages/supply/index/index', {tyep: 'redirect'});
  89. })
  90. }
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="scss" scoped="scoped">
  96. .lf-m-t-60{
  97. margin-top: 60rpx;
  98. }
  99. .head{
  100. height: 604rpx;
  101. width: 750rpx;
  102. background-color: #1833F2;
  103. }
  104. .content{
  105. width: 686rpx;
  106. height: 622rpx;
  107. background: #FFFFFF;
  108. box-shadow: 0rpx 2rpx 10rpx 5rpx rgba(24, 51, 242, 0.1);
  109. border-radius: 20rpx;
  110. margin: 0 auto;
  111. margin-top: -100rpx;
  112. padding: 60rpx 30rpx;
  113. box-sizing: border-box;
  114. display: flex;
  115. flex-direction: column;
  116. justify-content: space-between;
  117. .input{
  118. // padding: 20rpx 0;
  119. border-bottom: 1rpx solid #e5e5e5;
  120. font-size: 60rpx;
  121. /* #ifdef MP */
  122. height: 90rpx;
  123. line-height: 90rpx;
  124. /* #endif */
  125. }
  126. .button{
  127. background-color: #1833F2;
  128. color: #FFFFFF;
  129. font-size: 32rpx;
  130. }
  131. }
  132. /deep/.input-placeholder{
  133. color: #999999;
  134. font-size: 28rpx;
  135. }
  136. /deep/.button-hover{
  137. opacity: .5;
  138. animation: all .3s;
  139. }
  140. </style>