血透系统pad前端

login.vue 11KB

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