29d2601ae53a1d77c5fbabd9556919123a8395af.svn-base 8.6 KB

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