1.先是获取到中奖的内存里的所有id
2.再获取到本身的中奖id
3.如果内存中存在id,但是不是中奖的那个,就不显示弹窗.
var getCode = JSON.parse(localStorage.getItem("prizeIds")) vmi.awardId = res.data.id; if (getCode) { if (getCode.indexOf(Number(res.data.id)) != '-1') { vmi.comfirmYouAward = false; vmi.hideTheCover = false; } } if (!getCode) { vmi.comfirmYouAward = true; vmi.hideTheCover = true; vmi.awardIds.push(Number(res.data.id)); localStorage.setItem('prizeIds', JSON.stringify(vmi.awardIds)) vmi.getAwardGoodsInfo = res.data; } if (getCode && getCode.indexOf(Number(res.data.id)) == '-1') { vmi.comfirmYouAward = true; vmi.hideTheCover = true; vmi.awardIds.push(Number(res.data.id)); localStorage.setItem('prizeIds', JSON.stringify(vmi.awardIds)) vmi.getAwardGoodsInfo = res.data; }