login.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <view class="zai-box">
  3. <scroll-view scroll-y class="page">
  4. <view style="text-align: center;" :style="[{animation: 'show ' + 0.4+ 's 1'}]">
  5. <image src="/static/login3.png" mode='aspectFit' class="zai-logo"></image>
  6. <view class="zai-title">JEECG BOOT</view>
  7. </view>
  8. <view class="box padding-lr-xl login-paddingtop" :style="[{animation: 'show ' + 0.6+ 's 1'}]">
  9. <view class="cu-form-group margin-top round shadow-blur">
  10. <view class="title">账号:</view>
  11. <input placeholder="请输入账号" name="input" v-model="userName"></input>
  12. </view>
  13. <view class="cu-form-group margin-top round">
  14. <view class="title">密码:</view>
  15. <input placeholder="请输入密码" name="input" type="password" v-model="password"></input>
  16. </view>
  17. <view class="padding flex flex-direction">
  18. <button class="cu-btn bg-green shadow-blur round lg" :loading="loading"
  19. @tap="onLogin"> {{loading ? "登录中...":"登 录"}}
  20. </button>
  21. </view>
  22. <!-- #ifdef APP-PLUS -->
  23. <view class="padding flex flex-direction text-center ">
  24. 当前版本:{{version}}
  25. </view>
  26. <!-- #endif -->
  27. </view>
  28. </scroll-view>
  29. <!-- 登录加载弹窗 -->
  30. <view class="cu-load load-modal" v-if="loading">
  31. <!-- <view class="cuIcon-emojifill text-orange"></view> -->
  32. <image src="/static/login3.png" mode="aspectFit"></image>
  33. <view class="gray-text">登录中...</view>
  34. </view>
  35. <!-- <my-image-upload></my-image-upload>
  36. <my-select></my-select> -->
  37. <!-- <my-page></my-page> -->
  38. </view>
  39. </template>
  40. <script>
  41. import { ACCESS_TOKEN,USER_NAME,USER_INFO } from "@/common/util/constants"
  42. import { mapActions } from "vuex"
  43. import myImageUpload from "@/components/my-componets/my-image-upload.vue"
  44. import mypage from "@/components/my-componets/my-page.vue"
  45. import myselect from "@/components/my-componets/my-select.vue"
  46. export default {
  47. components:{
  48. 'my-image-upload':myImageUpload,
  49. 'my-select':myselect
  50. },
  51. data() {
  52. return {
  53. loading: false,
  54. userName: '',
  55. password: '',
  56. phoneNo: '',
  57. smsCode: '',
  58. showPassword: false, //是否显示明文
  59. loginWay: 1, //1: 账密,2:验证码
  60. smsCountDown: 0,
  61. smsCountInterval: null,
  62. toggleDelay: false,
  63. version:''
  64. };
  65. },
  66. onLoad:function(){
  67. // #ifdef APP-PLUS
  68. var that=this
  69. plus.runtime.getProperty( plus.runtime.appid, function ( wgtinfo ) {
  70. that.version=wgtinfo.version
  71. } );
  72. // #endif
  73. },
  74. methods: {
  75. ...mapActions([ "mLogin","PhoneLogin" ]),
  76. onLogin: function (){
  77. if(!this.userName || this.userName.length==0){
  78. this.$tip.toast('请填写用户名');
  79. return;
  80. }
  81. if(!this.password || this.password.length==0){
  82. this.$tip.toast('请填写密码');
  83. return;
  84. }
  85. let loginParams = {
  86. username:this.userName,
  87. password:this.password
  88. }
  89. this.loading=true;
  90. this.mLogin(loginParams).then((res) => {
  91. console.log("mLogin",res)
  92. this.loading=false;
  93. if(res.data.success){
  94. this.$tip.success('登录成功!')
  95. this.$Router.replaceAll({name:'index'})
  96. /* uni.reLaunch({
  97. url: '/pages/index/index'
  98. }); */
  99. }else{
  100. this.$tip.alert(res.data.message);
  101. }
  102. }).catch((err) => {
  103. let msg = err.data.message || "请求出现错误,请稍后再试"
  104. this.$tip.alert(msg);
  105. }).finally(()=>{
  106. this.loading=false;
  107. })
  108. }
  109. }
  110. }
  111. </script>
  112. <style>
  113. .login-paddingtop {
  114. padding-top: 200 upx;
  115. }
  116. .zai-box {
  117. padding: 0 20 upx;
  118. padding-top: 100 upx;
  119. position: relative;
  120. }
  121. .zai-logo {
  122. width: 200upx;
  123. height: 300 upx;
  124. }
  125. .zai-title {
  126. font-size: 58upx;
  127. color: #000000;
  128. text-align: center;
  129. }
  130. .input-placeholder, .zai-input {
  131. color: #94afce;
  132. }
  133. .zai-label {
  134. padding: 60 upx 0;
  135. text-align: center;
  136. font-size: 30 upx;
  137. color: #a7b6d0;
  138. }
  139. .zai-btn {
  140. background: #ff65a3;
  141. color: #fff;
  142. border: 0;
  143. border-radius: 100 upx;
  144. font-size: 36 upx;
  145. }
  146. .zai-btn:after {
  147. border: 0;
  148. }
  149. /*按钮点击效果*/
  150. .zai-btn.button-hover {
  151. transform: translate(1 upx, 1 upx);
  152. }
  153. </style>