afe039c09661618b33e782258baef4605898fb57.svn-base 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. localStorage.setItem('token',res.data.data[0].token)
  138. localStorage.setItem('name',res.data.data[0].name)
  139. this.$store.dispatch('GET_ISSHOW',false)
  140. }else{
  141. console.log('resstatus',res)
  142. this.info = res.data.msg;
  143. }
  144. })
  145. // 是否记住账号,记住账号是在登录成功后使用
  146. if (this.rememberacc == true) {
  147. localStorage.setItem('value',this.account)
  148. }
  149. }else{
  150. this.info = '账号或密码有误'
  151. }
  152. },
  153. // 关闭登录组件
  154. LoginEsc(){
  155. // 关闭登录
  156. this.isshow=false;
  157. this.$store.dispatch('GET_ISSHOW',this.isshow)
  158. },
  159. register(){
  160. this.$store.dispatch('GET_ISSHOW',false);
  161. this.$store.dispatch('GETRGSHOW', true);
  162. }
  163. },
  164. computed: {
  165. Isshow:function(){
  166. this.$store.dispatch('GET_ISSHOW',this.isshow)
  167. return {
  168. isshow_code:this.$store.state.isShow
  169. }
  170. }
  171. },
  172. watch: {
  173. Isshow(obj){
  174. }
  175. },
  176. mounted(){
  177. console.log('status',localStorage.getItem('status'))
  178. if(localStorage.getItem('status')){
  179. this.account = localStorage.getItem('value');
  180. this.rememberacc = true;
  181. }else{
  182. this.account = '';
  183. this.rememberacc = false;
  184. }
  185. }
  186. };
  187. </script>
  188. <style scoped>
  189. .Loginbox {
  190. background: #f8f8f8;
  191. border-radius: 0.52rem;
  192. }
  193. .loginbox-close {
  194. height: 1.2rem;
  195. position: relative;
  196. }
  197. .loginbox-close img {
  198. width: 0.26rem;
  199. height: 0.26rem;
  200. position: absolute;
  201. top: 0.92rem;
  202. right: 0.93rem;
  203. }
  204. .loginbox-logo {
  205. height: 1.5rem;
  206. display: flex;
  207. justify-content: center;
  208. font-size: .6rem;
  209. color: #ccc;
  210. align-items: center;
  211. }
  212. .Loginbox-main {
  213. display: flex;
  214. justify-content: center;
  215. align-items: center;
  216. flex-wrap: wrap;
  217. }
  218. .Loginbox-main .account-box,
  219. .password-box {
  220. height: 0.9rem;
  221. width: 5rem;
  222. border-bottom: 1px solid #e4e4e4;
  223. display: flex;
  224. align-items: center;
  225. justify-content: space-around;
  226. }
  227. .password-box-img img {
  228. width: 0.53rem;
  229. height: 0.53rem;
  230. }
  231. .account-box-img img {
  232. width: 0.33rem;
  233. height: 0.32rem;
  234. }
  235. .password-box-look img {
  236. width: 0.4rem;
  237. height: 0.4rem;
  238. }
  239. .account-box-img {
  240. width: 0.8rem !important;
  241. display: flex;
  242. justify-content: center;
  243. align-items: center;
  244. }
  245. .password-box-img {
  246. width: 0.8rem !important;
  247. display: flex;
  248. justify-content: center;
  249. align-items: center;
  250. }
  251. .password-box-look {
  252. width: 0.8rem !important;
  253. display: flex;
  254. justify-content: center;
  255. align-items: center;
  256. }
  257. input {
  258. border: none;
  259. width: 100%;
  260. height: .9rem;
  261. font-size: 0.26rem;
  262. color: #aaaaaa;
  263. }
  264. .instrument-box {
  265. height: 0.9rem;
  266. width: 5rem;
  267. display: flex;
  268. justify-content: space-between;
  269. padding: 0 0.5rem;
  270. align-items: center;
  271. }
  272. .remember-acc {
  273. display: flex;
  274. justify-content: flex-start;
  275. }
  276. .remember-acc img {
  277. width: 0.33rem;
  278. height: 0.33rem;
  279. }
  280. .login-btn {
  281. width: 5rem;
  282. height: 0.88rem;
  283. background: #F76649;
  284. color: #f8f8f8;
  285. display: flex;
  286. border-radius: .08rem;
  287. justify-content: center;
  288. align-items: center;
  289. }
  290. .login-footer {
  291. height: 1.96rem;
  292. display: flex;
  293. justify-content: center;
  294. flex-wrap: wrap;
  295. align-items: center;
  296. width: 100%;
  297. }
  298. .infomation{
  299. width: 100%;
  300. margin-left: 20%;
  301. margin-top: 0.2rem;
  302. color: #F76649;
  303. }
  304. </style>