//注册获取新的验证码 mutations_registration_get_verificationCode(store) { let registration_get_code = store.state.registration.registration_get_code; //设置是否允许 获取新的求情的标志位 let params = { number: 1252223333 }; if (!registration_get_code) { return false; } store.state.registration.registration_get_code = false; // 不允许发送请求 console.log("registration_get_code"); get("/verificationCode ", params) .then(response => { alert("then"); console.log(response); }) .catch(err => { alert("get err"); }); post("/verificationCode ", params) .then(response => { console.log(response); }) .catch(err => { console.log(err); alert("post err"); console.log(" error"); }).finally(()=>{ alert('axios end') }) // 服务调取成功后 启动技术 mutations_registration_set_interver(store); function mutations_registration_set_interver(store) { let time = 10; let store1 = store; let defaultText = store1.state.registration.getVerificationDefaultText; alert("mutations_registration_set_interver"); let timer = setInterval(function() { time -= 1; store1.state.registration.getVerificationTimer = time; store1.state.registration.getVerificationText = `重发(${time}s)`; if (time <= 0) { clearInterval(timer); store1.state.registration.getVerificationText = defaultText; store.state.registration.registration_get_code = true; // 允许发送请求 } }, 1000); } },