From 49f8e2f365d4ad5e67e45a525d14d7112ce682fe Mon Sep 17 00:00:00 2001 From: Ymm0008 Date: Thu, 7 Apr 2022 10:23:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BD=A0=E8=97=8F=E6=88=91=E7=8C=9C?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/__VUE/guessgift/demo.vue | 24 ++++++++--------- src/packages/__VUE/guessgift/index.taro.vue | 27 ++++++++++--------- .../vue/src/pages/guessgift/index.vue | 2 +- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/packages/__VUE/guessgift/demo.vue b/src/packages/__VUE/guessgift/demo.vue index 71f2093..8ac46d9 100644 --- a/src/packages/__VUE/guessgift/demo.vue +++ b/src/packages/__VUE/guessgift/demo.vue @@ -16,28 +16,26 @@ diff --git a/src/packages/__VUE/guessgift/index.taro.vue b/src/packages/__VUE/guessgift/index.taro.vue index 34e1e8b..56822b9 100644 --- a/src/packages/__VUE/guessgift/index.taro.vue +++ b/src/packages/__VUE/guessgift/index.taro.vue @@ -83,12 +83,14 @@ export default create({ }); // 打乱数组顺序 + const shuffleNewary = ref([]); const shuffle = (ary: Array) => { const array = JSON.parse(JSON.stringify(ary)); for (let i = array.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [array[i], array[j]] = [array[j], array[i]]; } + shuffleNewary.value = array; return array; }; @@ -166,16 +168,17 @@ export default create({ showBean.value = true; lock.value = true; const idx = _index + 1 > 2 ? 0 : _index + 1; + bowlRaiseIndex.value = idx; // const item = bowlEle[idx]; const _item = bowlElement[idx]; - + const m: any = shuffleNewary.value[idx] || _item; setTimeout(() => { if (_index > -1) { const _itemParentLeft = guessGiftEle.value.left || 0; const _left = - _item["left"] + - _item["width"] / 2 - + m["left"] + + m["width"] / 2 - _itemParentLeft - goldBeanEle.value.width / 2 + "px"; @@ -203,15 +206,15 @@ export default create({ showBean.value = true; const _item = orginBowlCopy[index]; const _itemParentLeft = guessGiftEle.value.left || 0; - setTimeout(() => { - const _left = - _item["left"] + - _item["width"] / 2 - - _itemParentLeft - - goldBeanDom.value.offsetWidth / 2 + - "px"; - goldBeanDomLeft.value = _left; - }, 100); + // setTimeout(() => { + const _left = + _item["left"] + + _item["width"] / 2 - + _itemParentLeft - + goldBeanEle.value.width / 2 + + "px"; + goldBeanDomLeft.value = _left; + // }, 100); } else { showBean.value = false; } diff --git a/src/sites/mobile-taro/vue/src/pages/guessgift/index.vue b/src/sites/mobile-taro/vue/src/pages/guessgift/index.vue index 91b8b0b..e211d65 100644 --- a/src/sites/mobile-taro/vue/src/pages/guessgift/index.vue +++ b/src/sites/mobile-taro/vue/src/pages/guessgift/index.vue @@ -27,7 +27,7 @@ export default { const guessgiftDom: Ref = ref(null); // 中奖的奖品的index(此数据可根据后台返回的值重新赋值) - const prizeIndex = ref(3); + const prizeIndex = ref(2); const gameStart = () => { guessgiftDom.value.start(); };