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

168 lines
3.7 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" :class="{'lf-btn-disabled': button_click}" @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. button_click: false
  57. }
  58. },
  59. onLoad(options){
  60. // todo 优化:input输入后有clear按钮
  61. },
  62. methods: {
  63. inputFocus(scrollTop){
  64. time = setTimeout(() => {
  65. this.is_focus = true;
  66. }, 0); // 给blur事件留出时间
  67. setTimeout(() => {
  68. uni.pageScrollTo({
  69. scrollTop: scrollTop,
  70. duration: 100
  71. })
  72. }, 200);
  73. },
  74. inputBlur(){
  75. time = setTimeout(() => {
  76. this.is_focus = false;
  77. }, 0); // 给click事件留出时间
  78. },
  79. login(){
  80. if(this.button_click) return;
  81. if(!this.user_key){
  82. this.$msg('账号不能为空');
  83. }else if(!this.user_pw){
  84. this.$msg('密码不能为空');
  85. }else{
  86. this.button_click = true;
  87. this.$http(this.API.API_CANTEEN_LOGIN, {
  88. username: this.user_key,
  89. password: this.user_pw
  90. }).then(res => {
  91. console.log("login", res);
  92. uni.setStorageSync('canteen_token', res.data.token);
  93. this.button_click = false;
  94. this.$url('/pages/index/index', {tyep: 'redirect'});
  95. }).catch(err => this.button_click = false);
  96. }
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss" scoped="scoped">
  102. .lf-m-t-60{
  103. margin-top: 60rpx;
  104. }
  105. .head{
  106. height: 750rpx;
  107. width: 750rpx;
  108. background-color: #11D189;
  109. position: relative;
  110. image{
  111. width: 626.5rpx;
  112. height: 582rpx;
  113. position: absolute;
  114. top: calc(50% - 240rpx);
  115. left: calc(50% - 313rpx);
  116. z-index: 0;
  117. }
  118. .nav{
  119. text-align: center;
  120. padding-top: 70rpx;
  121. padding-bottom: 34rpx;
  122. color: #FFFFFF;
  123. font-size: 32rpx;
  124. font-weight: bold;
  125. }
  126. }
  127. .content{
  128. width: 686rpx;
  129. height: 622rpx;
  130. background: #FFFFFF;
  131. box-shadow: 0rpx 2rpx 10rpx 5rpx rgba(17, 209, 137, 0.1);
  132. border-radius: 20rpx;
  133. margin: 0 auto;
  134. margin-top: -100rpx;
  135. padding: 60rpx 30rpx;
  136. box-sizing: border-box;
  137. display: flex;
  138. flex-direction: column;
  139. justify-content: space-between;
  140. position: relative;
  141. z-index: 2;
  142. .input{
  143. // padding: 20rpx 0;
  144. border-bottom: 1rpx solid #e5e5e5;
  145. font-size: 48rpx;
  146. /* #ifdef MP */
  147. height: 90rpx;
  148. line-height: 90rpx;
  149. /* #endif */
  150. }
  151. .button{
  152. background-color: #11D189;
  153. color: #FFFFFF;
  154. font-size: 32rpx;
  155. }
  156. }
  157. /deep/.input-placeholder{
  158. color: #999999;
  159. font-size: 28rpx;
  160. }
  161. /deep/.button-hover{
  162. opacity: .5;
  163. animation: all .3s;
  164. }
  165. </style>