自主产品,供应链食堂系统。将两个端拆开了。
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.

164 lines
3.5 KiB

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