搜索

首页  >  问答  >  正文

如何在发出邀请电子邮件时添加提醒?

这是我的 JavaScript 代码,用于向其他人发送邀请电子邮件。 当邀请电子邮件发送成功时,如何/在哪里添加警报。 警报“您的电子邮件已发送”

async function invitePeopleToMyTeam(){
    let [invites,invite_statuses] = [[],$Q('.invitation-data.invite-access').slice(0,20)];

    $Q('.invitation-data.invite-email').slice(0,20).map((i,ind)=>{
        if(~i.value.search(/.+@.+\..+/gi)){
            invites.push({
                email:i.value.trim().toLowerCase(),
                status:invite_statuses[ind].options[invite_statuses[ind].selectedIndex].innerHTML.slice(0,1).toLowerCase()
        });
        }else{
            invite_statuses[ind] = null;
        }
    });

    for(let i=0,il=invites.length; i<il; i++){
        if(invites[i] === null){
            invites.split(i,1);
            il--;
            i--;
            continue;
        }
        if(invites[i].status == null || invites[i].status == ""){
            invites[i].status = "m";
        }
    }
    if(invites.length===0 || invites.filter(e=>e).length===0){
        alert('There don\'t seem to be any e-mails in your invite list. Please review and try again.');
        return false;
    }
    
    let sql = `./invitePeople.cfc?method=sendInvite`;
    let params = {"invites" : invites};

    let result = await fetch(sql, {
        method:"post",
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(params)
    })
    .then(resp => resp.text())
    .then(resp=>{console.log(resp); return resp})
    .then(r=>{
        $Q('.invitation-data.invite-email').slice(0,20).map((i,ind)=>{
        i.value= "";
    });
    })
    .catch(e=>console.log(e));
}

P粉057869348P粉057869348304 天前540

全部回复(1)我来回复

  • P粉842215006

    P粉8422150062024-02-27 00:16:27

    我认为你应该添加“最后”

    let result = await fetch(sql, {
            method:"post",
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(params)
        })
        .then(resp => resp.text())
        .then(resp=>{console.log(resp); return resp})
        .then(r=>{
            $Q('.invitation-data.invite-email').slice(0,20).map((i,ind)=>{
            i.value= "";
        })
        .finally(resp => alert('email sent')); // <<<<< here
        })
        .catch(e=>console.log(e));

    回复
    0
  • 取消回复