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

121 lines
2.8 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. methods: {
  38. inputFocus(scrollTop){
  39. time = setTimeout(() => {
  40. this.is_focus = true;
  41. }, 0); // 给blur事件留出时间
  42. setTimeout(() => {
  43. uni.pageScrollTo({
  44. scrollTop: scrollTop,
  45. duration: 100
  46. })
  47. }, 200);
  48. },
  49. inputBlur(){
  50. time = setTimeout(() => {
  51. this.is_focus = false;
  52. }, 0); // 给click事件留出时间
  53. },
  54. login(){
  55. if(!this.user_key){
  56. this.$msg('账号不能为空');
  57. }else if(!this.user_pw){
  58. this.$msg('密码不能为空');
  59. }else{
  60. this.$http(this.API.API_SUPPLIER_LOGIN, {
  61. username: this.user_key,
  62. password: this.user_pw
  63. }).then(res => {
  64. console.log("login", res);
  65. uni.setStorageSync('supply_token', res.data.token);
  66. this.$url('/pages/supply/index/index');
  67. })
  68. }
  69. }
  70. }
  71. }
  72. </script>
  73. <style lang="scss" scoped="scoped">
  74. .lf-m-t-60{
  75. margin-top: 60rpx;
  76. }
  77. .head{
  78. height: 604rpx;
  79. width: 750rpx;
  80. background-color: #1833F2;
  81. }
  82. .content{
  83. width: 686rpx;
  84. height: 622rpx;
  85. background: #FFFFFF;
  86. box-shadow: 0rpx 2rpx 10rpx 5rpx rgba(24, 51, 242, 0.1);
  87. border-radius: 20rpx;
  88. margin: 0 auto;
  89. margin-top: -100rpx;
  90. padding: 60rpx 30rpx;
  91. box-sizing: border-box;
  92. display: flex;
  93. flex-direction: column;
  94. justify-content: space-between;
  95. .input{
  96. // padding: 20rpx 0;
  97. border-bottom: 1rpx solid #e5e5e5;
  98. font-size: 60rpx;
  99. /* #ifdef MP */
  100. height: 90rpx;
  101. line-height: 90rpx;
  102. /* #endif */
  103. }
  104. .button{
  105. background-color: #1833F2;
  106. color: #FFFFFF;
  107. font-size: 32rpx;
  108. }
  109. }
  110. /deep/.input-placeholder{
  111. color: #999999;
  112. font-size: 28rpx;
  113. }
  114. /deep/.button-hover{
  115. opacity: .5;
  116. animation: all .3s;
  117. }
  118. </style>