复制 function throttle (fn , limit = 2000 ) {
let flag = true
return function () {
if (flag) {
fn .apply ( this , arguments)
flag = false
setTimeout (() => { flag = true } , limit)
}
}
}
// mounted 里面
self = this ;
this .debounceFn =
throttle ((num) => {
self .openPacket (num)
})
doLottery (num) {
this .debounceFn (num)
} ,
复制 4. 埋点问题
postTask 和 dolottery 不一样, 两者的区分点在与游戏逻辑。
```js
// dolottery
* true logger.makeActivityLog('activity_prize_got');
* false logger.makeActivityLog('activity_prize_failed');//调抽奖接口返回错误、异常埋点
//postTask
* true
* false logger.makeActivityLog('activity_prizebad_juge'); // 获取lottery失败次数
复制 DialogBuilder.of(this).alert(util.createComponentProxy(_BigTitle, {'title': '恭喜你!'}), util.createComponentProxy(_LotteryResult, {'award': realAward[0]}));
DialogBuilder.of(this).confirm(util.createComponentProxy(_BigTitle, {title: '合成成功!'}), util.createComponentProxy(_LotteryResult, {'award': award, awardNameColor: '#fcff29', tipsColor: 'rgba(0,0,0,.5)'}));
复制 self . $store .commit ( 'setAccessToken' , token);
复制 NativeInterface .goBackDirectly ();
复制 let bgAudio = document .getElementById ( "bgaudio" ) .play ();
if (bgAudio !== undefined ) {
bgAudio .catch (error => {
console .log ( 'error: ' , error);
// Auto-play was prevented
// Show a UI element to let the user manually start playback
}) .then (() => {
// Auto-play started
});
}