Files
shoot-miniprograms/src/pages/index.vue

712 lines
18 KiB
Vue
Raw Normal View History

2025-04-10 11:11:46 +08:00
<script setup>
2026-01-08 10:30:41 +08:00
import { ref, onMounted } from "vue";
2025-09-12 10:38:21 +08:00
import { onShow, onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app";
2025-05-01 16:17:51 +08:00
import AppFooter from "@/components/AppFooter.vue";
2025-06-15 15:53:57 +08:00
import Signin from "@/components/Signin.vue";
2026-01-13 11:35:36 +08:00
import NoticeBar from "@/components/NoticeBar.vue";
import TopRank from "@/components/TopRank.vue";
import MyRank from "@/components/MyRank.vue";
import LiveItem from "@/components/LiveItem.vue";
2025-12-30 18:10:31 +08:00
2025-07-22 00:01:29 +08:00
import {
getAppConfig,
getRankListAPI,
getHomeData,
getMyDevicesAPI,
2025-12-31 13:39:16 +08:00
getDeviceBatteryAPI,
2025-07-22 00:01:29 +08:00
} from "@/apis";
2025-06-26 23:41:23 +08:00
import { topThreeColors } from "@/constants";
2026-01-12 16:21:32 +08:00
import { canEenter, capsuleHeight } from "@/util";
2025-12-31 13:39:16 +08:00
2025-05-26 16:28:13 +08:00
import useStore from "@/store";
2025-05-25 23:51:10 +08:00
import { storeToRefs } from "pinia";
2025-05-26 16:28:13 +08:00
const store = useStore();
2025-12-31 13:39:16 +08:00
const {
updateConfig,
updateUser,
updateDevice,
updateRank,
getLvlName,
updateOnline,
} = store;
const { user, device, rankData, online, game } = storeToRefs(store);
2025-12-31 13:39:16 +08:00
2026-01-13 11:35:36 +08:00
const isIOS = uni.getDeviceInfo().osName === "ios";
2025-06-12 00:24:14 +08:00
const showModal = ref(false);
2025-07-12 16:01:49 +08:00
const showGuide = ref(false);
2026-01-12 16:21:32 +08:00
const selected = ref(0);
2026-01-13 11:35:36 +08:00
const liveType = ref(0);
const liveTypes = {
大神赛: "../static/dashen.png",
新人王: "../static/xinren.png",
女神赛: "../static/nvshen.png",
};
2025-05-07 23:34:15 +08:00
2025-11-26 17:12:55 +08:00
const toPage = async (path) => {
2025-06-12 00:24:14 +08:00
if (!user.value.id) {
showModal.value = true;
2025-06-15 22:38:28 +08:00
return;
2025-05-30 16:14:17 +08:00
}
2025-12-31 13:39:16 +08:00
if (path === "/pages/first-try") {
2026-01-04 11:36:31 +08:00
if (canEenter(user.value, device.value, online.value, path)) {
await uni.$checkAudio();
} else {
return;
2025-06-15 22:38:28 +08:00
}
2025-11-26 17:12:55 +08:00
}
2025-12-31 13:39:16 +08:00
uni.navigateTo({ url: path });
2025-05-08 22:05:53 +08:00
};
2025-05-10 22:25:06 +08:00
2025-06-17 12:01:44 +08:00
const toRankListPage = () => {
uni.navigateTo({
2025-06-26 13:51:41 +08:00
url: "/pages/rank-list",
2025-06-17 12:01:44 +08:00
});
};
2025-07-19 00:03:12 +08:00
onShow(async () => {
2025-09-12 17:49:26 +08:00
const token = uni.getStorageSync(
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
);
2025-09-18 09:28:14 +08:00
const promises = [getRankListAPI()];
2025-07-22 09:36:38 +08:00
if (token) {
2025-09-18 09:28:14 +08:00
promises.push(getHomeData());
}
const [rankList, homeData] = await Promise.all(promises);
console.log("排行数据", rankList);
updateRank(rankList);
if (homeData) {
console.log("首页数据:", homeData);
if (homeData.user) {
updateUser(homeData.user);
2025-12-03 17:24:55 +08:00
if ("823,209,293,257".indexOf(homeData.user.id) !== -1) {
2025-12-03 13:56:01 +08:00
const show = uni.getStorageSync("show-the-user");
if (!show) {
showTheUser.value = true;
uni.setStorageSync("show-the-user", true);
}
}
2025-09-18 09:28:14 +08:00
if (homeData.user.trio <= 0) {
2025-07-22 00:01:29 +08:00
showGuide.value = true;
setTimeout(() => {
showGuide.value = false;
}, 3000);
}
const devices = await getMyDevicesAPI();
if (devices.bindings && devices.bindings.length) {
updateDevice(
devices.bindings[0].deviceId,
devices.bindings[0].deviceName
);
2026-01-07 15:12:18 +08:00
const data = await getDeviceBatteryAPI();
updateOnline(data.online);
2025-07-22 00:01:29 +08:00
}
2025-07-10 15:34:00 +08:00
}
2025-05-10 22:25:06 +08:00
}
});
2025-06-24 13:18:03 +08:00
2025-07-19 00:03:12 +08:00
onMounted(async () => {
const config = await getAppConfig();
updateConfig(config);
console.log("全局配置:", config);
2025-10-30 09:19:34 +08:00
});
2025-09-12 10:38:21 +08:00
onShareAppMessage(() => {
return {
2025-09-12 17:49:26 +08:00
title: "智能真弓:实时捕捉+毫秒级同步,弓箭选手全球竞技!", // 分享卡片的标题
2025-09-12 10:38:21 +08:00
path: "/pages/index", // 用户点击分享卡片后跳转的页面路径
2025-09-12 17:49:26 +08:00
imageUrl:
"https://static.shelingxingqiu.com/attachment/2025-09-12/dcqoz26q0268wxmzjg.png", // 分享卡片的配图,可以是本地或网络图片
2025-09-12 10:38:21 +08:00
};
});
onShareTimeline(() => {
return {
2025-09-12 17:49:26 +08:00
title: "智能真弓:实时捕捉+毫秒级同步,弓箭选手全球竞技!", // 分享到朋友圈的标题
2025-09-12 10:38:21 +08:00
query: "from=timeline", // 用户通过朋友圈点击后,在页面 onShow 的 options 中可以获取到的参数
2025-09-12 17:49:26 +08:00
imageUrl:
"https://static.shelingxingqiu.com/attachment/2025-09-12/dcqoz26q0268wxmzjg.png", // 分享到朋友圈的配图
2025-09-12 10:38:21 +08:00
};
});
2025-04-10 11:11:46 +08:00
</script>
<template>
2026-01-12 16:21:32 +08:00
<view
class="container"
:style="{
paddingTop: capsuleHeight + 'px',
height: 'calc(100vh - ' + capsuleHeight + 'px)',
}"
>
2026-01-13 11:35:36 +08:00
<view :style="{ flex: 1, overflow: 'hidden' }">
2026-01-12 16:21:32 +08:00
<image
src="https://static.shelingxingqiu.com/attachment/2026-01-12/dfmg11wd20o1bagd4k.png"
mode="widthFix"
class="top-bg"
/>
<view class="header">
<image
src="https://static.shelingxingqiu.com/attachment/2026-01-12/dfmf4cjlds7oxd0tqd.png"
mode="widthFix"
/>
</view>
2026-01-13 11:35:36 +08:00
<scroll-view
class="body"
scroll-y
:show-scrollbar="false"
:enhanced="true"
:bounces="false"
>
<view class="main-btns" :style="{ marginBottom: '10rpx' }">
<view @click="() => toPage('/pages/my-device')">
<image
src="https://static.shelingxingqiu.com/attachment/2026-01-12/dfmgwjhsjc19tl0t7c.png"
mode="widthFix"
/>
<view v-if="user.id" class="device-info">
<text v-if="!device.deviceId">绑定我的智能弓</text>
<text v-else-if="!online">设备离线</text>
<text v-else-if="online">设备在线</text>
</view>
</view>
<view class="main-sub-btns">
<view @click="() => toPage('/pages/first-try')">
<image
src="https://static.shelingxingqiu.com/attachment/2026-01-12/dfmgwjhren1tfefi7k.png"
mode="widthFix"
/>
</view>
<view @click="() => toPage('/pages/practise')">
<image
src="https://static.shelingxingqiu.com/attachment/2026-01-12/dfmgwjht6q8l8zcduq.png"
mode="widthFix"
/>
</view>
</view>
</view>
<view class="main-btns">
<view @click="() => toPage('/pages/ranking')">
<image
src="https://static.shelingxingqiu.com/attachment/2026-01-12/dfmgwjhsi4s5qa7hch.png"
mode="widthFix"
/>
</view>
<view @click="() => toPage('/pages/friend-battle')">
<image
src="https://static.shelingxingqiu.com/attachment/2026-01-12/dfmgwjht17th6vl9a6.png"
mode="widthFix"
/>
</view>
</view>
<NoticeBar />
<view class="rank-info">
<image
src="../static/trophy-bg.png"
mode="widthFix"
class="trophy-bg"
/>
<view class="rank-info-header">
<view>
<image src="../static/rank-title.png" mode="widthFix" />
<text>星球榜</text>
</view>
<button hover-class="none">
<text>更多榜单</text>
<image src="../static/enter.png" mode="widthFix" />
</button>
</view>
<view class="rank-info-body">
<view :style="{ width: '45%' }">
<TopRank />
</view>
<view :style="{ width: '55%' }">
<MyRank />
</view>
</view>
</view>
<view class="live-bar">
<button
hover-class="none"
v-for="(item, index) in Object.keys(liveTypes)"
:key="index"
@click="liveType = index"
:style="{
color: liveType === index ? '#fff' : '#fff9',
background:
liveType === index
? 'linear-gradient( 133deg, #FFD19A 0%, #A17636 100%)'
: '#252831',
}"
>
<image :src="liveTypes[item]" mode="widthFix" />
<text>{{ item }}</text>
</button>
</view>
<swiper
:current="liveType"
@change="(e) => (liveType = e.detail.current)"
>
<swiper-item>
<LiveItem />
</swiper-item>
<swiper-item>
<LiveItem />
</swiper-item>
<swiper-item>
<LiveItem />
</swiper-item>
</swiper>
</scroll-view>
2026-01-12 16:21:32 +08:00
<Signin :show="showModal" :onClose="() => (showModal = false)" />
</view>
2026-01-13 11:35:36 +08:00
<AppFooter
:selected="selected"
:onChange="(index) => (selected = index)"
:onSignin="() => (showModal = true)"
/>
2026-01-12 16:21:32 +08:00
<!-- <view class="top-theme">
2025-12-31 16:42:53 +08:00
<image
src="https://static.shelingxingqiu.com/attachment/2025-12-31/dfc9dxrq4xn7e6y2pp.png"
mode="widthFix"
/>
</view>
2025-07-02 17:21:44 +08:00
<view :style="{ padding: '12px 10px' }">
<view class="feature-grid">
<view class="bow-card">
2025-05-01 16:17:51 +08:00
<image
2025-12-31 13:39:16 +08:00
v-if="online"
2025-08-07 09:34:47 +08:00
src="https://static.shelingxingqiu.com/attachment/2025-08-07/dbvt1o6dvhr2rop3kn.webp"
2025-05-01 16:17:51 +08:00
mode="widthFix"
2025-07-02 17:21:44 +08:00
@click="() => toPage('/pages/my-device')"
2025-05-01 16:17:51 +08:00
/>
2025-12-31 13:39:16 +08:00
<image
v-else
2026-01-05 09:23:26 +08:00
src="https://static.shelingxingqiu.com/attachment/2026-01-04/dffohwtk1gwh0xfa6h.png"
2025-12-31 13:39:16 +08:00
mode="widthFix"
@click="() => toPage('/pages/my-device')"
/>
<block v-if="user.id">
<text v-if="!device.deviceId">绑定我的智能弓</text>
<text v-else-if="!online">设备离线</text>
<text v-else-if="online">设备在线</text>
</block>
2025-05-01 16:17:51 +08:00
<image
2025-07-30 17:38:48 +08:00
src="../static/first-try.png"
2025-05-01 16:17:51 +08:00
mode="widthFix"
2025-07-02 17:21:44 +08:00
@click="() => toPage('/pages/first-try')"
2025-05-01 16:17:51 +08:00
/>
2026-01-12 10:09:36 +08:00
<BubbleTip v-if="showGuide" :location="{ top: '60%', left: '47%' }">
2025-07-12 16:01:49 +08:00
<text>新人必刷</text>
<text>快来报到吧~</text>
</BubbleTip>
2025-07-02 17:21:44 +08:00
</view>
2025-07-30 17:38:48 +08:00
<view class="play-card">
<view @click="() => toPage('/pages/practise')">
<image src="../static/my-practise.png" mode="widthFix" />
</view>
<view @click="() => toPage('/pages/friend-battle')">
<image src="../static/friend-battle.png" mode="widthFix" />
</view>
2025-07-02 17:21:44 +08:00
</view>
</view>
<view class="ranking-section">
2025-10-01 12:57:34 +08:00
<image
src="https://static.shelingxingqiu.com/attachment/2025-09-25/dd1p9ci9v7frcrsxhj.png"
mode="widthFix"
/>
2025-07-02 17:21:44 +08:00
<button
class="into-btn"
@click="() => toPage('/pages/ranking')"
hover-class="none"
></button>
<view class="ranking-players" @click="toRankListPage">
<img src="../static/juezhanbang.png" mode="widthFix" />
<view class="divide-line"></view>
2025-10-11 15:37:05 +08:00
<view class="player-avatars">
<view
v-for="i in 6"
:key="i"
class="player-avatar"
:style="{
zIndex: 8 - i,
borderColor: rankData.rank[i - 1]
? topThreeColors[i - 1] || '#000'
: '#000',
}"
>
<image v-if="i === 1" src="../static/champ1.png" />
<image v-if="i === 2" src="../static/champ2.png" />
<image v-if="i === 3" src="../static/champ3.png" />
<view v-if="i > 3">{{ i }}</view>
<image
:src="
rankData.rank[i - 1]
? rankData.rank[i - 1].avatar
: '../static/user-icon-dark.png'
"
mode="aspectFill"
/>
</view>
<view class="more-players">
2025-07-02 17:21:44 +08:00
<text>{{ rankData.rank.length }}</text>
</view>
2025-05-01 16:17:51 +08:00
</view>
</view>
2025-07-30 17:38:48 +08:00
<view class="my-data">
<view @click="() => toPage('/pages/my-growth')">
<image src="../static/my-growth.png" mode="widthFix" />
</view>
2025-08-19 09:44:15 +08:00
<view @click="() => toPage('/pages/ranking')">
2025-07-30 17:38:48 +08:00
<view>
<text>段位</text>
2025-08-15 15:25:41 +08:00
<text>{{
2025-11-13 16:48:24 +08:00
user.rankLvl ? getLvlName(user.rankLvl) : "暂无"
2025-08-15 15:25:41 +08:00
}}</text>
2025-07-30 17:38:48 +08:00
</view>
<view>
<text>赛季平均环数</text>
2025-08-09 11:58:11 +08:00
<text>{{ user.avg_ring ? user.avg_ring + "环" : "暂无" }}</text>
2025-07-30 17:38:48 +08:00
</view>
<view>
<text>赛季胜率</text>
<text>{{
user.avg_win
? Number((user.avg_win * 100).toFixed(2)) + "%"
2025-08-09 11:58:11 +08:00
: "暂无"
2025-07-30 17:38:48 +08:00
}}</text>
</view>
</view>
</view>
2025-05-01 16:17:51 +08:00
</view>
2026-01-12 16:21:32 +08:00
</view> -->
</view>
2025-04-10 11:11:46 +08:00
</template>
2026-01-13 11:35:36 +08:00
<style scoped lang="scss">
2025-05-01 16:17:51 +08:00
.container {
2026-01-12 16:21:32 +08:00
width: 100vw;
2026-01-13 11:35:36 +08:00
height: 100vh;
2026-01-12 16:21:32 +08:00
display: flex;
flex-direction: column;
justify-content: space-between;
background-color: #000;
}
.top-bg {
2025-07-02 17:21:44 +08:00
width: 100%;
2026-01-12 16:21:32 +08:00
position: fixed;
top: 0;
left: 0;
2025-05-01 16:17:51 +08:00
}
2026-01-12 16:21:32 +08:00
.header {
height: 50px;
position: relative;
display: flex;
align-items: center;
padding-left: 30rpx;
}
.header > image {
width: 200rpx;
height: 50rpx;
}
.body {
2026-01-13 11:35:36 +08:00
width: calc(100vw - 50rpx);
height: calc(100% - 25rpx);
padding: 0 25rpx;
position: relative;
margin-bottom: 25rpx;
}
.main-btns {
width: 100%;
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20rpx;
}
.main-btns > view {
position: relative;
}
.main-btns image {
width: 100%;
}
.main-sub-btns {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.device-info {
position: absolute;
width: 100%;
bottom: 50rpx;
font-size: 24rpx;
color: #fff9;
display: flex;
justify-content: center;
}
.rank-info {
margin-top: 10rpx;
background: linear-gradient(180deg, #2f2d2b 0%, #252831 100%);
border-radius: 20rpx;
position: relative;
padding: 20rpx;
display: flex;
flex-direction: column;
margin-top: 20rpx;
}
.trophy-bg {
position: absolute;
top: 0;
right: 0;
width: 188rpx;
height: 192rpx;
}
.rank-info-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 30rpx;
}
.rank-info-header > view {
width: 186rpx;
height: 56rpx;
font-weight: 500;
font-size: 28rpx;
color: #ffffff;
}
.rank-info-header > view > image {
width: 100%;
height: 100%;
}
.rank-info-header > view > text {
line-height: 56rpx;
display: block;
transform: translate(75rpx, -65rpx);
}
.rank-info-header > button {
font-size: 20rpx;
color: #999999;
display: flex;
align-items: center;
}
.rank-info-header > button > image {
width: 30rpx;
height: 30rpx;
}
.rank-info-body {
display: flex;
align-items: center;
}
.rank-info-body > view:first-child {
border-right: 1rpx solid #e8e8e81a;
box-sizing: border-box;
}
.live-bar {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20rpx;
margin: 20rpx 0;
}
.live-bar > button {
display: flex;
align-items: center;
justify-content: center;
height: 68rpx;
border-radius: 34rpx;
font-weight: 600;
font-size: 28rpx;
}
.live-bar > button > image {
width: 46rpx;
height: 40rpx;
margin-right: 15rpx;
2026-01-12 16:21:32 +08:00
}
/* .feature-grid {
2025-07-30 17:38:48 +08:00
width: 100%;
display: flex;
margin-bottom: 5px;
2025-05-01 16:17:51 +08:00
}
2025-07-30 17:38:48 +08:00
.feature-grid > view {
2025-05-01 16:17:51 +08:00
position: relative;
2025-07-30 17:38:48 +08:00
display: flex;
flex-direction: column;
}
.bow-card {
width: 50%;
2026-01-05 09:23:26 +08:00
border-radius: 25rpx;
overflow: hidden;
2025-05-01 16:17:51 +08:00
}
.feature-grid > view > image {
width: 100%;
}
.bow-card > text {
position: absolute;
2026-01-05 09:23:26 +08:00
top: 66%;
2025-05-01 16:17:51 +08:00
left: 50%;
transform: translate(-50%, -50%);
2025-06-16 22:43:39 +08:00
white-space: nowrap;
2025-05-01 16:17:51 +08:00
font-size: 13px;
color: #b3b3b3;
}
2025-07-12 16:01:49 +08:00
.bow-card > image:nth-child(3) {
2025-07-15 17:10:56 +08:00
transform: translateY(-1px);
2025-05-01 16:17:51 +08:00
}
2025-07-30 17:38:48 +08:00
.play-card {
width: 48%;
margin-left: 2%;
2025-05-01 16:17:51 +08:00
}
2025-07-30 17:38:48 +08:00
.play-card > view > image {
2025-05-01 16:17:51 +08:00
width: 100%;
}
.ranking-section {
border-radius: 15px;
padding: 15px;
position: relative;
}
.ranking-section > image {
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: -1;
}
2025-06-19 01:55:40 +08:00
.into-btn {
position: absolute;
top: 40px;
left: calc(50% - 100px);
width: 200px;
height: 100px;
}
2025-05-01 16:17:51 +08:00
.ranking-players {
display: flex;
align-items: center;
padding-bottom: 20px;
2025-05-23 20:58:24 +08:00
margin-top: 42%;
2025-10-11 15:37:05 +08:00
border-bottom: 1rpx solid rgba(255, 255, 255, 0.2);
2025-05-01 16:17:51 +08:00
}
.ranking-players > image:first-child {
width: 28%;
2025-06-26 23:41:23 +08:00
transform: translateX(-10px) translateY(-8px);
2025-05-01 16:17:51 +08:00
}
.player-avatars {
display: flex;
align-items: center;
}
2025-06-25 00:09:53 +08:00
.divide-line {
width: 1px;
height: 35px;
background-color: #80808033;
margin-right: 8px;
}
2025-05-01 16:17:51 +08:00
.player-avatar,
.more-players {
2025-07-15 18:14:59 +08:00
width: 82rpx;
height: 82rpx;
2025-05-01 16:17:51 +08:00
border-radius: 50%;
2025-10-11 15:37:05 +08:00
margin-right: -20rpx;
border: 1rpx solid #312f35;
2025-05-01 16:17:51 +08:00
position: relative;
2025-07-15 18:14:59 +08:00
box-sizing: border-box;
2025-05-01 16:17:51 +08:00
}
.player-avatar > image:first-child,
.player-avatar > view:first-child {
position: absolute;
2025-10-11 15:37:05 +08:00
top: -24rpx;
left: 22rpx;
width: 32rpx;
height: 32rpx;
2025-05-01 16:17:51 +08:00
}
.player-avatar > view:first-child {
border-radius: 50%;
background: #777777;
text-align: center;
2025-06-25 00:09:53 +08:00
font-size: 10px;
line-height: 18px;
width: 18px;
height: 18px;
2025-07-15 17:10:56 +08:00
color: #fff;
2025-05-01 16:17:51 +08:00
}
.player-avatar > image:last-child {
width: 100%;
height: 100%;
border-radius: 50%;
}
.more-players {
background: #3c445a;
2025-06-25 00:09:53 +08:00
font-size: 9px;
2025-06-25 01:46:04 +08:00
line-height: 80rpx;
2025-06-25 00:09:53 +08:00
text-align: center;
2025-06-26 13:51:41 +08:00
z-index: 1;
2025-06-17 12:01:44 +08:00
}
.more-players > text {
2025-06-25 01:46:04 +08:00
margin-left: 2px;
2025-07-02 17:21:44 +08:00
color: #fff;
2025-05-01 16:17:51 +08:00
}
2025-07-30 17:38:48 +08:00
.my-data {
display: flex;
margin-top: 20px;
justify-content: space-between;
}
.my-data > view:first-child {
width: 28%;
}
.my-data > view:first-child > image {
width: 100%;
transform: translateX(-8px);
}
.my-data > view:nth-child(2) {
width: 68%;
font-size: 12px;
color: #fff6;
display: flex;
justify-content: space-between;
}
.my-data > view:nth-child(2) > view:nth-child(2) {
width: 38%;
}
.my-data > view:nth-child(2) > view {
width: 28%;
border-radius: 10px;
background: linear-gradient(180deg, #303b4c 30%, #2c384a 100%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.my-data > view:nth-child(2) > view > text:last-child {
color: #fff;
line-height: 25px;
2025-08-06 10:56:57 +08:00
font-weight: 500;
2025-07-30 17:38:48 +08:00
}
2025-12-31 16:42:53 +08:00
.top-theme {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 60px;
2026-01-05 09:23:26 +08:00
z-index: -1;
2025-12-31 16:42:53 +08:00
}
.top-theme > image {
width: 300rpx;
transform: translate(-4%, -14%);
2026-01-12 16:21:32 +08:00
} */
2025-04-10 11:11:46 +08:00
</style>