c6c12a6c7a160f8e1df36ac551624e49acf3d97f.svn-base 7.5 KB

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