Browse Source

feat: 游戏列表界面及功能实现实现

master
wally 4 years ago
parent
commit
036f377ef2
  1. BIN
      public/page3/apple.jpg
  2. BIN
      public/page3/balloon.jpg
  3. BIN
      public/page3/basketball.jpg
  4. BIN
      public/page3/bird.jpg
  5. BIN
      public/page3/bomb.jpg
  6. BIN
      public/page3/football.jpg
  7. BIN
      public/page3/golf.jpg
  8. BIN
      public/page3/hurdle.jpg
  9. BIN
      public/page3/left-disable.png
  10. BIN
      public/page3/left.png
  11. BIN
      public/page3/orange-juice.jpg
  12. BIN
      public/page3/right-disable.png
  13. BIN
      public/page3/right.png
  14. BIN
      public/page3/tomato.jpg
  15. 2
      src/store/index.js
  16. 126
      src/views/GameList.vue

BIN
public/page3/apple.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 KiB

BIN
public/page3/balloon.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

BIN
public/page3/basketball.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 KiB

BIN
public/page3/bird.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

BIN
public/page3/bomb.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

BIN
public/page3/football.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 KiB

BIN
public/page3/golf.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

BIN
public/page3/hurdle.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

BIN
public/page3/left-disable.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
public/page3/left.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
public/page3/orange-juice.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 KiB

BIN
public/page3/right-disable.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
public/page3/right.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
public/page3/tomato.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 KiB

2
src/store/index.js

@ -2,7 +2,7 @@ import { createStore } from 'vuex';
import { getGamesBySite } from 'config/gameList';
export default createStore({
state: { selectedSite: '' },
state: { selectedSite: 'UpperLimb' },
getters: {
/**
* 当前选中的训练部位下的 游戏列表

126
src/views/GameList.vue

@ -1,17 +1,53 @@
<template>
<button @click="$router.back()">返回</button>
游戏列表选择
<div v-for="item in games" :key="item.id" @click="openGame(item.name)">
{{ item.text }}
<!-- <button @click="$router.back()">返回</button>-->
<!-- 游戏列表选择-->
<!-- <div v-for="item in games" :key="item.id" @click="openGame(item.name)">-->
<!-- {{ item.text }}-->
<!-- </div>-->
<div class="container" :style="{ 'background-image': `url(${gameImage})` }">
<div class="back" @click="$router.back()"></div>
<div class="btn btn-left" :class="{ disabled: page === 0 }" @click="handlePrev"></div>
<div class="small-container">
<div
class="small-item"
v-for="item in showGames"
:key="item.id"
@mouseover="mouseover(item.name)"
@click="openGame(item.name)"
:style="{ 'background-image': `url(/page3/${item.name}.jpg)` }"
></div>
</div>
<div class="btn btn-right" :class="{ disabled: page === total - 1 }" @click="handleNext"></div>
</div>
</template>
<script setup>
import { useStore } from 'vuex';
import { computed } from 'vue';
import { computed, ref } from 'vue';
// TODO: url
const store = useStore();
const games = computed(() => store.getters.selectedGames);
const allGames = computed(() => store.getters.selectedGames); //
const gameImage = ref(`/page3/${allGames.value[0].name}.jpg`); //
const page = ref(0); //
const size = 4;
const count = computed(() => allGames.value.length); //
const total = computed(() => Math.ceil(count.value / size)); //
const showGames = computed(() => allGames.value.slice(page.value * size, page.value * size + size));
//
function handlePrev() {
console.log(allGames.value, showGames.value);
if (page.value === 0) return;
page.value -= 1;
}
//
function handleNext() {
if (page.value === total.value - 1) return;
page.value += 1;
}
/**
* 根据game.name 跳转到对应的游戏界面
@ -20,6 +56,82 @@ const games = computed(() => store.getters.selectedGames);
function openGame(gameName) {
window.location.href = `https://www.tall.wiki/kangfu/game/${gameName}/win`;
}
/**
* 输入移入预览图 切换背景图
* @param {string} gameName 游戏name
*/
function mouseover(gameName) {
gameImage.value = `/page3/${gameName}.jpg`;
}
</script>
<style scoped></style>
<style scoped>
.container {
position: absolute;
width: 1280rem;
height: 720rem;
left: 50%;
top: 50%;
transform: translate3d(-50%, -50%, 0);
background-repeat: no-repeat;
background-position: center;
background-size: 1280rem 720rem;
}
.small-container {
position: absolute;
left: 78rem;
bottom: 20rem;
width: 1128rem;
height: 160rem;
display: flex;
}
.small-item {
width: 276rem;
height: 154rem;
background-repeat: no-repeat;
background-position: center;
background-size: 276rem 154rem;
border: 4rem solid #fff;
margin-right: 8rem;
cursor: pointer;
}
.small-item:last-child {
margin-right: 0;
}
.btn {
position: absolute;
bottom: 64rem;
transform: translate3d(0, -50%, 0);
width: 40rem;
height: 40rem;
background-position: center;
background-size: 40rem;
background-repeat: no-repeat;
cursor: pointer;
}
.btn-left {
left: 20rem;
background-image: url('/page3/left.png');
}
.btn-right {
right: 20rem;
background-image: url('/page3/right.png');
}
.btn-left.disabled {
background-image: url('/page3/left-disable.png');
}
.btn-right.disabled {
background-image: url('/page3/right-disable.png');
}
.back {
width: 100rem;
height: 107rem;
position: absolute;
left: 30rem;
top: 30rem;
background: url('/page2/return.png') no-repeat center;
background-size: 100rem 107rem;
}
</style>

Loading…
Cancel
Save