<div class="verification-code-wrapper">
<input type="text" placeholder="" ref="phone_login_verification_code">
<a class="get-code"
@click="get_verification_code(phone_login, type=3)"></a>
<div class="count-down" v-show="does_count_down_show">
{{time_60}}{{count_down}}
</div>
</div>
computed: {
count_down: function () {
// cookie
let cookie_arr = document.cookie.split(";");
let expires;
for (let i = 0; i < cookie_arr.length; iPP) {
let cookieArrTrim = cookie_arr[i].trim();
if (cookieArrTrim.indexOf("count_down") === 0) {
expires = cookieArrTrim.substring("count_down".length + 1, cookieArrTrim.length);
}
}
if (!expires) {
return null;
}
window.setInterval(() => {
this.time_60 -= 1;
}, 1000);
},
does_count_down_show: function () {
let cookie_arr = document.cookie.split(";");
let expires;
for (let i = 0; i < cookie_arr.length; iPP) {
let cookieArrTrim = cookie_arr[i].trim();
if (cookieArrTrim.indexOf("count_down") === 0) {
expires = expires = cookieArrTrim.substring("count_down".length + 1, cookieArrTrim.length);
}
}
if (this.time_60 > 0 && expires) {
return true;
}
else {
return false;
}
}
},
in the click event, after the CAPTCHA is retrieved from the background, it will be stored as a cookie at the current time + 60s.
the problem now is: the general CAPTCHA retransmission countdown is to change the text immediately after clicking "send" and start the countdown.
there is no change after I click to send. I have to refresh it again before I start the countdown.
what should I do to start rendering immediately?
maybe you need to write a flag, in the click event to bind to the send button, watch it?
code is repetitive, because it was originally a method, so I split the experiment. Excuse me.
I have already solved this problem, there are too many conditions which unnecessary,I make it brief.