i
This commit is contained in:
@@ -1,10 +1,22 @@
|
||||
import type { UserConfigExport } from "@tarojs/cli";
|
||||
import type {UserConfigExport} from '@tarojs/cli'
|
||||
|
||||
export default {
|
||||
logger: {
|
||||
quiet: false,
|
||||
stats: true
|
||||
},
|
||||
mini: {},
|
||||
h5: {}
|
||||
logger: {
|
||||
quiet: false,
|
||||
stats: true
|
||||
},
|
||||
mini: {},
|
||||
h5: {
|
||||
devServer: {
|
||||
// proxy: {
|
||||
// '/api': {
|
||||
// target: 'http://localhost:3000',
|
||||
// changeOrigin: true,
|
||||
// pathRewrite: {
|
||||
// '^/api': ''
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
} satisfies UserConfigExport
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
export default defineAppConfig({
|
||||
pages: [
|
||||
'pages/index/index',
|
||||
'pages/game_list/yaotouzi/index',
|
||||
'pages/game_detail/index'
|
||||
'pages/yaotouzi/index/index',
|
||||
'pages/game_detail/index',
|
||||
'pages/yaotouzi/records/index'
|
||||
],
|
||||
window: {
|
||||
backgroundTextStyle: 'light',
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// 用于配置项目的一些常量,如接口地址、websocket地址等
|
||||
import Taro from "@tarojs/taro";
|
||||
import Taro from '@tarojs/taro'
|
||||
|
||||
export const app = {
|
||||
API_URL: () =>
|
||||
process.env.NODE_ENV === "production"
|
||||
? "https://game.jdt168.com/dice"
|
||||
: "http://game.jdt168.com/dice",
|
||||
process.env.NODE_ENV === 'production'
|
||||
? 'https://www.jdt168.com/dice'
|
||||
: 'https://www.jdt168.com/dice',
|
||||
API_WS: () =>
|
||||
process.env.NODE_ENV === "production"
|
||||
? `wss://game.jdt168.com/dice/home?uid=${Taro.getStorageSync('uid')}`
|
||||
: `ws://game.jdt168.com/dice/home?uid=${Taro.getStorageSync('uid')}`,
|
||||
};
|
||||
process.env.NODE_ENV === 'production'
|
||||
? `wss://www.jdt168.com/dice/home?uid=${Taro.getStorageSync('uid')}`
|
||||
: `wss://www.jdt168.com/dice/home?uid=${Taro.getStorageSync('uid')}`
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ const list = ref(['https://storage.360buyimg.com/jdc-article/NutUItaro34.jpg', '
|
||||
|
||||
const startGame = () => {
|
||||
Taro.navigateTo({
|
||||
url: '/pages/game_list/yaotouzi/index'
|
||||
url: '/pages/yaotouzi/index/index'
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,264 +0,0 @@
|
||||
<template>
|
||||
<view class="index">
|
||||
<!-- 公告 -->
|
||||
<view class="subColor tips"></view>
|
||||
<!-- 用户信息 -->
|
||||
<view class="subColor userInfo">
|
||||
<view class="left">
|
||||
<image src="https://img01.yzcdn.cn/vant/cat.jpeg"></image>
|
||||
<view class="userText">
|
||||
<view class="userName">YuanHuakk</view>
|
||||
<view class="userScore">积分:10000000</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="right">
|
||||
<view class="icon"></view>
|
||||
<view class="bean">1231321</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 游戏信息 -->
|
||||
<view class="subColor gameInfo">
|
||||
<view class="left">
|
||||
<image src="../../../static/tx.png"></image>
|
||||
<view class="game_box">
|
||||
<view class="gameName">第1000期开奖</view>
|
||||
<view class="lottery">
|
||||
<text class="text">3</text>
|
||||
<text class="text">4</text>
|
||||
<text class="text">6</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="right">
|
||||
<view class="btn">开奖记录</view>
|
||||
<view class="btn mt-15">投注记录</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 选项区 -->
|
||||
<view class="opt">
|
||||
<view class="subColor item" v-for="item in odds" :key="item.id">
|
||||
<view class="name">{{ item.name }}</view>
|
||||
<view class="odd">赢{{ item.odds }}倍</view>
|
||||
</view>
|
||||
</view>
|
||||
<view style="height: 8px;"></view>
|
||||
<view class="opt1">
|
||||
<view>
|
||||
<view class="subColor item">
|
||||
<view class="name">{{ odds1[0].name }}</view>
|
||||
<view class="odd">赢{{ odds1[0].odds }}倍</view>
|
||||
</view>
|
||||
<view class="subColor item">
|
||||
<view class="name">{{ odds1[1].name }}</view>
|
||||
<view class="odd">赢{{ odds1[1].odds }}倍</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="base">
|
||||
<view class="qz">
|
||||
{{ qzTitle }}
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<view class="subColor item">
|
||||
<view class="name">{{ odds1[2].name }}</view>
|
||||
<view class="odd">赢{{ odds1[2].odds }}倍</view>
|
||||
</view>
|
||||
<view class="subColor item">
|
||||
<view class="name">{{ odds1[3].name }}</view>
|
||||
<view class="odd">赢{{ odds1[3].odds }}倍</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view style="height: 4px;"></view>
|
||||
<view class="opt">
|
||||
<view class="subColor item" style="margin-bottom: 10px;" v-for="item in odd2" :key="item.id">
|
||||
<view class="name">{{ item.name }}</view>
|
||||
<view class="odd">赢{{ item.odds }}倍</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 底部操作栏 -->
|
||||
<view class="subColor bottomBar">
|
||||
<view class="btn1">重置</view>
|
||||
<view class="btn2">X100</view>
|
||||
<view class="btn3">投注</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref} from 'vue'
|
||||
import Taro from '@tarojs/taro'
|
||||
import {app} from '@/config'
|
||||
|
||||
|
||||
let ws: any = null;
|
||||
|
||||
const odds = ref([
|
||||
{
|
||||
id: 1,
|
||||
name: '1+1',
|
||||
odds: 1.98
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '2+2',
|
||||
odds: 1.98
|
||||
}, {
|
||||
id: 3,
|
||||
name: '3+3',
|
||||
odds: 1.98
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '4+4',
|
||||
odds: 1.98
|
||||
}, {
|
||||
id: 5,
|
||||
name: '5+5',
|
||||
odds: 1.98
|
||||
}
|
||||
])
|
||||
|
||||
const odds1 = ref([
|
||||
{
|
||||
id: 1,
|
||||
name: '大',
|
||||
odds: 2.98
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '小',
|
||||
odds: 2.98
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '单',
|
||||
odds: 2.98
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '双',
|
||||
odds: 2.98
|
||||
}
|
||||
])
|
||||
|
||||
const odd2 = ref([
|
||||
{
|
||||
id: 1,
|
||||
name: '和',
|
||||
odds: 2.98
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '6+6',
|
||||
odds: 1.98
|
||||
}, {
|
||||
id: 3,
|
||||
name: '3',
|
||||
odds: 1.98
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '4',
|
||||
odds: 1.98
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: '5',
|
||||
odds: 1.98
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: '6',
|
||||
odds: 1.98
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
name: '8',
|
||||
odds: 1.98
|
||||
}, {
|
||||
id: 9,
|
||||
name: '9',
|
||||
odds: 1.98
|
||||
}, {
|
||||
id: 10,
|
||||
name: '10',
|
||||
odds: 1.98
|
||||
}, {
|
||||
id: 11,
|
||||
name: '11',
|
||||
odds: 1.98
|
||||
}
|
||||
])
|
||||
|
||||
const qzTitle = ref('请投注')
|
||||
|
||||
Taro.useLoad(() => {
|
||||
init();
|
||||
})
|
||||
|
||||
const init = () => {
|
||||
ws = new WebSocket(`${app.API_WS()}`);
|
||||
ws.onopen = async () => {
|
||||
console.log("连接游戏服务器成功");
|
||||
|
||||
Taro.showToast({
|
||||
title: "连接游戏服务器成功",
|
||||
mask: true,
|
||||
icon: "none",
|
||||
});
|
||||
};
|
||||
|
||||
ws.onmessage = async (e: any) => {
|
||||
const res = JSON.parse(e.data);
|
||||
switch (res.code) {
|
||||
case 200:
|
||||
let num = Number(res.data);
|
||||
if (num === 1) {
|
||||
}
|
||||
break;
|
||||
case 401:
|
||||
Taro.showToast({
|
||||
title: "未登录",
|
||||
mask: true,
|
||||
icon: "none",
|
||||
});
|
||||
break;
|
||||
case 403:
|
||||
Taro.showToast({
|
||||
title: "未能操作",
|
||||
mask: true,
|
||||
icon: "none",
|
||||
});
|
||||
break;
|
||||
case 400:
|
||||
Taro.showToast({
|
||||
title: "豆子不足",
|
||||
mask: true,
|
||||
icon: "none",
|
||||
});
|
||||
break;
|
||||
case 5:
|
||||
Taro.showToast({
|
||||
title: "投注成功",
|
||||
mask: true,
|
||||
icon: "none",
|
||||
});
|
||||
break;
|
||||
}
|
||||
};
|
||||
ws.onerror = () => {
|
||||
console.log("连接游戏服务器失败");
|
||||
Taro.showToast({
|
||||
title: "连接游戏服务器失败,请退出重新进入游戏",
|
||||
mask: true,
|
||||
icon: "none",
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import './index.scss';
|
||||
</style>
|
||||
@@ -4,13 +4,15 @@
|
||||
height: 100%;
|
||||
|
||||
.tips {
|
||||
border-radius: 0;
|
||||
width: 100%;
|
||||
height: 80px;
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
.userInfo {
|
||||
width: 680px;
|
||||
margin: 20px auto;
|
||||
//margin: auto;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
@@ -54,13 +56,13 @@
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
padding: 15px;
|
||||
padding: 10px;
|
||||
|
||||
.icon {
|
||||
background-image: url("../../../static/dz.png");
|
||||
background-size: 100% 100%;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
@@ -136,8 +138,11 @@
|
||||
flex-wrap: wrap;
|
||||
|
||||
.item {
|
||||
width: 140px;
|
||||
width: 18%;
|
||||
text-align: center;
|
||||
//margin: auto 3px;
|
||||
border: 1px dashed #228960;
|
||||
position: relative;
|
||||
|
||||
.name {
|
||||
//font-size: 30px;
|
||||
@@ -147,6 +152,27 @@
|
||||
.odd {
|
||||
font-size: 25px;
|
||||
}
|
||||
|
||||
.mask {
|
||||
position: absolute;
|
||||
//background: #7950f2;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
border-radius: 10px;
|
||||
text-align: center;
|
||||
line-height: 100px;
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
|
||||
.text {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +186,9 @@
|
||||
width: 200px;
|
||||
margin-bottom: 10px;
|
||||
text-align: center;
|
||||
padding: 33px 0;
|
||||
padding: 31px 0;
|
||||
border: 1px dashed #228960;
|
||||
position: relative;
|
||||
|
||||
.name {
|
||||
font-size: 55px;
|
||||
@@ -170,6 +198,25 @@
|
||||
.odd {
|
||||
font-size: 25px;
|
||||
}
|
||||
|
||||
.mask {
|
||||
position: absolute;
|
||||
//background: #7950f2;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
border-radius: 10px;
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
|
||||
.text {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.base {
|
||||
@@ -181,6 +228,8 @@
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
.qz {
|
||||
background-image: url("../../../static/qz.png");
|
||||
@@ -260,3 +309,79 @@
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
// 虚线边框且闪烁3秒
|
||||
.flicker {
|
||||
animation: flicker 1s infinite;
|
||||
}
|
||||
|
||||
@keyframes flicker {
|
||||
0% {
|
||||
border: 1px dashed #228960;
|
||||
}
|
||||
50% {
|
||||
border: 1px dashed white;
|
||||
}
|
||||
100% {
|
||||
border: 1px dashed #228960;
|
||||
}
|
||||
}
|
||||
|
||||
.expanding-div {
|
||||
width: 10px;
|
||||
height: 90px;
|
||||
background-image: url("../../../static/qzzz.png");
|
||||
background-size: 100% 100%;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 55%;
|
||||
transform: translate(-50%, -50%);
|
||||
animation-name: rotate, expand;
|
||||
animation-duration: 2s, 3s;
|
||||
animation-delay: 0s, 2s;
|
||||
animation-timing-function: linear, ease-in-out;
|
||||
animation-fill-mode: forwards, forwards;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
line-height: 90px;
|
||||
color: red;
|
||||
}
|
||||
|
||||
@keyframes rotate {
|
||||
0% {
|
||||
top: -100%;
|
||||
transform: translate(-50%, -50%) rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%) rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes expand {
|
||||
from {
|
||||
width: 10px;
|
||||
}
|
||||
to {
|
||||
width: 200px;
|
||||
}
|
||||
}
|
||||
|
||||
// 倒计时动画
|
||||
.activeQz {
|
||||
animation: change-size 1s ease-in-out infinite;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@keyframes change-size {
|
||||
0% {
|
||||
opacity: 1;
|
||||
}
|
||||
90% {
|
||||
font-size: 300px;
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
473
src/pages/yaotouzi/index/index.vue
Normal file
473
src/pages/yaotouzi/index/index.vue
Normal file
@@ -0,0 +1,473 @@
|
||||
<template>
|
||||
<view class="index">
|
||||
<!-- 公告 -->
|
||||
<view class="subColor tips"></view>
|
||||
<!-- 用户信息 -->
|
||||
<view class="subColor userInfo">
|
||||
<view class="left">
|
||||
<image :src="userInfo.avatarUrl"></image>
|
||||
<view class="userText">
|
||||
<view class="userName">{{ userInfo.nickName || '用户' }}</view>
|
||||
<view class="userScore">积分: {{ userInfo.integral || 0 }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="right">
|
||||
<view class="icon"></view>
|
||||
<view class="bean">{{ userInfo.pulse || 0 }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 游戏信息 -->
|
||||
<view class="subColor gameInfo">
|
||||
<view class="left">
|
||||
<image src="../../../static/tx.png"></image>
|
||||
<view class="game_box">
|
||||
<view class="gameName">第{{ kJData[0]?.Periods || 0 }}期开奖</view>
|
||||
<view class="lottery">
|
||||
<text class="text">{{ kJData[0]?.Start || 0 }}</text>
|
||||
<text class="text">{{ kJData[0]?.End || 0 }}</text>
|
||||
<!-- <text class="text">6</text>-->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="right">
|
||||
<view class="btn" @click="toPage(1)">开奖记录</view>
|
||||
<view class="btn mt-15" @click="toPage(2)">投注记录</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 选项区 -->
|
||||
<view class="opt">
|
||||
<view class="subColor item" :class="{flicker: item.flicker}" v-for="item in odds" :key="item.id"
|
||||
@click.stop="addNum(item)">
|
||||
<view class="name">{{ item.name }}</view>
|
||||
<view class="odd">赢{{ item.odds }}倍</view>
|
||||
<view class="mask" v-if="item.status">
|
||||
<view class="text">{{ item.markNum }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view style="height: 8px"></view>
|
||||
<view class="opt1" v-if="odds1.length > 0">
|
||||
<view>
|
||||
<view class="subColor item" :class="{flicker: odds1[0].flicker}" @click.stop="addNum(odds1[0])">
|
||||
<view class="name">{{ odds1[0].name }}</view>
|
||||
<view class="odd">赢{{ odds1[0].odds }}倍</view>
|
||||
<view class="mask" v-if="odds1[0].status">
|
||||
<view class="text">{{ odds1[0].markNum }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="subColor item" :class="{flicker: odds1[1].flicker}" @click.stop="addNum(odds1[1])">
|
||||
<view class="name">{{ odds1[1].name }}</view>
|
||||
<view class="odd">赢{{ odds1[1].odds }}倍</view>
|
||||
<view class="mask" v-if="odds1[1].status">
|
||||
<view class="text">{{ odds1[1].markNum }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="base">
|
||||
<view class="qz">
|
||||
<view :class="{ activeQz: isExpanding }">
|
||||
{{ qzTitle }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="expanding-div" v-if="isShow">{{ nowKJInfo.Start }} - {{ nowKJInfo.End }}</view>
|
||||
</view>
|
||||
<view>
|
||||
<view class="subColor item" :class="{flicker: odds1[2].flicker}" @click.stop="addNum(odds1[2])">
|
||||
<view class="name">{{ odds1[2].name }}</view>
|
||||
<view class="odd">赢{{ odds1[2].odds }}倍</view>
|
||||
<view class="mask" v-if="odds1[2].status">
|
||||
<view class="text">{{ odds1[2].markNum }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="subColor item" :class="{flicker: odds1[3].flicker}" @click.stop="addNum(odds1[3])">
|
||||
<view class="name">{{ odds1[3].name }}</view>
|
||||
<view class="odd">赢{{ odds1[3].odds }}倍</view>
|
||||
<view class="mask" v-if="odds1[3].status">
|
||||
<view class="text">{{ odds1[3].markNum }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view style="height: 4px"></view>
|
||||
<view class="opt">
|
||||
<view
|
||||
class="subColor item"
|
||||
:class="{flicker: item.flicker}"
|
||||
style="margin-bottom: 10px"
|
||||
v-for="item in odds2"
|
||||
:key="item.id"
|
||||
@click.stop="addNum(item)"
|
||||
>
|
||||
<view class="name">{{ item.name }}</view>
|
||||
<view class="odd">赢{{ item.odds }}倍</view>
|
||||
<view class="mask" v-if="item.status">
|
||||
<view class="text">{{ item.markNum }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view style="width: 18%;"></view>
|
||||
</view>
|
||||
<!-- 底部操作栏 -->
|
||||
<view class="subColor bottomBar">
|
||||
<view class="btn1" @click="clearBet">重置</view>
|
||||
<view class="btn2" @click="changeOdd">X{{ oddVal }}</view>
|
||||
<view class="btn3" @click="verifyBet">投注</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref} from 'vue'
|
||||
import Taro from '@tarojs/taro'
|
||||
import {app} from '@/config'
|
||||
import {getGameOption, getKaiJiangList, getJfDz} from '@/api'
|
||||
|
||||
const ws = ref<null | WebSocket>(null)
|
||||
|
||||
// 是否显示开奖动画
|
||||
const isShow = ref(false)
|
||||
|
||||
// 是否开启文字放大动画
|
||||
const isExpanding = ref(false)
|
||||
|
||||
interface Odd {
|
||||
id?: number
|
||||
name?: string
|
||||
odds?: number
|
||||
markNum?: number
|
||||
status?: boolean
|
||||
flicker?: boolean
|
||||
}
|
||||
|
||||
const odds = ref<Odd[]>([])
|
||||
|
||||
const odds1 = ref<Odd[]>([])
|
||||
|
||||
const odds2 = ref<Odd[]>([])
|
||||
|
||||
const qzTitle = ref('请投注')
|
||||
|
||||
const nowKJInfo = ref<{
|
||||
Start?: string
|
||||
End?: string
|
||||
Periods?: number
|
||||
}>({})
|
||||
|
||||
const userInfo = ref<{
|
||||
pulse?: number
|
||||
integral?: number
|
||||
nickName?: string
|
||||
avatarUrl?: string
|
||||
}>({})
|
||||
|
||||
const zjObj = ref({})
|
||||
|
||||
const iMsgNum = ref(0)
|
||||
|
||||
Taro.useLoad(() => {
|
||||
initWs()
|
||||
initData()
|
||||
})
|
||||
|
||||
const initData = () => {
|
||||
qzTitle.value = '请投注'
|
||||
getOddList()
|
||||
getKJList()
|
||||
getUserInfo()
|
||||
}
|
||||
|
||||
const arr = ['2+2', '3+3', '4+4', '5+5', '6+6']
|
||||
const arr1 = ['大', '小', '单', '双']
|
||||
const arr2 = ['和', '3', '4', '5', '6', '8', '9', '10', '11']
|
||||
|
||||
// 投注列表
|
||||
const getOddList = async () => {
|
||||
const res = await getGameOption()
|
||||
odds.value = []
|
||||
odds1.value = []
|
||||
odds2.value = []
|
||||
res.data.data.forEach((item: any) => {
|
||||
const {name, ID, odds: odd} = item
|
||||
const newItem = {
|
||||
id: ID,
|
||||
name: name,
|
||||
odds: odd,
|
||||
markNum: 0,
|
||||
status: false,
|
||||
flicker: false
|
||||
}
|
||||
if (arr1.includes(name)) {
|
||||
odds1.value.push(newItem)
|
||||
} else if (arr.includes(name)) {
|
||||
odds.value.push(newItem)
|
||||
} else if (arr2.includes(name)) {
|
||||
odds2.value.push(newItem)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 获取个人信息
|
||||
const getUserInfo = async () => {
|
||||
const res = await getJfDz(Taro.getStorageSync('uid'))
|
||||
userInfo.value = res.data.data
|
||||
}
|
||||
|
||||
const kJData = ref<any>([])
|
||||
|
||||
// 开奖列表
|
||||
const getKJList = async () => {
|
||||
const res = await getKaiJiangList()
|
||||
kJData.value = res.data.data
|
||||
}
|
||||
|
||||
// 初始化游戏
|
||||
const initWs = () => {
|
||||
ws.value = new WebSocket(`${app.API_WS()}`)
|
||||
ws.value.onopen = async () => {
|
||||
Taro.showToast({
|
||||
title: '连接游戏服务器成功',
|
||||
mask: true,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
ws.value.onmessage = async (e: any) => {
|
||||
const res = JSON.parse(e.data)
|
||||
switch (res.code) {
|
||||
case 200:
|
||||
let num = Number(res.data)
|
||||
if (num === 5) {
|
||||
openDraw()
|
||||
}
|
||||
break
|
||||
case 401:
|
||||
Taro.showToast({
|
||||
title: '未登录',
|
||||
mask: true,
|
||||
icon: 'none'
|
||||
})
|
||||
break
|
||||
case 403:
|
||||
Taro.showToast({
|
||||
title: '未能操作',
|
||||
mask: true,
|
||||
icon: 'none'
|
||||
})
|
||||
break
|
||||
case 400:
|
||||
Taro.showToast({
|
||||
title: '豆子不足',
|
||||
mask: true,
|
||||
icon: 'none'
|
||||
})
|
||||
break
|
||||
case 5:
|
||||
Taro.showToast({
|
||||
title: '投注成功',
|
||||
mask: true,
|
||||
icon: 'none'
|
||||
})
|
||||
break
|
||||
case 666:
|
||||
iMsgNum.value++
|
||||
const newObj = JSON.parse(res.data)
|
||||
const arr = Object.values(newObj)
|
||||
// zjObj.value = {
|
||||
// ...zjObj.value,
|
||||
// ...newObj
|
||||
// }
|
||||
console.log(arr)
|
||||
if (iMsgNum.value === 19) {
|
||||
iMsgNum.value = 0
|
||||
startFlicker()
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
ws.value.onerror = () => {
|
||||
console.log('连接游戏服务器失败')
|
||||
Taro.showToast({
|
||||
title: '连接游戏服务器失败',
|
||||
mask: true,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const isKj = ref(false)
|
||||
// 开奖倒计时
|
||||
const openDraw = () => {
|
||||
isExpanding.value = true
|
||||
isKj.value = true
|
||||
for (let i = 5; i > 0; i--) {
|
||||
setTimeout(() => {
|
||||
// i <= 3 && (fontColor.value = "red");
|
||||
qzTitle.value = i.toString()
|
||||
}, 1000 * (5 - i))
|
||||
}
|
||||
setTimeout(async () => {
|
||||
isExpanding.value = false
|
||||
const res = await getKaiJiangList()
|
||||
nowKJInfo.value = res.data.data[0]
|
||||
qzTitle.value = `第${nowKJInfo.value?.Periods || 0}期开奖`
|
||||
playAminExpand()
|
||||
isKj.value = false
|
||||
}, 5000)
|
||||
}
|
||||
|
||||
const oddVal = ref(1)
|
||||
const changeOdd = () => {
|
||||
switch (oddVal.value) {
|
||||
case 1:
|
||||
oddVal.value = 10
|
||||
break
|
||||
case 10:
|
||||
oddVal.value = 100
|
||||
break
|
||||
case 100:
|
||||
oddVal.value = 1
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
const clearBet = () => {
|
||||
clearItems(odds.value)
|
||||
clearItems(odds1.value)
|
||||
clearItems(odds2.value)
|
||||
}
|
||||
|
||||
const clearItems = (items: any[]) => {
|
||||
items.forEach((item: any) => {
|
||||
item.markNum = 0
|
||||
item.status = false
|
||||
})
|
||||
}
|
||||
|
||||
const addNum = (item: any) => {
|
||||
if (item.markNum >= 1000) return Taro.showToast({
|
||||
title: '单注不能超过1000',
|
||||
icon: 'none'
|
||||
})
|
||||
if (isKj.value) return Taro.showToast({
|
||||
title: '正在开奖,不能下注',
|
||||
icon: 'none'
|
||||
})
|
||||
item.status = true
|
||||
item.markNum += oddVal.value
|
||||
}
|
||||
|
||||
// 投注
|
||||
const verifyBet = () => {
|
||||
let numCount = 0
|
||||
|
||||
odds.value.forEach((item: any) => {
|
||||
if (item.markNum > 0) {
|
||||
numCount += item.markNum
|
||||
}
|
||||
})
|
||||
|
||||
odds1.value.forEach((item: any) => {
|
||||
if (item.markNum > 0) {
|
||||
numCount += item.markNum
|
||||
}
|
||||
})
|
||||
|
||||
odds2.value.forEach((item: any) => {
|
||||
if (item.markNum > 0) {
|
||||
numCount += item.markNum
|
||||
}
|
||||
})
|
||||
|
||||
if (numCount === 0) return Taro.showToast({
|
||||
title: '请选择选项,再投注',
|
||||
icon: 'none'
|
||||
})
|
||||
|
||||
if (numCount > (userInfo.value?.pulse as number)) return Taro.showToast({
|
||||
title: '投注豆子不足',
|
||||
icon: 'none'
|
||||
})
|
||||
|
||||
const data: any[] = []
|
||||
|
||||
odds.value.forEach((item: any) => {
|
||||
if (item.markNum > 0) {
|
||||
data.push({
|
||||
bid: item.id,
|
||||
number: item.markNum,
|
||||
name: item.name
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
odds1.value.forEach((item: any) => {
|
||||
if (item.markNum > 0) {
|
||||
data.push({
|
||||
bid: item.id,
|
||||
number: item.markNum,
|
||||
name: item.name
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
odds2.value.forEach((item: any) => {
|
||||
if (item.markNum > 0) {
|
||||
data.push({
|
||||
bid: item.id,
|
||||
number: item.markNum,
|
||||
name: item.name
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
ws.value?.send(JSON.stringify({
|
||||
type: 1,
|
||||
data: data
|
||||
}))
|
||||
|
||||
getUserInfo()
|
||||
|
||||
qzTitle.value = '已投注'
|
||||
clearBet()
|
||||
}
|
||||
|
||||
// 前往开奖和投注记录
|
||||
const toPage = (type: number) => {
|
||||
Taro.navigateTo({
|
||||
url: `/pages/yaotouzi/records/index?type=${type}`
|
||||
})
|
||||
}
|
||||
|
||||
// 播放展开动画
|
||||
const playAminExpand = () => {
|
||||
isShow.value = true
|
||||
setTimeout(() => {
|
||||
isShow.value = false
|
||||
initData()
|
||||
}, 10000)
|
||||
}
|
||||
|
||||
// 开始闪烁
|
||||
const startFlicker = () => {
|
||||
console.log('开始闪烁', zjObj.value)
|
||||
flickerItems(odds.value)
|
||||
flickerItems(odds1.value)
|
||||
flickerItems(odds2.value)
|
||||
}
|
||||
|
||||
const flickerItems = (items: any[]) => {
|
||||
items.forEach((item) => {
|
||||
for (const val in zjObj.value) {
|
||||
if (item.name === zjObj.value[val]) {
|
||||
item.flicker = true
|
||||
setTimeout(() => {
|
||||
item.flicker = false
|
||||
}, 3000)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "./index.scss";
|
||||
</style>
|
||||
3
src/pages/yaotouzi/records/index.config.ts
Normal file
3
src/pages/yaotouzi/records/index.config.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export default definePageConfig({
|
||||
navigationBarBackgroundColor: '#23684B'
|
||||
})
|
||||
91
src/pages/yaotouzi/records/index.vue
Normal file
91
src/pages/yaotouzi/records/index.vue
Normal file
@@ -0,0 +1,91 @@
|
||||
<template>
|
||||
<view class="app">
|
||||
<template v-if="typeNum===1">
|
||||
<view class="card" v-for="(item,index) in list as any[]" :key="index">
|
||||
<view>
|
||||
<view>第{{ item.Periods }}期开奖:
|
||||
<text style="color: red">{{ item.Start }},{{ item.End }}</text>
|
||||
</view>
|
||||
<view class="sub">开奖时间:
|
||||
<text>{{ item.DrawTime }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class="card desc" v-for="(item,index) in list as any[]" :key="index">
|
||||
<view>
|
||||
<view>第{{ item.Periods }}期投注:
|
||||
</view>
|
||||
<view>
|
||||
点数:
|
||||
<text style="color: red">{{ item.Name }}</text>
|
||||
</view>
|
||||
<view class="sub">投注时间:
|
||||
<text>{{ item.DrawTime }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<view style="color: red" v-if="item.State === 1">+{{ item.DrawNum }}积分</view>
|
||||
<view style="color: green">-{{ item.Number }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref} from 'vue'
|
||||
import Taro from '@tarojs/taro'
|
||||
import {getKaiJiangList, getTzJl} from '@/api'
|
||||
|
||||
const list = ref<any[]>([])
|
||||
|
||||
const typeNum = ref(0)
|
||||
|
||||
Taro.useLoad((options) => {
|
||||
typeNum.value = Number(options.type)
|
||||
Taro.setNavigationBarTitle({title: options.type === '1' ? '开奖记录' : '投注记录'})
|
||||
getData(options.type)
|
||||
})
|
||||
|
||||
const getData = async (type: string) => {
|
||||
let res: any
|
||||
if (type === '1') {
|
||||
res = await getKaiJiangList()
|
||||
} else {
|
||||
res = await getTzJl(Taro.getStorageSync('uid'))
|
||||
}
|
||||
list.value = res.data.data
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 35px;
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 90%;
|
||||
padding: 20px;
|
||||
background-color: #fff;
|
||||
margin-top: 10px;
|
||||
border-radius: 10px;
|
||||
|
||||
.sub {
|
||||
margin-top: 10px;
|
||||
color: #555555;
|
||||
}
|
||||
}
|
||||
|
||||
.desc {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
</style>
|
||||
BIN
src/static/qzzz.png
Normal file
BIN
src/static/qzzz.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -8,7 +8,7 @@ export interface RequestParams {
|
||||
data?: string | object;
|
||||
}
|
||||
|
||||
const request = (request: RequestParams) => {
|
||||
const request = (request: RequestParams): Promise<any> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Taro.request({
|
||||
url: `${app.API_URL()}${request.url}`,
|
||||
|
||||
Reference in New Issue
Block a user