axios 使用

  //註冊獲取新的驗證碼
  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);
    }
  },
相關文章
相關標籤/搜索