index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class="content">
  3. <view class="head">
  4. <text>登录</text>
  5. </view>
  6. <view class="login-wrap">
  7. <view class="username item">
  8. <!-- <text>账号:</text> -->
  9. <image class="icon" src="/static/login/phone.png" mode="widthFix"></image>
  10. <uni-easyinput :inputBorder="false" class="login_input" type="text" v-model="username" placeholder="请输入账号" />
  11. </view>
  12. <view class="password item">
  13. <image class="icon" src="/static/login/pwd.png" mode="widthFix"></image>
  14. <!-- <text>密码:</text> -->
  15. <uni-easyinput :inputBorder="false" class="login_input" type="password" v-model="password" placeholder="请输入密码">
  16. </uni-easyinput>
  17. </view>
  18. <view class="tip">
  19. <label>
  20. <checkbox style="transform:scale(0.7)" class="check" value="cb" checked="true" />
  21. <text>我已阅读并同意《数字管家用户协议》和《数字管家隐私政策》,且已明确知晓平台仅限企业内部用户使用。 </text>
  22. </label>
  23. </view>
  24. <button type="primary" @click="loginSubmit" class="submit-BT">登录</button>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import store from '@/store/index.js'
  30. import { login } from '@/api/system/user.js';
  31. import { setToken } from '@/libs/auth.js';
  32. export default {
  33. data() {
  34. return {
  35. username: "",
  36. password: "",
  37. }
  38. },
  39. onLoad({username,password}) {
  40. if(username){
  41. this.username=username;
  42. this.password=password;
  43. }
  44. },
  45. methods: {
  46. loginSubmit() {
  47. let username = (this.username).trim();
  48. let password = (this.password).trim();
  49. if (username.length < 1) {
  50. uni.showToast({
  51. title: '请填写账号',
  52. icon: "error"
  53. })
  54. return;
  55. }
  56. if (password.length < 1) {
  57. uni.showToast({
  58. title: '请填写密码',
  59. icon: "error"
  60. })
  61. return;
  62. }
  63. login({
  64. username,
  65. password
  66. }).then((res) => {
  67. let token = res.data.accessToken;
  68. setToken(token);
  69. uni.setStorageSync('accountInfo', res.data.user);
  70. store.commit('setToken', token);
  71. uni.reLaunch({
  72. url: '/pages/index/index'
  73. })
  74. }).catch((res)=>{
  75. uni.showToast({
  76. icon:'none',
  77. title:res.msg||"登录失败!"
  78. })
  79. })
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .content {
  86. height: 100vh;
  87. background-color: #F5F6F8;
  88. .head {
  89. font-size: 50upx;
  90. text-align: center;
  91. padding: 40upx 0;
  92. letter-spacing: 2upx;
  93. }
  94. .login-wrap {
  95. width: 90%;
  96. margin: 50upx auto 0;
  97. box-sizing: border-box;
  98. padding: 20upx;
  99. border-radius: 8upx;
  100. .item {
  101. display: flex;
  102. justify-content: flex-start;
  103. align-items: center;
  104. height: 100upx;
  105. font-size: 32upx;
  106. line-height: 100upx;
  107. background-color: #fff;
  108. border-radius: 60rpx;
  109. margin-top: 40rpx;
  110. padding-left: 30rpx;
  111. box-sizing: border-box;
  112. .icon{
  113. width: 48rpx;
  114. }
  115. input {
  116. font-size: 32upx;
  117. height: 100upx;
  118. border: 0;
  119. }
  120. .login_input {
  121. width: 580upx;
  122. border: none;
  123. }
  124. }
  125. .tip {
  126. padding: 48rpx 0 0 56rpx;
  127. font-size: 28upx;
  128. color: #323233;
  129. position: relative;
  130. .check{
  131. position: absolute;
  132. left: 8rpx;
  133. top: 44rpx;
  134. }
  135. }
  136. .submit-BT {
  137. height: 88rpx;
  138. line-height: 88rpx;
  139. border-radius: 50rpx;
  140. margin-top: 50upx;
  141. background-color:#2A5BEE;
  142. padding: 0;
  143. }
  144. }
  145. }
  146. </style>