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.

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