血透系统pad前端

login.vue 11KB

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