自主项目,食堂系统,前端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.

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