Skip to content

Commit

Permalink
fix: 你藏我猜小程序适配
Browse files Browse the repository at this point in the history
  • Loading branch information
Ymm0008 committed Apr 7, 2022
1 parent 70fdd4a commit 49f8e2f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
24 changes: 11 additions & 13 deletions src/packages/__VUE/guessgift/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,36 @@
</template>

<script lang="ts">
import { Dialog } from "@nutui/nutui";
import { Ref, ref } from 'vue';
import { createComponent } from '../../utils/create';
import { reactive } from '@vue/reactivity';
const { createDemo } = createComponent('guess-gift');
import { Ref, ref } from "vue";
import { createComponent } from "../../utils/create";
const { createDemo } = createComponent("guess-gift");
export default createDemo({
props: {},
setup() {
const guessgiftDom: Ref = ref(null);
// 中奖的奖品的index(此数据可根据后台返回的值重新赋值)
const prizeIndex = ref(3);
const prizeIndex = ref(3);
const gameStart = () => {
guessgiftDom.value.start();
}
};
const startTurns = () => {
console.log('开始抽奖');
}
console.log("开始抽奖");
};
const endTurns = () => {
console.log('抽奖结束');
}
console.log("抽奖结束");
};
const turnNum = ref(5);
return {
guessgiftDom,
turnNum,
prizeIndex,
gameStart,
startTurns,
endTurns
endTurns,
};
}
},
});
</script>

Expand Down
27 changes: 15 additions & 12 deletions src/packages/__VUE/guessgift/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ export default create({
});
// 打乱数组顺序
const shuffleNewary = ref([]);
const shuffle = (ary: Array<any>) => {
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;
};
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sites/mobile-taro/vue/src/pages/guessgift/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down

0 comments on commit 49f8e2f

Please sign in to comment.