update
Showing
1 changed file
with
75 additions
and
5 deletions
| ... | @@ -16,8 +16,14 @@ | ... | @@ -16,8 +16,14 @@ |
| 16 | placeholder="请输入密码" show-password></el-input> | 16 | placeholder="请输入密码" show-password></el-input> |
| 17 | </el-form-item> | 17 | </el-form-item> |
| 18 | <el-form-item prop="yz"> | 18 | <el-form-item prop="yz"> |
| 19 | <el-input class="yz" @keyup.native="login('user')" v-model="user.yz" | 19 | <div class="flex-container"> |
| 20 | placeholder="请输入验证码"></el-input> | 20 | <div class="flex-input"> |
| 21 | <el-input class="yz" @keyup.native="login('user')" v-model="user.yz" placeholder="请输入验证码"></el-input> | ||
| 22 | </div> | ||
| 23 | <div class="flex-line"></div> | ||
| 24 | <div class="flex-img"><canvas id="s-canvas" ref="s-canvas"></canvas></div> | ||
| 25 | <div class="flex-renovate"><font id="renovate" @click="verification">换一批</font></div> | ||
| 26 | </div> | ||
| 21 | </el-form-item> | 27 | </el-form-item> |
| 22 | <el-form-item class="login-btn"> | 28 | <el-form-item class="login-btn"> |
| 23 | <el-button type="primary" style="width: 100%" @click="login('user')">登录</el-button> | 29 | <el-button type="primary" style="width: 100%" @click="login('user')">登录</el-button> |
| ... | @@ -48,7 +54,8 @@ | ... | @@ -48,7 +54,8 @@ |
| 48 | }, | 54 | }, |
| 49 | }; | 55 | }; |
| 50 | }, | 56 | }, |
| 51 | created () { | 57 | created () { |
| 58 | this.verification(); | ||
| 52 | const params = {}; | 59 | const params = {}; |
| 53 | const queryOptions = { | 60 | const queryOptions = { |
| 54 | conditionGroup: { | 61 | conditionGroup: { |
| ... | @@ -78,7 +85,37 @@ | ... | @@ -78,7 +85,37 @@ |
| 78 | mounted () { | 85 | mounted () { |
| 79 | // this.checkUserName(); | 86 | // this.checkUserName(); |
| 80 | }, | 87 | }, |
| 81 | methods: { | 88 | methods: { |
| 89 | verification() { | ||
| 90 | let str = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ', code = '', i = 0; | ||
| 91 | for( ; i++ < 4 ; ) code += str[ Math.floor( Math.random() * ( str.length - 0 ) + 0 ) ]; | ||
| 92 | setTimeout( () => { | ||
| 93 | let canvas = document.getElementById("s-canvas"), ctx = canvas.getContext("2d"); | ||
| 94 | canvas.width = 80; | ||
| 95 | canvas.height = 28; | ||
| 96 | ctx.fillStyle = '#ffffff'; | ||
| 97 | ctx.fillRect( 0, 0, 80, 28 ); | ||
| 98 | for ( i = 0; i < code.length; i++ ) { this.drawText( ctx, code[i], i ); } | ||
| 99 | }, 0 ); | ||
| 100 | }, | ||
| 101 | drawText(ctx, txt, i) { | ||
| 102 | ctx.fillStyle = this.randomColor(50, 160); | ||
| 103 | ctx.font = "18px SimHei"; | ||
| 104 | let x = (i + 1) * (80 / (4 + 1)), y = this.randomNum( 18, 28 - 5 ); | ||
| 105 | ctx.translate(x, y); | ||
| 106 | ctx.fillText(txt, 0, 0); | ||
| 107 | ctx.rotate((-0 * Math.PI) / 180); | ||
| 108 | ctx.translate(-x, -y); | ||
| 109 | }, | ||
| 110 | randomColor(min, max) { | ||
| 111 | let r = this.randomNum(min, max); | ||
| 112 | let g = this.randomNum(min, max); | ||
| 113 | let b = this.randomNum(min, max); | ||
| 114 | return "rgb(" + r + "," + g + "," + b + ")"; | ||
| 115 | }, | ||
| 116 | randomNum(min, max) { | ||
| 117 | return Math.floor(Math.random() * (max - min) + min); | ||
| 118 | }, | ||
| 82 | //记住用户名 | 119 | //记住用户名 |
| 83 | checkUserName: function (flag) { | 120 | checkUserName: function (flag) { |
| 84 | this.user.checkStatus = flag; | 121 | this.user.checkStatus = flag; |
| ... | @@ -128,7 +165,6 @@ | ... | @@ -128,7 +165,6 @@ |
| 128 | .password, | 165 | .password, |
| 129 | .yz { | 166 | .yz { |
| 130 | position: relative; | 167 | position: relative; |
| 131 | |||
| 132 | &:before { | 168 | &:before { |
| 133 | content: ""; | 169 | content: ""; |
| 134 | display: block; | 170 | display: block; |
| ... | @@ -148,6 +184,40 @@ | ... | @@ -148,6 +184,40 @@ |
| 148 | } | 184 | } |
| 149 | } | 185 | } |
| 150 | 186 | ||
| 187 | .flex-container { | ||
| 188 | position: relative; | ||
| 189 | display: -webkit-flex; | ||
| 190 | display: flex; | ||
| 191 | } | ||
| 192 | |||
| 193 | .flex-input { | ||
| 194 | width: 100%; | ||
| 195 | } | ||
| 196 | .flex-line { | ||
| 197 | position: absolute; | ||
| 198 | width: 1px; | ||
| 199 | height: 64%; | ||
| 200 | margin: 5px; | ||
| 201 | right: 36%; | ||
| 202 | background-color: #CCCCCC; | ||
| 203 | } | ||
| 204 | .flex-img { | ||
| 205 | position: absolute; | ||
| 206 | margin: 2px; | ||
| 207 | right: 16%; | ||
| 208 | } | ||
| 209 | .flex-renovate { | ||
| 210 | position: absolute; | ||
| 211 | margin: 1px; | ||
| 212 | right: 3%; | ||
| 213 | } | ||
| 214 | #renovate { | ||
| 215 | color: #3F8FEA; | ||
| 216 | font-size: 16px; | ||
| 217 | font-weight: 700; | ||
| 218 | cursor: pointer; | ||
| 219 | } | ||
| 220 | |||
| 151 | .username::before { | 221 | .username::before { |
| 152 | background-image: url(../../image/userlogo.png); | 222 | background-image: url(../../image/userlogo.png); |
| 153 | } | 223 | } | ... | ... |
-
Please register or sign in to post a comment