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

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