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