64a0167f68027b8363b7a4c781555daa64c215ef.svn-base 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <div>
  3. <yd-popup v-model="isshow" position="center" width="90%">
  4. <div class="Loginbox">
  5. <div class="Loginbox-top">
  6. <div class="loginbox-close">
  7. <img :src="img.url1" @click="LoginEsc()">
  8. </div>
  9. <div class="loginbox-logo">
  10. <span>
  11. <i style="color:#F76649">HX</i>699
  12. </span>
  13. </div>
  14. </div>
  15. <!-- 账号输入框 -->
  16. <div class="Loginbox-main">
  17. <div class="account-box">
  18. <div class="account-box-img">
  19. <img :src="img.url3">
  20. </div>
  21. <!-- 账号输入 -->
  22. <div class="account-box-input">
  23. <input
  24. @focus="clearacc('acc')"
  25. :style="account=='用户名不存在'?'color:red;':''"
  26. v-model="account"
  27. type="text"
  28. placeholder="账户名"
  29. onkeyup="this.value=this.value.replace(/^ +| +$/g,'')"
  30. >
  31. </div>
  32. <div style="width:.8rem"></div>
  33. </div>
  34. <!-- 密码输入框 -->
  35. <div class="password-box">
  36. <div class="password-box-img">
  37. <img :src="img.url4">
  38. </div>
  39. <!-- 密码输入 -->
  40. <div class="password-box-input">
  41. <input
  42. @focus="clearacc('pwd')"
  43. v-model="password"
  44. :style="password=='密码错误'?'color:red;':''"
  45. :type="lockactive == true ? 'text' : 'password'"
  46. placeholder="密码"
  47. onkeyup="this.value=this.value.replace(/^ +| +$/g,'')"
  48. >
  49. </div>
  50. <!-- 查看密码,密码可见 -->
  51. <div class="password-box-look">
  52. <img @click="lookclick(lockactive)" :src="lockactive == true ? img.url6 : img.url5">
  53. </div>
  54. </div>
  55. <div class="infomation">{{info}}</div>
  56. <div class="instrument-box">
  57. <div class="remember-acc" @click="instrumentclick()">
  58. <img :src="rememberacc == true ? img.url8 : img.url7">
  59. &nbsp;
  60. <span style="color: #AAAAAA;">记住账号</span>
  61. </div>
  62. <div class="forget-pwd" @click="forgetpwd(account)">
  63. <span style="color: #F76649;">忘记密码</span>
  64. </div>
  65. </div>
  66. <div class="login-btn" @click="login()">登录</div>
  67. <div class="login-footer">
  68. <p style="width: 100%;color: #AAAAAA;font-size: .22rem;text-align: center;">
  69. 没有HX699账户?
  70. <br>
  71. <span style="color: #F76649;font-size: .23rem;" @click="register()">注册</span>
  72. </p>
  73. </div>
  74. </div>
  75. </div>
  76. </yd-popup>
  77. </div>
  78. </template>
  79. <script>
  80. export default {
  81. name: "Login",
  82. data() {
  83. return {
  84. // 账号密码
  85. account: "",
  86. password: "",
  87. // 是否密码可见
  88. lockactive: false,
  89. // 是否记住账号
  90. rememberacc: false,
  91. // 是否退出登录界面
  92. isshow: this.$store.state.isShow,
  93. info: "",
  94. // 提示数据
  95. data: "",
  96. img: {
  97. url1: require("@/assets/st-imges/guanbi.png"),
  98. url2: require("@/assets/st-imges/loginlogo.png"),
  99. url3: require("@/assets/st-imges/zhanghao.png"),
  100. url4: require("@/assets/st-imges/mima.png"),
  101. url5: require("@/assets/st-imges/kan.png"),
  102. url6: require("@/assets/st-imges/kanactive.png"),
  103. url7: require("@/assets/st-imges/xuanzhong.png"),
  104. url8: require("@/assets/st-imges/xuanzhongactive.png")
  105. }
  106. };
  107. },
  108. methods: {
  109. // 错误刷新
  110. clearacc(val) {
  111. if (val == "acc") this.account = "";
  112. else if (val == "pwd") this.password = "";
  113. },
  114. // 点击密码可见
  115. lookclick(istrue) {
  116. this.lockactive = !istrue;
  117. },
  118. // 点击确认是否记住账号
  119. instrumentclick() {
  120. this.rememberacc = !this.rememberacc;
  121. console.log("123", this.rememberacc);
  122. if (this.rememberacc == true) {
  123. if (localStorage.getItem("token")) {
  124. localStorage.setItem("status", true);
  125. }
  126. } else {
  127. localStorage.setItem("status", false);
  128. }
  129. },
  130. // 点击忘记密码?
  131. forgetpwd(acc) {
  132. console.log("这是忘记密码");
  133. },
  134. login() {
  135. if (this.account.length > 0 && this.password.length > 0) {
  136. console.log(this.account.length);
  137. // 请在此处发送登录请求
  138. this.$http
  139. .post(this.$ports.login.login, {
  140. account: this.account,
  141. password: this.password
  142. })
  143. .then(res => {
  144. if (res.data.status == 1) {
  145. this.info = "";
  146. this.$public.setItem("token", res.data.data[0].token);
  147. this.$store.dispatch("SET_TOKEN", res.data.data[0].token);
  148. localStorage.setItem("name", res.data.data[0].name);
  149. this.$store.dispatch("GET_ISSHOW", false);
  150. this.$dialog.toast({mes: '登录成功!', timeout: 1500});
  151. } else {
  152. console.log('resstatus',res)
  153. this.info = res.data.msg;
  154. }
  155. });
  156. // 是否记住账号,记住账号是在登录成功后使用
  157. if (this.rememberacc == true) {
  158. localStorage.setItem("value", this.account);
  159. }
  160. } else {
  161. this.info = "账号或密码有误";
  162. }
  163. },
  164. // 关闭登录组件
  165. LoginEsc() {
  166. // 关闭登录
  167. this.isshow = false;
  168. this.$store.dispatch("GET_ISSHOW", this.isshow);
  169. this.$store.dispatch("SET_NOROLL", false);
  170. },
  171. register() {
  172. this.$store.dispatch("GET_ISSHOW", false);
  173. this.$store.dispatch("GETRGSHOW", true);
  174. }
  175. },
  176. computed: {
  177. Isshow: function() {
  178. // 根据登录框设置背景可否滚动
  179. this.$store.dispatch("SET_NOROLL", this.isshow);
  180. this.$store.dispatch("GET_ISSHOW", this.isshow);
  181. return {
  182. isshow_code: this.$store.getters.getIsShow
  183. };
  184. }
  185. },
  186. watch: {
  187. Isshow(obj) {}
  188. },
  189. mounted() {
  190. // console.log('status',localStorage.getItem('status'))
  191. if (localStorage.getItem("status")) {
  192. this.account = localStorage.getItem("value");
  193. this.rememberacc = true;
  194. } else {
  195. this.account = "";
  196. this.rememberacc = false;
  197. }
  198. }
  199. };
  200. </script>
  201. <style scoped>
  202. .Loginbox {
  203. background: #f8f8f8;
  204. border-radius: 0.52rem;
  205. }
  206. .loginbox-close {
  207. height: 1.2rem;
  208. position: relative;
  209. }
  210. .loginbox-close img {
  211. width: 0.26rem;
  212. height: 0.26rem;
  213. position: absolute;
  214. top: 0.92rem;
  215. right: 0.93rem;
  216. }
  217. .loginbox-logo {
  218. height: 1.5rem;
  219. display: flex;
  220. justify-content: center;
  221. font-size: 0.6rem;
  222. color: #ccc;
  223. align-items: center;
  224. }
  225. .Loginbox-main {
  226. display: flex;
  227. justify-content: center;
  228. align-items: center;
  229. flex-wrap: wrap;
  230. }
  231. .Loginbox-main .account-box,
  232. .password-box {
  233. height: 0.9rem;
  234. width: 5rem;
  235. border-bottom: 1px solid #e4e4e4;
  236. display: flex;
  237. align-items: center;
  238. justify-content: space-around;
  239. }
  240. .password-box-img img {
  241. width: 0.53rem;
  242. height: 0.53rem;
  243. }
  244. .account-box-img img {
  245. width: 0.33rem;
  246. height: 0.32rem;
  247. }
  248. .password-box-look img {
  249. width: 0.4rem;
  250. height: 0.4rem;
  251. }
  252. .account-box-img {
  253. width: 0.8rem !important;
  254. display: flex;
  255. justify-content: center;
  256. align-items: center;
  257. }
  258. .password-box-img {
  259. width: 0.8rem !important;
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. }
  264. .password-box-look {
  265. width: 0.8rem !important;
  266. display: flex;
  267. justify-content: center;
  268. align-items: center;
  269. }
  270. input {
  271. border: none;
  272. width: 100%;
  273. height: 0.9rem;
  274. font-size: 0.26rem;
  275. color: #aaaaaa;
  276. }
  277. .instrument-box {
  278. height: 0.9rem;
  279. width: 5rem;
  280. display: flex;
  281. justify-content: space-between;
  282. padding: 0 0.5rem;
  283. align-items: center;
  284. }
  285. .remember-acc {
  286. display: flex;
  287. justify-content: flex-start;
  288. }
  289. .remember-acc img {
  290. width: 0.33rem;
  291. height: 0.33rem;
  292. }
  293. .login-btn {
  294. width: 5rem;
  295. height: 0.88rem;
  296. background: #f76649;
  297. color: #f8f8f8;
  298. display: flex;
  299. border-radius: 0.08rem;
  300. justify-content: center;
  301. align-items: center;
  302. }
  303. .login-footer {
  304. height: 1.96rem;
  305. display: flex;
  306. justify-content: center;
  307. flex-wrap: wrap;
  308. align-items: center;
  309. width: 100%;
  310. }
  311. .infomation {
  312. width: 100%;
  313. margin-left: 20%;
  314. margin-top: 0.2rem;
  315. color: #f76649;
  316. }
  317. </style>