login.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="page">
  3. <view class="logo">
  4. <image
  5. src="~@/static/logo.png"
  6. mode="aspectFit"
  7. class="img"
  8. ></image>
  9. </view>
  10. <view class="form">
  11. <input
  12. class="input"
  13. v-model="username"
  14. placeholder="请输入用户名"
  15. @blur="queryDep"
  16. />
  17. <ld-select
  18. :list="depList"
  19. placeholder="请选择部门"
  20. class="input select"
  21. v-model="depId"
  22. @change="selectDep"
  23. />
  24. <input
  25. class="input"
  26. :password="true"
  27. v-model="password"
  28. placeholder="请输入密码"
  29. />
  30. <button class="btn" @tap="calllogin">立即登录</button>
  31. <view class="label" @tap="forget">忘记密码?</view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import { queryDep, LoginFunc } from "@/services/login";
  37. export default {
  38. data() {
  39. return {
  40. loading: false,
  41. username: "",
  42. password: "",
  43. depId: "",
  44. count: 0,
  45. count2: 0,
  46. depList: [],
  47. };
  48. },
  49. methods: {
  50. async calllogin() {
  51. this.loading = true;
  52. if (this.username == "") {
  53. uni.showToast({
  54. icon: "none",
  55. title: "请输入手机号或邮箱",
  56. });
  57. this.loading = false;
  58. return;
  59. }
  60. if (!this.depId) {
  61. uni.showToast({
  62. icon: "none",
  63. title: "请选择部门",
  64. });
  65. this.loading = false;
  66. return;
  67. }
  68. if (this.password == "") {
  69. uni.showToast({
  70. icon: "none",
  71. title: "请输入密码",
  72. });
  73. this.loading = false;
  74. return;
  75. }
  76. const { data } = await LoginFunc({
  77. UserName: this.username,
  78. Password: this.password,
  79. DepId: this.depId,
  80. });
  81. uni.setStorageSync("token", data.token);
  82. uni.setStorageSync("user", data.user);
  83. uni.reLaunch({
  84. url: "../index/index",
  85. });
  86. },
  87. // toogle() {
  88. // this.count++;
  89. // if (this.count == 8) {
  90. // const env = uni.getStorageSync("ENV");
  91. // if (env == "dev") {
  92. // uni.setStorageSync("ENV", "deploy");
  93. // uni.showToast({
  94. // icon: "none",
  95. // title: "已切换成正式环境",
  96. // });
  97. // } else {
  98. // uni.setStorageSync("ENV", "dev");
  99. // uni.showToast({
  100. // icon: "none",
  101. // title: "已切换成测试环境",
  102. // });
  103. // }
  104. // setTimeout(() => {
  105. // location.reload();
  106. // }, 1500);
  107. // }
  108. // },
  109. forget() {
  110. this.count2++;
  111. if (this.count2 >= 5) {
  112. uni.showToast({
  113. icon: "none",
  114. title: `当前环境为${uni.getStorageSync("ENV")}`,
  115. });
  116. } else {
  117. uni.showToast({
  118. duration: 1500,
  119. icon: "none",
  120. title: "请联系系统管理员",
  121. });
  122. }
  123. },
  124. selectDep(value) {
  125. this.depId = value + "";
  126. },
  127. async queryDep() {
  128. const res = await queryDep({
  129. userName: this.username,
  130. });
  131. this.depList = res.data.map((item) => ({
  132. label: item.Name,
  133. value: item.ID,
  134. }));
  135. this.depId = this.depList[0].value + "";
  136. },
  137. },
  138. };
  139. </script>
  140. <style lang="scss" scoped>
  141. .page {
  142. display: flex;
  143. flex-direction: column;
  144. justify-content: space-evenly;
  145. position: relative;
  146. // padding-bottom: 50px;
  147. min-height: 100vh;
  148. display: flex;
  149. flex-direction: column;
  150. background: url("~@/static/bg.png") no-repeat center;
  151. background-size: 100% 100%;
  152. }
  153. .logo {
  154. height: 220rpx;
  155. display: flex;
  156. justify-content: center;
  157. align-items: center;
  158. background: #fff;
  159. .img {
  160. height: 138rpx;
  161. }
  162. }
  163. .form {
  164. width: 530rpx;
  165. margin: 0 auto;
  166. flex-direction: column;
  167. display: flex;
  168. padding: 74rpx 56rpx;
  169. border: 1px solid #fff;
  170. .input {
  171. width: 100%;
  172. margin-bottom: 25rpx;
  173. background: #fff;
  174. height: 70rpx;
  175. color: #777777;
  176. padding-left: 20rpx;
  177. font-size: 24rpx;
  178. border-radius: 0px;
  179. }
  180. .select {
  181. padding: 0;
  182. }
  183. .btn {
  184. background: #5b78bf;
  185. font-size: 30rpx;
  186. color: #ffffff;
  187. width: 100%;
  188. height: 72rpx;
  189. margin-top: 100rpx;
  190. }
  191. .label {
  192. font-size: 26rpx;
  193. margin-top: 50rpx;
  194. text-align: center;
  195. color: #ffffff;
  196. }
  197. }
  198. </style>