Commit 8eeb9e21 authored by 郝聪敏's avatar 郝聪敏

修改奖品列表重复问题

parent 6e812dde
...@@ -151,8 +151,7 @@ ...@@ -151,8 +151,7 @@
_invalidDown: 0, _invalidDown: 0,
_videoContexts: [], _videoContexts: [],
loading: false, loading: false,
isFirstUp: true, isFirstUp: true,
isComputing: false
}, },
watch: { watch: {
videoList () { videoList () {
...@@ -178,7 +177,8 @@ ...@@ -178,7 +177,8 @@
}, },
methods: { methods: {
compute (newVal) { compute (newVal) {
this.isComputing = true; if (!this.curQueue.length) return;
this.nextQueue.forEach(v => { this.nextQueue.forEach(v => {
v.probability = getProbability(+newVal, +v.coinQuantity); v.probability = getProbability(+newVal, +v.coinQuantity);
}); });
...@@ -194,7 +194,6 @@ ...@@ -194,7 +194,6 @@
this.curQueue = [...this.curQueue]; this.curQueue = [...this.curQueue];
this.nextQueue = [...this.nextQueue]; this.nextQueue = [...this.nextQueue];
this.prevQueue = [...this.prevQueue]; this.prevQueue = [...this.prevQueue];
this.isComputing = false;
}, },
async getProgress(id) { async getProgress(id) {
const detail = await getAwardsDetail({ prizeId: id }); const detail = await getAwardsDetail({ prizeId: id });
...@@ -252,60 +251,53 @@ ...@@ -252,60 +251,53 @@
this.isFirstUp = false; this.isFirstUp = false;
await fn(700); await fn(700);
} }
// if (timeout) clearTimeout(timeout);
// timeout = setTimeout(() => { const direction = diff === 1 || diff === -2 ? 'up' : 'down';
const direction = diff === 1 || diff === -2 ? 'up' : 'down'; if (direction === 'up') {
if (direction === 'up') { if (this._invalidDown === 0) {
if (this._invalidDown === 0) { const change = (this._change + 1) % 3;
const change = (this._change + 1) % 3; const add = this.nextQueue.shift();
const add = this.nextQueue.shift(); const remove = this.curQueue[change];
const remove = this.curQueue[change]; if (add) {
if (add) { this.prevQueue.push(remove);
this.prevQueue.push(remove); this.curQueue[change] = add;
this.curQueue[change] = add; this._change = change;
this._change = change; if (this.nextQueue.length === 0) this.nextQueue.push(this.prevQueue.shift());
if (this.nextQueue.length === 0) this.nextQueue.push(this.prevQueue.shift());
} else {
this._invalidUp += 1;
}
} else { } else {
this._invalidDown -= 1; this._invalidUp += 1;
} }
} else {
this._invalidDown -= 1;
} }
if (direction === 'down') { }
if (this._invalidUp === 0) { if (direction === 'down') {
const _change2 = this._change; if (this._invalidUp === 0) {
const _remove = this.curQueue[_change2]; const _change2 = this._change;
const _add = this.prevQueue.pop(); const _remove = this.curQueue[_change2];
if (_add) { const _add = this.prevQueue.pop();
this.curQueue[_change2] = _add; if (_add) {
this.nextQueue.unshift(_remove); this.curQueue[_change2] = _add;
this._change = (_change2 - 1 + 3) % 3; this.nextQueue.unshift(_remove);
console.log('this.prevQueue.length', this.prevQueue.length); this._change = (_change2 - 1 + 3) % 3;
if (this.prevQueue.length === 0) this.prevQueue.push(this.nextQueue.pop()); if (this.prevQueue.length === 0) this.prevQueue.push(this.nextQueue.pop());
} else {
this._invalidDown += 1;
}
} else { } else {
this._invalidUp -= 1; this._invalidDown += 1;
} }
} else {
this._invalidUp -= 1;
} }
this.curQueue = [...this.curQueue]; }
this.nextQueue = [...this.nextQueue]; this.curQueue = [...this.curQueue];
this.prevQueue = [...this.prevQueue]; this.nextQueue = [...this.nextQueue];
this.circular = true; this.prevQueue = [...this.prevQueue];
this.circular = true;
if (this.nextQueue.length === 0 && current !== 0) { if (this.nextQueue.length === 0 && current !== 0) {
console.log('circular1'); this.circular = false;
this.circular = false; }
} if (this.prevQueue.length === 0 && current !== 2) {
if (this.prevQueue.length === 0 && current !== 2) { this.circular = false;
console.log('circular2'); }
this.circular = false;
}
console.log(this.prevQueue.map(v => v.id), this.curQueue.map(v => v.id), this.nextQueue.map(v => v.id));
// }, 700);
}, },
onWaiting (e) { onWaiting (e) {
this.trigger(e, 'wait'); this.trigger(e, 'wait');
...@@ -366,7 +358,7 @@ ...@@ -366,7 +358,7 @@
cancelPause() { cancelPause() {
// console.log('bindchange'); // console.log('bindchange');
this.pause = false; this.pause = false;
}, }
} }
}); });
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment