血透系统pad前端

login.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <div class="container">
  3. <div class="newLogin">
  4. <div class="login">
  5. <div class="logo">
  6. <img src="../../assets/login/newLogo.png" alt />
  7. </div>
  8. <div class="reg">
  9. <div class="form">
  10. <ul>
  11. <li>
  12. <span class="iconfont">&#xe78b;</span>
  13. <input placeholder="请输入手机号" type="tel" class="tel" v-model="form.mobile" />
  14. </li>
  15. <li>
  16. <span class="iconfont">&#xe6c0;</span>
  17. <input placeholder="请输入密码" type="password" class="tel" v-model="form.pwd" />
  18. </li>
  19. </ul>
  20. </div>
  21. <!-- <router-link to="/product"> -->
  22. <div class="remember">
  23. <el-checkbox v-model="checked">记住密码</el-checkbox>
  24. </div>
  25. <!-- <button
  26. class="loginBtn"
  27. @click="loginAction"
  28. :class="loginDisable ? 'disableLoginBtn' : ''"
  29. :disabled="loginDisable"
  30. >
  31. 登录
  32. </button>-->
  33. <button
  34. class="loginBtn"
  35. @click="submitForm"
  36. :class="loginDisable ? 'disableLoginBtn' : ''"
  37. :disabled="loginDisable"
  38. >登录</button>
  39. <!-- <router-link to="/forgetPassword"> -->
  40. <div class="newForget" style="display:none">忘记密码</div>
  41. <!-- </router-link> -->
  42. <!-- </router-link> -->
  43. <!-- <div class="forget">
  44. <a href="">免密码登录</a>
  45. <a href="">忘记密码?</a>
  46. </div>-->
  47. <div class="agree">
  48. <el-checkbox v-model="agreement">
  49. 我已阅读并同意
  50. <!-- <router-link to="/privacyPolicy"> -->
  51. <!-- </router-link> -->
  52. </el-checkbox>
  53. <!-- <router-link to="/privacyPolicy"> -->
  54. <span class="agreeText" @click="agree">《隐私服务协议》</span>
  55. <!-- </router-link> -->
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. </template>
  62. <script>
  63. import { loginByPwd } from "@/api/login";
  64. import { hex_md5 } from "@/utils/md5";
  65. import { getLoginInfoCache, cacheLoginInfo } from "@/utils/admin_info_cache";
  66. import { Toast } from "vant";
  67. export default {
  68. name: "Home",
  69. data() {
  70. return {
  71. form: {
  72. mobile: "",
  73. pwd: ""
  74. },
  75. checked: false,
  76. agreement: true
  77. };
  78. },
  79. computed: {
  80. loginDisable() {
  81. // return false
  82. return this.form.mobile.length == 0 || this.form.pwd.length == 0;
  83. }
  84. },
  85. created() {
  86. var loginInfo = getLoginInfoCache();
  87. this.form.mobile = loginInfo.mobile;
  88. this.form.pwd = loginInfo.password;
  89. },
  90. mounted() {
  91. this.getCookie();
  92. },
  93. methods: {
  94. loginAction: function() {
  95. loginByPwd(this.form.mobile, hex_md5(this.form.pwd)).then(rs => {
  96. var resp = rs.data;
  97. if (resp.state == 1) {
  98. cacheLoginInfo(this.form.mobile, this.form.pwd);
  99. console.log(resp);
  100. var user = resp.data.user;
  101. var org = resp.data.org;
  102. var subscibe = resp.data.subscibe;
  103. var config_list = resp.data.config_list;
  104. var template_info = resp.data.template_info;
  105. var filed_list = resp.data.filed_list;
  106. console.log(resp.data.filed_list);
  107. console.log(filed_list);
  108. this.$store.dispatch("InitUserInfo", {
  109. user: user,
  110. org: org,
  111. subscibe: subscibe,
  112. template_info: template_info,
  113. filed_list: filed_list
  114. });
  115. this.$store.dispatch("SetConfigList", config_list);
  116. // this.$router.push({path: "/product"})
  117. this.$router.push({ path: "/main" });
  118. } else {
  119. this.$toast({
  120. message: resp.msg
  121. });
  122. }
  123. });
  124. },
  125. to: function() {
  126. this.$router.push({ path: "/forgetPassword" });
  127. },
  128. submitForm() {
  129. const self = this;
  130. //判断复选框是否被勾选 勾选则调用配置cookie方法
  131. if (self.checked == true) {
  132. console.log("checked == true");
  133. //传入账号名,密码,和保存天数3个参数
  134. self.setCookie(self.form.mobile, self.form.pwd, 7);
  135. } else {
  136. console.log("清空Cookie");
  137. //清空Cookie
  138. self.clearCookie();
  139. }
  140. //与后端请求代码,本功能不需要与后台交互所以省略
  141. loginByPwd(this.form.mobile, hex_md5(this.form.pwd)).then(rs => {
  142. var resp = rs.data;
  143. if (resp.state == 1) {
  144. cacheLoginInfo(this.form.mobile, this.form.pwd);
  145. console.log(resp);
  146. var user = resp.data.user;
  147. var org = resp.data.org;
  148. var subscibe = resp.data.subscibe;
  149. var config_list = resp.data.config_list;
  150. var template_info = resp.data.template_info;
  151. var filed_list = resp.data.filed_list;
  152. console.log(resp.data.filed_list);
  153. console.log(filed_list);
  154. this.$store.dispatch("InitUserInfo", {
  155. user: user,
  156. org: org,
  157. subscibe: subscibe,
  158. template_info: template_info,
  159. filed_list: filed_list
  160. });
  161. this.$store.dispatch("SetConfigList", config_list);
  162. // this.$router.push({path: "/product"})
  163. this.$router.push({ path: "/main" });
  164. } else {
  165. this.$toast({
  166. message: resp.msg
  167. });
  168. }
  169. });
  170. console.log("登陆成功");
  171. },
  172. //设置cookie
  173. setCookie(c_name, c_pwd, exdays) {
  174. var exdate = new Date(); //获取时间
  175. exdate.setTime(exdate.getTime() + 24 * 60 * 60 * 1000 * exdays); //保存的天数
  176. //字符串拼接cookie
  177. window.document.cookie =
  178. "userName" + "=" + c_name + ";path=/;expires=" + exdate.toGMTString();
  179. window.document.cookie =
  180. "userPwd" + "=" + c_pwd + ";path=/;expires=" + exdate.toGMTString();
  181. },
  182. getCookie: function() {
  183. this.$nextTick(() => {
  184. if (this.form.pwd != "") {
  185. this.checked = true;
  186. }
  187. });
  188. if (document.cookie.length > 0) {
  189. var arr = document.cookie.split("; "); //这里显示的格式需要切割一下自己可输出看下
  190. for (var i = 0; i < arr.length; i++) {
  191. var arr2 = arr[i].split("="); //再次切割
  192. //判断查找相对应的值
  193. if (arr2[0] == "userName") {
  194. this.form.mobile = arr2[1]; //保存到保存数据的地方
  195. } else if (arr2[0] == "userPwd") {
  196. this.form.pwd = arr2[1];
  197. }
  198. }
  199. }
  200. },
  201. //清除cookie
  202. clearCookie: function() {
  203. this.setCookie("", "", -1); //修改2值都为空,天数为负1天就好了
  204. },
  205. agree() {
  206. this.$router.push({ path: "/privacyPolicy" });
  207. }
  208. }
  209. };
  210. </script>
  211. <style rel="stylesheet/scss" lang="scss" scoped>
  212. .container {
  213. // background: $white-bg;
  214. background: #fff;
  215. @include box-sizing;
  216. position: fixed;
  217. width: 100%;
  218. height: 100%;
  219. display: flex;
  220. justify-content: space-between;
  221. .newLogin {
  222. width: 100%;
  223. height: 100%;
  224. margin: auto;
  225. // box-shadow: 0px 2px 25px 0px rgba(37, 143, 252, 0.1);
  226. background: #fff;
  227. }
  228. .login {
  229. // @include box-shadow;
  230. @include text-align;
  231. @include display-flex;
  232. @include align-items-center;
  233. // @include justify-content-center;
  234. @include flex-direction;
  235. height: 100%;
  236. .logo {
  237. padding: 3rem 0 2.5rem;
  238. img {
  239. width: 44%;
  240. height: auto;
  241. display: inline-block;
  242. }
  243. }
  244. .reg {
  245. width: 9.3rem;
  246. .welcome {
  247. text-align: left;
  248. font-size: 0.55rem;
  249. font-weight: 400;
  250. color: rgba(37, 143, 252, 1);
  251. margin-bottom: 0.5rem;
  252. // line-height: 14px;
  253. }
  254. .newForget {
  255. text-align: right;
  256. font-size: 0.45rem;
  257. font-weight: 400;
  258. color: rgba(37, 143, 252, 1);
  259. margin-top: 0.3rem;
  260. }
  261. .form {
  262. border: 1px $border-color solid;
  263. border-radius: 4px;
  264. li {
  265. border-bottom: 1px $border-color solid;
  266. @include align-items-center;
  267. @include text-align;
  268. @include display-flex;
  269. @include box-sizing;
  270. .tel {
  271. padding: 0.4rem 0;
  272. width: 90%;
  273. border: none;
  274. outline: none;
  275. font-size: 0.6rem;
  276. }
  277. .mint-cell {
  278. width: 100%;
  279. }
  280. &:last-child {
  281. border: none;
  282. }
  283. .iconfont {
  284. color: $main-color;
  285. font-size: 0.6rem;
  286. margin: 0 0.46rem;
  287. }
  288. }
  289. }
  290. .forget {
  291. text-align: left;
  292. padding: 0.45rem 1rem;
  293. a {
  294. float: left;
  295. font-size: 0.28rem;
  296. color: $main-color;
  297. &:nth-child(2) {
  298. color: #999999;
  299. float: right;
  300. }
  301. &:active {
  302. background: $white-bg;
  303. }
  304. }
  305. }
  306. .loginBtn {
  307. width: 100%;
  308. height: 1.4rem;
  309. line-height: 1.4rem;
  310. background: $main-color;
  311. color: #fff;
  312. font-size: 0.6rem;
  313. @include text-align;
  314. border-radius: 4px;
  315. margin: 1rem 0 0 0;
  316. }
  317. .disableLoginBtn {
  318. background: lightgray;
  319. }
  320. }
  321. }
  322. .remember {
  323. float: left;
  324. }
  325. .agreeText {
  326. color: #409eff;
  327. font-size: 14px;
  328. }
  329. }
  330. </style>
  331. <style lang="scss">
  332. .remember {
  333. .el-checkbox__inner {
  334. @media only screen and (min-width: 415px) and (max-width: 767px) {
  335. width: 20px;
  336. height: 20px;
  337. }
  338. @media only screen and (min-width: 768px) {
  339. width: 20px;
  340. height: 20px;
  341. }
  342. }
  343. .el-checkbox__inner::after {
  344. @media only screen and (min-width: 415px) and (max-width: 767px) {
  345. left: 7px;
  346. height: 12px;
  347. width: 4px;
  348. }
  349. @media only screen and (min-width: 768px) {
  350. left: 7px;
  351. height: 12px;
  352. width: 4px;
  353. }
  354. }
  355. .el-checkbox__label {
  356. @media only screen and (min-width: 415px) and (max-width: 767px) {
  357. font-size: 0.45rem;
  358. }
  359. @media only screen and (min-width: 768px) {
  360. font-size: 0.45rem;
  361. }
  362. }
  363. }
  364. .agree {
  365. .el-checkbox__inner {
  366. @media only screen and (min-width: 415px) and (max-width: 767px) {
  367. width: 20px;
  368. height: 20px;
  369. }
  370. @media only screen and (min-width: 768px) {
  371. width: 20px;
  372. height: 20px;
  373. }
  374. }
  375. .el-checkbox__inner::after {
  376. @media only screen and (min-width: 415px) and (max-width: 767px) {
  377. left: 7px;
  378. height: 12px;
  379. width: 4px;
  380. }
  381. @media only screen and (min-width: 768px) {
  382. left: 7px;
  383. height: 12px;
  384. width: 4px;
  385. }
  386. }
  387. .el-checkbox__label {
  388. @media only screen and (min-width: 415px) and (max-width: 767px) {
  389. font-size: 0.45rem;
  390. }
  391. @media only screen and (min-width: 768px) {
  392. font-size: 0.45rem;
  393. }
  394. }
  395. .agreeText {
  396. @media only screen and (min-width: 415px) and (max-width: 767px) {
  397. font-size: 0.45rem;
  398. }
  399. @media only screen and (min-width: 768px) {
  400. font-size: 0.45rem;
  401. }
  402. }
  403. }
  404. </style>