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.

309 lines
11 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
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 :model="form" :rules="rules" ref="form" class="demo-ruleForm">
  8. <el-form-item label="" prop="Username">
  9. <el-input v-model="form.Username" placeholder="用户名" prefix-icon="el-icon-s-custom"></el-input>
  10. </el-form-item>
  11. <el-form-item label="" prop="Password">
  12. <el-input v-model="form.Password" placeholder="密码" type="password" prefix-icon="el-icon-unlock"></el-input>
  13. </el-form-item>
  14. <el-button type="primary" class="btn" @click="onSubmit(form)">用户登录</el-button>
  15. </el-form>
  16. </div>
  17. </div>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. import { lognis } from "@/request/ruquset";
  23. import { yzstr } from "@/utlis/validate.js";
  24. import { yztoken, writetoken } from "@/utlis/istoken";
  25. import mm from "@/utlis/mm";
  26. import { getapi, postapi } from "@/api/api";
  27. export default {
  28. data() {
  29. return {
  30. form: {
  31. Username: "",
  32. Password: "",
  33. },
  34. rules: {
  35. Username: [
  36. { required: true, message: "请输入用户名", trigger: "blur" },
  37. { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
  38. ],
  39. Password: [
  40. { required: true, message: "请输入密码", trigger: "blur" },
  41. { min: 3, max: 8, message: "长度在 3 到 5 个字符", trigger: "blur" },
  42. ],
  43. },
  44. };
  45. },
  46. methods: {
  47. onSubmit() {
  48. this.$refs.form.validate((valid) => {
  49. if (valid) {
  50. // let res = await getapi("/api/identity/users/login", {
  51. // username: this.form.Username,
  52. // password: this.form.Password,11
  53. // });
  54. var msgs = "";
  55. postapi(`/api/identity/users/login`, {
  56. userName: this.form.Username,
  57. passWord: this.form.Password,
  58. })
  59. .then((res) => {
  60. msgs = res.data.msg;
  61. if (res.code == 1) {
  62. window.sessionStorage.setItem("peisid", res.data.peisid); //设置当前人员所属体检中心
  63. writetoken(res.data.expires_in);
  64. window.localStorage.setItem("token", res.data.access_token);
  65. window.localStorage.setItem(
  66. "refresh_token",
  67. res.data.refresh_token
  68. );
  69. window.localStorage.setItem("tokentype", res.data.token_type);
  70. window.localStorage.setItem("user", this.form.Username);
  71. this.$router.push({ path: "home" });
  72. this.$store.state.changepassword = this.form.Password;
  73. }
  74. this.$message.success(msgs);
  75. console.log(res, 'res');
  76. // if (res.code != -1 && res.data.code == 1) {
  77. // window.sessionStorage.setItem("peisid", res.data.peisid); //设置当前人员所属体检中心
  78. // return this.$axios.post(
  79. // mm.apiurl + "/connect/token",
  80. // {
  81. // client_id: "Peis_App",
  82. // grant_type: "password",
  83. // username: this.form.Username,
  84. // password: this.form.Password,
  85. // scope: "Peis offline_access",
  86. // },
  87. // {
  88. // headers: {
  89. // "Content-Type": "application/x-www-form-urlencoded",
  90. // },
  91. // }
  92. // );
  93. // } else {
  94. // this.$message.warning(ret.data.msg);
  95. // }
  96. })
  97. // .then((res) => {
  98. // writetoken(res.data.expires_in);
  99. // window.localStorage.setItem("token", res.data.access_token);
  100. // window.localStorage.setItem(
  101. // "refresh_token",
  102. // res.data.refresh_token
  103. // );
  104. // window.localStorage.setItem("tokentype", res.data.token_type);
  105. // window.localStorage.setItem("user", this.form.Username);
  106. // this.$router.push({ path: "home" });
  107. // this.$store.state.changepassword = this.form.Password;
  108. // })
  109. .catch((err) => { });
  110. // console.log(res);
  111. // if (res.data.code == 1 && res.code == 1) {
  112. // console.log(res.data.msg);
  113. // postapi()
  114. // let ress = await this.$axios.post(
  115. // mm.apiurl + "/connect/token",
  116. // {
  117. // client_id: "Peis_App",
  118. // grant_type: "password",
  119. // username: this.form.Username,
  120. // password: this.form.Password,
  121. // scope: "Peis offline_access",
  122. // },
  123. // {
  124. // headers: {
  125. // "Content-Type": "application/x-www-form-urlencoded",
  126. // },
  127. // }
  128. // );
  129. // if (ress.status == 200) {
  130. // writetoken(ress.data.expires_in);
  131. // window.localStorage.setItem("token", ress.data.access_token);
  132. // window.localStorage.setItem(
  133. // "refresh_token",
  134. // ress.data.refresh_token
  135. // );
  136. // window.localStorage.setItem("tokentype", ress.data.token_type);
  137. // window.localStorage.setItem("user", this.form.Username);
  138. // this.$message.success(res.data.msg, "登录成功");
  139. // this.$router.push({ path: "home" });
  140. // }
  141. // } else {
  142. // console.log();
  143. // this.$message.warning(res.data.msg);
  144. // }
  145. // } catch (err) {
  146. // console.log(err);
  147. // }
  148. // await getapi("/api/identity/users/login", {
  149. // username: this.form.Username,
  150. // password: this.form.Password,
  151. // }).then((ress) => {
  152. // if (ress.data.code == 1 && ress.code == 1) {
  153. // // console.log(msg);
  154. // postapi(mm.apiurl + "/connect/token", {
  155. // client_id: "Peis_App",
  156. // grant_type: "password",
  157. // username: this.form.Username,
  158. // password: this.form.Password,
  159. // scope: "Peis offline_access",
  160. // }).then((res) => {
  161. // console.log(res);
  162. // writetoken(res.data.expires_in);
  163. // window.localStorage.setItem("token", res.data.access_token);
  164. // window.localStorage.setItem(
  165. // "refresh_token",
  166. // res.data.refresh_token
  167. // );
  168. // window.localStorage.setItem("tokentype", res.data.token_type);
  169. // window.localStorage.setItem("user", this.form.Username);
  170. // this.$message.success("登录成功");
  171. // this.$router.push({ path: "home" });
  172. // this.$store.state.changepassword = this.form.Password;
  173. // });
  174. // } else {
  175. // this.$message.warning(res.data.msg);
  176. // }
  177. // });
  178. // this.$axios
  179. // .post(
  180. // mm.apiurl + "/connect/token",
  181. // {
  182. // client_id: "Peis_App",
  183. // grant_type: "password",
  184. // username: this.form.Username, //admin
  185. // password: this.form.Password, //1q2w3E
  186. // scope: "Peis offline_access",
  187. // },
  188. // {
  189. // headers: {
  190. // "Content-Type": "application/x-www-form-urlencoded",
  191. // },
  192. // }
  193. // )
  194. // .then((res) => {
  195. // console.log(res, "222222");
  196. // if (res.status == 200) {
  197. // //console.log(res.data)
  198. // writetoken(res.data.expires_in);
  199. // window.localStorage.setItem("token", res.data.access_token);
  200. // window.localStorage.setItem(
  201. // "refresh_token",
  202. // res.data.refresh_token
  203. // );
  204. // // window.localStorage.setItem("expires_in", res.data.expires_in);
  205. // window.localStorage.setItem("tokentype", res.data.token_type);
  206. // window.localStorage.setItem("user", this.form.Username);
  207. // this.$message.success("登录成功");
  208. // this.$router.push({ path: "home" });
  209. // // this.$store.dispatch('changepassword',this.form.Password)
  210. // this.$store.state.changepassword = this.form.Password;
  211. // } else {
  212. // this.$message.warning("用户名或密码错误");
  213. // }
  214. // });
  215. }
  216. });
  217. },
  218. tuichui() {
  219. let token = localStorage.getItem("token");
  220. let tokentype = localStorage.getItem("tokentype");
  221. this.$axios
  222. .get("http://192.168.1.108:44394/api/identity/users", {
  223. params: {
  224. SkipCount: 1,
  225. MaxResultCount: 1,
  226. },
  227. headers: {
  228. Authorization: `${tokentype} ${token}`,
  229. },
  230. })
  231. .then((res) => {
  232. console.log(res);
  233. });
  234. },
  235. users() {
  236. this.$axios.put(
  237. "http://192.168.1.108:44394/api/permission-management/permissions",
  238. {
  239. providerName: "R",
  240. providerKey: "sdsaf",
  241. }
  242. );
  243. },
  244. },
  245. created() {
  246. // let date = moment();
  247. // date.add(3600, 's');
  248. // console.log(parseInt(new Date(date).getTime() / 1000) + '')
  249. // // console.log(this.$moment);
  250. // console.log('33');
  251. // console.log(parseInt(new Date().getTime() / 1000) + '');
  252. },
  253. };
  254. </script>
  255. <style lang="scss" scoped>
  256. .bg {
  257. background-color: black;
  258. // background: url("https://img.zcool.cn/community/013c8b5b62d108a801206a35bea1eb.jpg@2o.jpg");1
  259. // background: url("https://img1.baidu.com/it/u=1097534320,1746985227&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500");
  260. background: url("@/assets/images/logn.png");
  261. height: 100%;
  262. width: 100%;
  263. min-height: 100vh;
  264. }
  265. .box {
  266. width: 400px;
  267. height: 300px;
  268. display: flex;
  269. // background: #fff;
  270. background: rgb(190, 243, 210);
  271. position: absolute;
  272. left: 50%;
  273. top: 50%;
  274. transform: translate(-50%, -50%);
  275. padding: 10px;
  276. }
  277. .mainbody {
  278. .title {
  279. width: 400px;
  280. text-align: center;
  281. font-weight: 700;
  282. font-size: 20px;
  283. }
  284. }
  285. .userform {
  286. margin-top: 20px;
  287. padding: 20px;
  288. }
  289. .btn {
  290. width: 100%;
  291. }
  292. </style>