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.

193 lines
5.3 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 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. // this.$store.dispatch('changepassword',this.form.Password)
  110. this.$store.state.changepassword=this.form.Password
  111. });
  112. }
  113. });
  114. },
  115. tuichui() {
  116. let token = localStorage.getItem("token");
  117. let tokentype = localStorage.getItem("tokentype");
  118. this.$axios
  119. .get("http://192.168.1.108:44394/api/identity/users", {
  120. params: {
  121. SkipCount: 1,
  122. MaxResultCount: 1,
  123. },
  124. headers: {
  125. Authorization: `${tokentype} ${token}`,
  126. },
  127. })
  128. .then((res) => {
  129. console.log(res);
  130. });
  131. },
  132. users() {
  133. this.$axios.put(
  134. "http://192.168.1.108:44394/api/permission-management/permissions",
  135. {
  136. providerName: "R",
  137. providerKey: "sdsaf",
  138. }
  139. );
  140. },
  141. },
  142. created() {
  143. // let date = moment();
  144. // date.add(3600, 's');
  145. // console.log(parseInt(new Date(date).getTime() / 1000) + '')
  146. // // console.log(this.$moment);
  147. // console.log('33');
  148. // console.log(parseInt(new Date().getTime() / 1000) + '');
  149. },
  150. };
  151. </script>
  152. <style lang="scss" scoped>
  153. .bg {
  154. background-color: black;
  155. // background: url("https://img.zcool.cn/community/013c8b5b62d108a801206a35bea1eb.jpg@2o.jpg");1
  156. background: url("https://img1.baidu.com/it/u=1097534320,1746985227&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500");
  157. height: 100%;
  158. width: 100%;
  159. min-height: 100vh;
  160. }
  161. .box {
  162. width: 400px;
  163. height: 300px;
  164. display: flex;
  165. background: #fff;
  166. position: absolute;
  167. left: 50%;
  168. top: 50%;
  169. transform: translate(-50%, -50%);
  170. padding: 10px;
  171. }
  172. .mainbody {
  173. .title {
  174. width: 400px;
  175. text-align: center;
  176. font-weight: 700;
  177. font-size: 20px;
  178. }
  179. }
  180. .userform {
  181. margin-top: 20px;
  182. padding: 20px;
  183. }
  184. .btn {
  185. width: 100%;
  186. }
  187. </style>