血透系统pad前端

login.vue 11KB

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