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.

191 lines
5.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="bg">
  3. <div class="box">
  4. <div class="mainbody">
  5. <div class="title">系统登录</div>
  6. <div class="userform">
  7. <el-form
  8. :model="form"
  9. :rules="rules"
  10. ref="form"
  11. class="demo-ruleForm"
  12. >
  13. <el-form-item label="" prop="Username">
  14. <el-input
  15. v-model="form.Username"
  16. placeholder="用户名"
  17. prefix-icon="el-icon-s-custom"
  18. ></el-input>
  19. </el-form-item>
  20. <el-form-item label="" prop="Password">
  21. <el-input
  22. v-model="form.Password"
  23. placeholder="密码"
  24. type="password"
  25. prefix-icon="el-icon-unlock"
  26. ></el-input>
  27. </el-form-item>
  28. <el-button type="primary" class="btn" @click="onSubmit(form)"
  29. >用户登录</el-button
  30. >
  31. </el-form>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. import { lognis } from "@/request/ruquset";
  39. import { yzstr } from "@/utlis/validate.js";
  40. import { yztoken, writetoken } from "@/utlis/istoken";
  41. import mm from "@/utlis/mm";
  42. export default {
  43. data() {
  44. return {
  45. form: {
  46. Username: "",
  47. Password: "",
  48. },
  49. rules: {
  50. Username: [
  51. { required: true, message: "请输入用户名", trigger: "blur" },
  52. { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
  53. ],
  54. Password: [
  55. { required: true, message: "请输入密码", trigger: "blur" },
  56. { min: 3, max: 8, message: "长度在 3 到 5 个字符", trigger: "blur" },
  57. ],
  58. },
  59. };
  60. },
  61. methods: {
  62. onSubmit() {
  63. this.$refs.form.validate((valid) => {
  64. if (valid) {
  65. // lognis({
  66. // client_id: "Peis_App",
  67. // grant_type: "password",
  68. // username: "admin",
  69. // password: "1q2w3E*",
  70. // scope: "Peis",
  71. // }).then(res=>{
  72. // console.log(res,'222')
  73. // })
  74. // lognis({
  75. // client_id: "Peis_App",
  76. // grant_type: "password",
  77. // username: "admin",
  78. // password: "1q2w3E*",
  79. // scope: "Peis",
  80. // }).then((res) => {
  81. // console.log(res);
  82. // }); "http://81.70.217.145:9529/connect/token",
  83. this.$axios
  84. .post(
  85. mm.apiurl + "/connect/token",
  86. {
  87. client_id: "Peis_App",
  88. grant_type: "password",
  89. username: this.form.Username, //admin
  90. password: this.form.Password, //1q2w3E
  91. scope: "Peis offline_access",
  92. },
  93. {
  94. headers: {
  95. "Content-Type": "application/x-www-form-urlencoded",
  96. },
  97. }
  98. )
  99. .then((res) => {
  100. console.log(res.data)
  101. writetoken(res.data.expires_in);
  102. window.localStorage.setItem("token", res.data.access_token);
  103. window.localStorage.setItem("refresh_token",res.data.refresh_token);
  104. // window.localStorage.setItem("expires_in", res.data.expires_in);
  105. window.localStorage.setItem("tokentype", res.data.token_type);
  106. window.localStorage.setItem("user", this.form.Username);
  107. this.$message.success("登录成功");
  108. this.$router.push({ path: "home" });
  109. });
  110. }
  111. });
  112. },
  113. tuichui() {
  114. let token = localStorage.getItem("token");
  115. let tokentype = localStorage.getItem("tokentype");
  116. this.$axios
  117. .get("http://192.168.1.108:44394/api/identity/users", {
  118. params: {
  119. SkipCount: 1,
  120. MaxResultCount: 1,
  121. },
  122. headers: {
  123. Authorization: `${tokentype} ${token}`,
  124. },
  125. })
  126. .then((res) => {
  127. console.log(res);
  128. });
  129. },
  130. users() {
  131. this.$axios.put(
  132. "http://192.168.1.108:44394/api/permission-management/permissions",
  133. {
  134. providerName: "R",
  135. providerKey: "sdsaf",
  136. }
  137. );
  138. },
  139. },
  140. created() {
  141. // let date = moment();
  142. // date.add(3600, 's');
  143. // console.log(parseInt(new Date(date).getTime() / 1000) + '')
  144. // // console.log(this.$moment);
  145. // console.log('33');
  146. // console.log(parseInt(new Date().getTime() / 1000) + '');
  147. },
  148. };
  149. </script>
  150. <style lang="scss" scoped>
  151. .bg {
  152. background-color: black;
  153. // background: url("https://img.zcool.cn/community/013c8b5b62d108a801206a35bea1eb.jpg@2o.jpg");1
  154. background: url("https://img1.baidu.com/it/u=1097534320,1746985227&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500");
  155. height: 100%;
  156. width: 100%;
  157. min-height: 100vh;
  158. }
  159. .box {
  160. width: 400px;
  161. height: 300px;
  162. display: flex;
  163. background: #fff;
  164. position: absolute;
  165. left: 50%;
  166. top: 50%;
  167. transform: translate(-50%, -50%);
  168. padding: 10px;
  169. }
  170. .mainbody {
  171. .title {
  172. width: 400px;
  173. text-align: center;
  174. font-weight: 700;
  175. font-size: 20px;
  176. }
  177. }
  178. .userform {
  179. margin-top: 20px;
  180. padding: 20px;
  181. }
  182. .btn {
  183. width: 100%;
  184. }
  185. </style>