build(projects): 增加代码规范
This commit is contained in:
57
.cz-config.js
Normal file
57
.cz-config.js
Normal file
@@ -0,0 +1,57 @@
|
||||
module.exports = {
|
||||
types: [
|
||||
{ value: 'feat', name: 'feat: 新增功能' },
|
||||
{ value: 'fix', name: 'fix: 修复bug' },
|
||||
{ value: 'docs', name: 'docs: 文档变更' },
|
||||
{
|
||||
value: 'style',
|
||||
name: 'style: 代码格式(不影响功能,例如空格、分号等格式修正)',
|
||||
},
|
||||
{
|
||||
value: 'refactor',
|
||||
name: 'refactor: 代码重构(不包括 bug 修复、功能新增)',
|
||||
},
|
||||
{ value: 'perf', name: 'perf: 性能优化' },
|
||||
{ value: 'test', name: 'test: 添加、修改测试用例' },
|
||||
{
|
||||
value: 'build',
|
||||
name: 'build: 构建流程、外部依赖变更(如升级 npm 包、修改 脚手架 配置等)',
|
||||
},
|
||||
{ value: 'ci', name: 'ci: 修改 CI 配置、脚本' },
|
||||
{
|
||||
value: 'chore',
|
||||
name: 'chore: 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)',
|
||||
},
|
||||
{ value: 'revert', name: 'revert: 回滚 commit' },
|
||||
{ value: 'wip', name: 'wip: 开发中' },
|
||||
{ value: 'mod', name: 'mod: 不确定分类的修改' },
|
||||
{ value: 'release', name: 'release: 发布' },
|
||||
],
|
||||
scopes: [
|
||||
['custom', '自定义'],
|
||||
['projects', '项目搭建'],
|
||||
['components', '组件相关'],
|
||||
['utils', 'utils 相关'],
|
||||
['styles', '样式相关'],
|
||||
['deps', '项目依赖'],
|
||||
['other', '其他修改'],
|
||||
].map(([value, description]) => {
|
||||
return {
|
||||
value,
|
||||
name: `${value.padEnd(30)} (${description})`,
|
||||
}
|
||||
}),
|
||||
messages: {
|
||||
type: '确保本次提交遵循 Angular 规范!选择你要提交的类型:\n',
|
||||
scope: '选择一个 scope(可选):',
|
||||
customScope: '请输入自定义的 scope:',
|
||||
subject: '填写简短精炼的变更描述:',
|
||||
body: '填写更加详细的变更描述(可选)。使用 "|" 换行:',
|
||||
breaking: '列举非兼容性重大的变更(可选):',
|
||||
footer: '列举出所有变更的 Issues Closed(可选)。 例如: #31, #34:',
|
||||
confirmCommit: '确认提交?',
|
||||
},
|
||||
allowBreakingChanges: ['feat', 'fix'],
|
||||
subjectLimit: 100,
|
||||
breaklineChar: '|',
|
||||
}
|
||||
4
.husky/commit-msg
Normal file
4
.husky/commit-msg
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
npx --no -- commitlint --edit "$1"
|
||||
4
.husky/pre-commit
Normal file
4
.husky/pre-commit
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
npm run lint:staged
|
||||
7
.prettierrc.json
Normal file
7
.prettierrc.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"printWidth": 100,
|
||||
"singleQuote": true,
|
||||
"semi": false,
|
||||
"endOfLine": "lf",
|
||||
"htmlWhitespaceSensitivity": "ignore"
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
import TestUtils from '@tarojs/test-utils-vue3'
|
||||
|
||||
describe('Testing', () => {
|
||||
|
||||
test('Test', async () => {
|
||||
const testUtils = new TestUtils()
|
||||
await testUtils.createApp()
|
||||
await testUtils.PageLifecycle.onShow()
|
||||
expect(testUtils.html()).toMatchSnapshot()
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
|
||||
module.exports = {
|
||||
presets: [
|
||||
['taro', {
|
||||
framework: 'vue3',
|
||||
ts: true
|
||||
}]
|
||||
]
|
||||
[
|
||||
'taro',
|
||||
{
|
||||
framework: 'vue3',
|
||||
ts: true,
|
||||
},
|
||||
],
|
||||
],
|
||||
}
|
||||
|
||||
26
commitlint.config.js
Normal file
26
commitlint.config.js
Normal file
@@ -0,0 +1,26 @@
|
||||
module.exports = {
|
||||
ignores: [(commit) => commit.includes('init')],
|
||||
extends: ['@commitlint/config-conventional'],
|
||||
rules: {
|
||||
'type-enum': [
|
||||
2,
|
||||
'always',
|
||||
[
|
||||
'feat',
|
||||
'fix',
|
||||
'docs',
|
||||
'style',
|
||||
'refactor',
|
||||
'perf',
|
||||
'test',
|
||||
'build',
|
||||
'ci',
|
||||
'chore',
|
||||
'revert',
|
||||
'wip',
|
||||
'mod',
|
||||
'release',
|
||||
],
|
||||
],
|
||||
},
|
||||
}
|
||||
@@ -1,22 +1,22 @@
|
||||
import type {UserConfigExport} from '@tarojs/cli'
|
||||
import type { UserConfigExport } from '@tarojs/cli'
|
||||
|
||||
export default {
|
||||
logger: {
|
||||
quiet: false,
|
||||
stats: true
|
||||
logger: {
|
||||
quiet: false,
|
||||
stats: true,
|
||||
},
|
||||
mini: {},
|
||||
h5: {
|
||||
devServer: {
|
||||
// proxy: {
|
||||
// '/api': {
|
||||
// target: 'http://localhost:3000',
|
||||
// changeOrigin: true,
|
||||
// pathRewrite: {
|
||||
// '^/api': ''
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
},
|
||||
mini: {},
|
||||
h5: {
|
||||
devServer: {
|
||||
// proxy: {
|
||||
// '/api': {
|
||||
// target: 'http://localhost:3000',
|
||||
// changeOrigin: true,
|
||||
// pathRewrite: {
|
||||
// '^/api': ''
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
},
|
||||
} satisfies UserConfigExport
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {defineConfig, type UserConfigExport} from '@tarojs/cli'
|
||||
import { defineConfig, type UserConfigExport } from '@tarojs/cli'
|
||||
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'
|
||||
import devConfig from './dev'
|
||||
import prodConfig from './prod'
|
||||
@@ -13,7 +13,7 @@ export default defineConfig(async (merge, {}) => {
|
||||
640: 2.34 / 2,
|
||||
750: 1,
|
||||
375: 2,
|
||||
828: 1.81 / 2
|
||||
828: 1.81 / 2,
|
||||
},
|
||||
sourceRoot: 'src',
|
||||
outputRoot: 'dist',
|
||||
@@ -21,77 +21,77 @@ export default defineConfig(async (merge, {}) => {
|
||||
defineConstants: {},
|
||||
copy: {
|
||||
patterns: [],
|
||||
options: {}
|
||||
options: {},
|
||||
},
|
||||
framework: 'vue3',
|
||||
compiler: 'webpack5',
|
||||
cache: {
|
||||
enable: true // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
|
||||
enable: true, // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
|
||||
},
|
||||
mini: {
|
||||
postcss: {
|
||||
pxtransform: {
|
||||
enable: true,
|
||||
config: {}
|
||||
config: {},
|
||||
},
|
||||
url: {
|
||||
enable: true,
|
||||
config: {
|
||||
limit: 1024 // 设定转换尺寸上限
|
||||
}
|
||||
limit: 1024, // 设定转换尺寸上限
|
||||
},
|
||||
},
|
||||
cssModules: {
|
||||
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
|
||||
config: {
|
||||
namingPattern: 'module', // 转换模式,取值为 global/module
|
||||
generateScopedName: '[name]__[local]___[hash:base64:5]'
|
||||
}
|
||||
}
|
||||
generateScopedName: '[name]__[local]___[hash:base64:5]',
|
||||
},
|
||||
},
|
||||
},
|
||||
webpackChain(chain) {
|
||||
chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
|
||||
}
|
||||
},
|
||||
},
|
||||
h5: {
|
||||
publicPath: '/public/',
|
||||
staticDirectory: 'static',
|
||||
router: {
|
||||
mode: 'hash'
|
||||
mode: 'hash',
|
||||
},
|
||||
output: {
|
||||
filename: 'js/[name].[hash:8].js',
|
||||
chunkFilename: 'js/[name].[chunkhash:8].js'
|
||||
chunkFilename: 'js/[name].[chunkhash:8].js',
|
||||
},
|
||||
miniCssExtractPluginOption: {
|
||||
ignoreOrder: true,
|
||||
filename: 'css/[name].[hash].css',
|
||||
chunkFilename: 'css/[name].[chunkhash].css'
|
||||
chunkFilename: 'css/[name].[chunkhash].css',
|
||||
},
|
||||
postcss: {
|
||||
autoprefixer: {
|
||||
enable: true,
|
||||
config: {}
|
||||
config: {},
|
||||
},
|
||||
cssModules: {
|
||||
enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
|
||||
config: {
|
||||
namingPattern: 'module', // 转换模式,取值为 global/module
|
||||
generateScopedName: '[name]__[local]___[hash:base64:5]'
|
||||
}
|
||||
}
|
||||
generateScopedName: '[name]__[local]___[hash:base64:5]',
|
||||
},
|
||||
},
|
||||
},
|
||||
webpackChain(chain) {
|
||||
chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
|
||||
}
|
||||
},
|
||||
},
|
||||
rn: {
|
||||
appName: 'taroDemo',
|
||||
postcss: {
|
||||
cssModules: {
|
||||
enable: false // 默认为 false,如需使用 css modules 功能,则设为 true
|
||||
}
|
||||
}
|
||||
}
|
||||
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
// 本地开发构建配置(不混淆压缩)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { UserConfigExport } from "@tarojs/cli";
|
||||
import type { UserConfigExport } from '@tarojs/cli'
|
||||
|
||||
export default {
|
||||
mini: {},
|
||||
@@ -29,5 +29,5 @@ export default {
|
||||
// postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') })
|
||||
// }))
|
||||
// }
|
||||
}
|
||||
},
|
||||
} satisfies UserConfigExport
|
||||
|
||||
@@ -2,5 +2,5 @@ const defineJestConfig = require('@tarojs/test-utils-vue3/dist/jest.js').default
|
||||
|
||||
module.exports = defineJestConfig({
|
||||
testEnvironment: 'jsdom',
|
||||
testMatch: ['<rootDir>/__tests__/?(*.)+(spec|test).[jt]s?(x)']
|
||||
testMatch: ['<rootDir>/__tests__/?(*.)+(spec|test).[jt]s?(x)'],
|
||||
})
|
||||
|
||||
26
package.json
26
package.json
@@ -29,13 +29,31 @@
|
||||
"dev:qq": "npm run build:qq -- --watch",
|
||||
"dev:jd": "npm run build:jd -- --watch",
|
||||
"dev:quickapp": "npm run build:quickapp -- --watch",
|
||||
"test": "jest"
|
||||
"test": "jest",
|
||||
"lint": "eslint --ext .ts,.vue .",
|
||||
"lint:fix": "eslint --fix --ext .ts,.vue .",
|
||||
"lint:staged": "lint-staged",
|
||||
"prepare": "husky install",
|
||||
"preview": "vite preview",
|
||||
"cz": "cz",
|
||||
"lf": "npx prettier --write --end-of-line lf ."
|
||||
},
|
||||
"browserslist": [
|
||||
"last 3 versions",
|
||||
"Android >= 4.1",
|
||||
"ios >= 8"
|
||||
],
|
||||
"lint-staged": {
|
||||
"*.{js,vue}": [
|
||||
"eslint --ext .ts,.vue .",
|
||||
"npx prettier --write --end-of-line lf ."
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "node_modules/cz-customizable"
|
||||
}
|
||||
},
|
||||
"author": "",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.22.11",
|
||||
@@ -56,6 +74,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.22.11",
|
||||
"@commitlint/cli": "^18.2.0",
|
||||
"@commitlint/config-conventional": "^18.1.0",
|
||||
"@tarojs/cli": "3.6.15",
|
||||
"@tarojs/taro-loader": "3.6.15",
|
||||
"@tarojs/test-utils-vue3": "^0.1.1",
|
||||
@@ -68,12 +88,16 @@
|
||||
"@vue/babel-plugin-jsx": "^1.1.5",
|
||||
"@vue/compiler-sfc": "^3.3.4",
|
||||
"babel-preset-taro": "3.6.15",
|
||||
"commitizen": "^4.3.0",
|
||||
"css-loader": "6.8.1",
|
||||
"cz-customizable": "^7.0.0",
|
||||
"eslint": "^8.48.0",
|
||||
"eslint-config-taro": "3.6.15",
|
||||
"eslint-plugin-vue": "^9.17.0",
|
||||
"husky": "^8.0.0",
|
||||
"jest": "^29.6.4",
|
||||
"jest-environment-jsdom": "^29.6.4",
|
||||
"lint-staged": "^15.0.2",
|
||||
"postcss": "^8.4.29",
|
||||
"style-loader": "3.3.3",
|
||||
"stylelint": "^15.10.3",
|
||||
|
||||
24793
pnpm-lock.yaml
generated
24793
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,17 @@
|
||||
import request from "@/utils/request";
|
||||
import request from '@/utils/request'
|
||||
|
||||
export const getGameOption = () =>
|
||||
request({
|
||||
url: "/betting",
|
||||
method: "GET",
|
||||
});
|
||||
url: '/betting',
|
||||
method: 'GET',
|
||||
})
|
||||
|
||||
export const getKaiJiangList = () => request({url: "/draw", method: "GET"});
|
||||
export const getKaiJiangList = () => request({ url: '/draw', method: 'GET' })
|
||||
|
||||
// 用户信息
|
||||
export const getJfDz = (uid: string) =>
|
||||
request({url: `/userBettingInfo?uid=${uid}`, method: "GET"});
|
||||
request({ url: `/userBettingInfo?uid=${uid}`, method: 'GET' })
|
||||
|
||||
// 用户投注记录
|
||||
export const getTzJl = (uid: string) =>
|
||||
request({url: `/userBettingRecord?uid=${uid}`, method: "GET"});
|
||||
request({ url: `/userBettingRecord?uid=${uid}`, method: 'GET' })
|
||||
|
||||
@@ -5,13 +5,13 @@ export default defineAppConfig({
|
||||
'pages/game_detail/index',
|
||||
'pages/yaotouzi/records/index',
|
||||
'pages/balloon/index/index',
|
||||
'/pages/balloon/records/index'
|
||||
'/pages/balloon/records/index',
|
||||
],
|
||||
window: {
|
||||
backgroundTextStyle: 'light',
|
||||
navigationBarBackgroundColor: '#fff',
|
||||
navigationBarTitleText: 'Game',
|
||||
navigationBarTextStyle: 'black'
|
||||
navigationBarTextStyle: 'black',
|
||||
},
|
||||
animation: false
|
||||
animation: false,
|
||||
})
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import {createApp} from 'vue'
|
||||
import { createApp } from 'vue'
|
||||
import './app.scss'
|
||||
|
||||
const App = createApp({
|
||||
onShow() {
|
||||
},
|
||||
onShow() {},
|
||||
// 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖
|
||||
})
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// 用于配置项目的一些常量,如接口地址、websocket地址等
|
||||
import Taro from "@tarojs/taro";
|
||||
import Taro from '@tarojs/taro'
|
||||
|
||||
export const app = {
|
||||
API_URL: () => `${process.env.TARO_APP_API}`,
|
||||
API_WS: () =>
|
||||
`${process.env.TARO_APP_WS}?uid=${Taro.getStorageSync("uid")}&game_id=${
|
||||
Taro.getStorageSync("gameItem").ID
|
||||
`${process.env.TARO_APP_WS}?uid=${Taro.getStorageSync('uid')}&game_id=${
|
||||
Taro.getStorageSync('gameItem').ID
|
||||
}`,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-touch-fullscreen" content="yes">
|
||||
<meta name="format-detection" content="telephone=no,address=no">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="white">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
|
||||
<meta http-equiv="Cache-control" content="no-cache">
|
||||
<title>newGameHome</title>
|
||||
<script><%= htmlWebpackPlugin.options.script %></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
||||
<meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-touch-fullscreen" content="yes" />
|
||||
<meta name="format-detection" content="telephone=no,address=no" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="white" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
<meta http-equiv="Cache-control" content="no-cache" />
|
||||
<title>newGameHome</title>
|
||||
<script>
|
||||
<%= htmlWebpackPlugin.options.script %>
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '吹气球'
|
||||
})
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '吹气球',
|
||||
})
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
.container {
|
||||
box-sizing: border-box;
|
||||
height: 100vh;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.time {
|
||||
margin: 100px;
|
||||
}
|
||||
|
||||
.balloon-box {
|
||||
background-image: url("../../../static/balloon.png");
|
||||
background-size: cover;
|
||||
width: 200px;
|
||||
height: 300px;
|
||||
margin: 100px;
|
||||
}
|
||||
|
||||
.bottom-box {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
margin: 10px;
|
||||
width: 80%;
|
||||
|
||||
.input {
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid grey;
|
||||
}
|
||||
|
||||
.box {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
.btn {
|
||||
margin: 10px 0;
|
||||
width: 45%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.container {
|
||||
box-sizing: border-box;
|
||||
height: 100vh;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.time {
|
||||
margin: 100px;
|
||||
}
|
||||
|
||||
.balloon-box {
|
||||
background-image: url('../../../static/balloon.png');
|
||||
background-size: cover;
|
||||
width: 200px;
|
||||
height: 300px;
|
||||
margin: 100px;
|
||||
}
|
||||
|
||||
.bottom-box {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
margin: 10px;
|
||||
width: 80%;
|
||||
|
||||
.input {
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid grey;
|
||||
}
|
||||
|
||||
.box {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
.btn {
|
||||
margin: 10px 0;
|
||||
width: 45%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,192 +1,181 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import Taro from "@tarojs/taro";
|
||||
import utils from "@/utils";
|
||||
|
||||
const val = ref("");
|
||||
|
||||
const timeStr = ref("0");
|
||||
|
||||
const betVal = ref(100);
|
||||
|
||||
const count = ref(1);
|
||||
|
||||
const zoom = ref(1);
|
||||
|
||||
const isBalloon = ref(true);
|
||||
|
||||
const ws = new WebSocket(
|
||||
`${process.env.TARO_APP_BALLOON_WS}?uid=${Taro.getStorageSync(
|
||||
"uid"
|
||||
)}&game_id=${Taro.getStorageSync("gameItem").ID}`
|
||||
);
|
||||
|
||||
ws.onopen = () => {
|
||||
Taro.showToast({
|
||||
title: "连接游戏服务器成功",
|
||||
mask: true,
|
||||
icon: "none",
|
||||
});
|
||||
};
|
||||
|
||||
ws.onmessage = (message) => {
|
||||
const res = JSON.parse(message.data);
|
||||
switch (res.code) {
|
||||
case 200:
|
||||
timeStr.value = res.data;
|
||||
break;
|
||||
case 5:
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
});
|
||||
break;
|
||||
case 400:
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
});
|
||||
break;
|
||||
case 100:
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
});
|
||||
break;
|
||||
default:
|
||||
startFun(res.name);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
const changeBet = () => {
|
||||
switch (betVal.value) {
|
||||
case 100:
|
||||
betVal.value = 1000;
|
||||
break;
|
||||
case 1000:
|
||||
betVal.value = 10000;
|
||||
break;
|
||||
case 10000:
|
||||
betVal.value = 100;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
const startBet = () => {
|
||||
if (!val.value)
|
||||
return Taro.showToast({
|
||||
title: "请输入秒数",
|
||||
icon: "none",
|
||||
});
|
||||
if (Number(val.value) > 13) {
|
||||
val.value = "13";
|
||||
Taro.showToast({
|
||||
title: "秒数不能超过13",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
type: 1,
|
||||
data: {
|
||||
number: betVal.value * count.value,
|
||||
second: Number(val.value),
|
||||
},
|
||||
})
|
||||
);
|
||||
setTimeout(() => {
|
||||
getUserInfo();
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const clear = () => {
|
||||
count.value = 1;
|
||||
val.value = "";
|
||||
};
|
||||
|
||||
const startFun = (num: number) => {
|
||||
let count = 1;
|
||||
for (let i = 0; i < num; i++) {
|
||||
setTimeout(() => {
|
||||
count++;
|
||||
zoom.value += 0.1;
|
||||
if (count === num) {
|
||||
isBalloon.value = false;
|
||||
setTimeout(() => {
|
||||
isBalloon.value = true;
|
||||
zoom.value = 1;
|
||||
}, 1000);
|
||||
}
|
||||
}, 1000 * i);
|
||||
}
|
||||
};
|
||||
|
||||
Taro.useDidShow(() => {
|
||||
getUserInfo();
|
||||
});
|
||||
|
||||
const douzi = ref(0);
|
||||
|
||||
const getUserInfo = async () => {
|
||||
Taro.request({
|
||||
url: `${
|
||||
process.env.TARO_APP_BALLOON_API
|
||||
}/userBalloonInfo?uid=${Taro.getStorageSync("uid")}`,
|
||||
method: "GET",
|
||||
success: ({ data: res }) => {
|
||||
douzi.value = res.data.data.pulse;
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const toPage = (type: number) => {
|
||||
Taro.navigateTo({
|
||||
url: `/pages/balloon/records/index?type=${type}`,
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="header">
|
||||
<view>豆子:{{ douzi }}</view>
|
||||
<view @click="utils.vibrateShort(() => toPage(1))">开奖记录</view>
|
||||
<view @click="utils.vibrateShort(() => toPage(2))">投注记录</view>
|
||||
</view>
|
||||
<view class="time">开奖倒计时:{{ timeStr }}</view>
|
||||
<view
|
||||
v-if="isBalloon"
|
||||
class="balloon-box"
|
||||
:style="{
|
||||
transform: `scale(${zoom})`,
|
||||
transition: 'transform 0.5s',
|
||||
}"
|
||||
></view>
|
||||
<view v-else>气球爆炸了!</view>
|
||||
<view class="bottom-box">
|
||||
<input
|
||||
class="input"
|
||||
type="number"
|
||||
v-model="val"
|
||||
placeholder="请输入秒数,秒数不能超过13"
|
||||
/>
|
||||
<view class="box">
|
||||
<button class="btn" type="primary" @click="count++">
|
||||
X{{ count }}
|
||||
</button>
|
||||
<button class="btn" type="primary" @click="changeBet">
|
||||
X{{ betVal }}
|
||||
</button>
|
||||
</view>
|
||||
<view class="box">
|
||||
<button class="btn" type="primary" @click="clear">重置</button>
|
||||
<button class="btn" type="primary" @click="startBet">吹</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
@import "./index.scss";
|
||||
</style>
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import Taro from '@tarojs/taro'
|
||||
import utils from '@/utils'
|
||||
|
||||
const val = ref('')
|
||||
|
||||
const timeStr = ref('0')
|
||||
|
||||
const betVal = ref(100)
|
||||
|
||||
const count = ref(1)
|
||||
|
||||
const zoom = ref(1)
|
||||
|
||||
const isBalloon = ref(true)
|
||||
|
||||
const ws = new WebSocket(
|
||||
`${process.env.TARO_APP_BALLOON_WS}?uid=${Taro.getStorageSync('uid')}&game_id=${
|
||||
Taro.getStorageSync('gameItem').ID
|
||||
}`
|
||||
)
|
||||
|
||||
ws.onopen = () => {
|
||||
Taro.showToast({
|
||||
title: '连接游戏服务器成功',
|
||||
mask: true,
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
|
||||
ws.onmessage = (message) => {
|
||||
const res = JSON.parse(message.data)
|
||||
switch (res.code) {
|
||||
case 200:
|
||||
timeStr.value = res.data
|
||||
break
|
||||
case 5:
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
})
|
||||
break
|
||||
case 400:
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
})
|
||||
break
|
||||
case 100:
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
})
|
||||
break
|
||||
default:
|
||||
startFun(res.name)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
const changeBet = () => {
|
||||
switch (betVal.value) {
|
||||
case 100:
|
||||
betVal.value = 1000
|
||||
break
|
||||
case 1000:
|
||||
betVal.value = 10000
|
||||
break
|
||||
case 10000:
|
||||
betVal.value = 100
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
const startBet = () => {
|
||||
if (!val.value)
|
||||
return Taro.showToast({
|
||||
title: '请输入秒数',
|
||||
icon: 'none',
|
||||
})
|
||||
if (Number(val.value) > 13) {
|
||||
val.value = '13'
|
||||
Taro.showToast({
|
||||
title: '秒数不能超过13',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
type: 1,
|
||||
data: {
|
||||
number: betVal.value * count.value,
|
||||
second: Number(val.value),
|
||||
},
|
||||
})
|
||||
)
|
||||
setTimeout(() => {
|
||||
getUserInfo()
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
const clear = () => {
|
||||
count.value = 1
|
||||
val.value = ''
|
||||
}
|
||||
|
||||
const startFun = (num: number) => {
|
||||
let count = 1
|
||||
for (let i = 0; i < num; i++) {
|
||||
setTimeout(() => {
|
||||
count++
|
||||
zoom.value += 0.1
|
||||
if (count === num) {
|
||||
isBalloon.value = false
|
||||
setTimeout(() => {
|
||||
isBalloon.value = true
|
||||
zoom.value = 1
|
||||
}, 1000)
|
||||
}
|
||||
}, 1000 * i)
|
||||
}
|
||||
}
|
||||
|
||||
Taro.useDidShow(() => {
|
||||
getUserInfo()
|
||||
})
|
||||
|
||||
const douzi = ref(0)
|
||||
|
||||
const getUserInfo = async () => {
|
||||
Taro.request({
|
||||
url: `${process.env.TARO_APP_BALLOON_API}/userBalloonInfo?uid=${Taro.getStorageSync('uid')}`,
|
||||
method: 'GET',
|
||||
success: ({ data: res }) => {
|
||||
douzi.value = res.data.data.pulse
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const toPage = (type: number) => {
|
||||
Taro.navigateTo({
|
||||
url: `/pages/balloon/records/index?type=${type}`,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="header">
|
||||
<view>豆子:{{ douzi }}</view>
|
||||
<view @click="utils.vibrateShort(() => toPage(1))">开奖记录</view>
|
||||
<view @click="utils.vibrateShort(() => toPage(2))">投注记录</view>
|
||||
</view>
|
||||
<view class="time">开奖倒计时:{{ timeStr }}</view>
|
||||
<view
|
||||
v-if="isBalloon"
|
||||
class="balloon-box"
|
||||
:style="{
|
||||
transform: `scale(${zoom})`,
|
||||
transition: 'transform 0.5s',
|
||||
}"
|
||||
></view>
|
||||
<view v-else>气球爆炸了!</view>
|
||||
<view class="bottom-box">
|
||||
<input class="input" type="number" v-model="val" placeholder="请输入秒数,秒数不能超过13" />
|
||||
<view class="box">
|
||||
<button class="btn" type="primary" @click="count++">X{{ count }}</button>
|
||||
<button class="btn" type="primary" @click="changeBet">X{{ betVal }}</button>
|
||||
</view>
|
||||
<view class="box">
|
||||
<button class="btn" type="primary" @click="clear">重置</button>
|
||||
<button class="btn" type="primary" @click="startBet">吹</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
@import './index.scss';
|
||||
</style>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default definePageConfig({
|
||||
navigationBarBackgroundColor: '#23684B',
|
||||
enablePullDownRefresh: true
|
||||
enablePullDownRefresh: true,
|
||||
})
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
<template v-if="typeNum === 1">
|
||||
<view class="card" v-for="(item,index) in list as any[]" :key="index">
|
||||
<view>
|
||||
<view
|
||||
>第{{ item.Periods }}期开奖:
|
||||
<view>
|
||||
第{{ item.Periods }}期开奖:
|
||||
<text>{{ item.Name }}秒</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -12,19 +12,17 @@
|
||||
</template>
|
||||
<template v-else>
|
||||
<view v-if="list.length > 0">
|
||||
<view
|
||||
class="card desc"
|
||||
v-for="(item,index) in list as any[]"
|
||||
:key="index"
|
||||
>
|
||||
<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>
|
||||
时间:
|
||||
<text style="color: red">{{ item.Name }}</text>
|
||||
</view>
|
||||
<view class="sub">
|
||||
投注时间:
|
||||
<text>{{ item.DrawTime }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view style="text-align: right">
|
||||
<view style="color: red">+{{ item.DrawNum }}积分</view>
|
||||
@@ -40,45 +38,47 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from "vue";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { ref } from 'vue'
|
||||
import Taro from '@tarojs/taro'
|
||||
|
||||
const list = ref<any[]>([]);
|
||||
const list = ref<any[]>([])
|
||||
|
||||
const typeNum = ref(0);
|
||||
const typeNum = ref(0)
|
||||
|
||||
Taro.useLoad((options) => {
|
||||
typeNum.value = Number(options.type);
|
||||
typeNum.value = Number(options.type)
|
||||
Taro.setNavigationBarTitle({
|
||||
title: options.type === "1" ? "开奖记录" : "投注记录",
|
||||
});
|
||||
getData();
|
||||
});
|
||||
title: options.type === '1' ? '开奖记录' : '投注记录',
|
||||
})
|
||||
getData()
|
||||
})
|
||||
|
||||
Taro.usePullDownRefresh(() => {
|
||||
getData();
|
||||
});
|
||||
getData()
|
||||
})
|
||||
|
||||
const getData = async () => {
|
||||
if (typeNum.value === 1) {
|
||||
Taro.request({
|
||||
url: `${process.env.TARO_APP_BALLOON_API}/draw`,
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
success: ({ data: res }) => {
|
||||
list.value = res.data.data || [];
|
||||
list.value = res.data.data || []
|
||||
},
|
||||
});
|
||||
})
|
||||
} else {
|
||||
Taro.request({
|
||||
url: `${process.env.TARO_APP_BALLOON_API}/userBalloonRecord?uid=${Taro.getStorageSync('uid')}`,
|
||||
method: "GET",
|
||||
url: `${process.env.TARO_APP_BALLOON_API}/userBalloonRecord?uid=${Taro.getStorageSync(
|
||||
'uid'
|
||||
)}`,
|
||||
method: 'GET',
|
||||
success: ({ data: res }) => {
|
||||
list.value = res.data.data || [];
|
||||
list.value = res.data.data || []
|
||||
},
|
||||
});
|
||||
})
|
||||
}
|
||||
Taro.stopPullDownRefresh();
|
||||
};
|
||||
Taro.stopPullDownRefresh()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '游戏详情'
|
||||
navigationBarTitleText: '游戏详情',
|
||||
})
|
||||
|
||||
@@ -32,7 +32,6 @@ page {
|
||||
width: 300px;
|
||||
text-align: center;
|
||||
border: 1px solid #f5f5f5;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,24 +15,22 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from "vue";
|
||||
import Taro from "@tarojs/taro";
|
||||
import "./index.scss";
|
||||
import { ref } from 'vue'
|
||||
import Taro from '@tarojs/taro'
|
||||
import './index.scss'
|
||||
|
||||
const info = ref<any>({});
|
||||
const info = ref<any>({})
|
||||
|
||||
Taro.useLoad(() => {
|
||||
info.value = Taro.getStorageSync("gameItem");
|
||||
});
|
||||
info.value = Taro.getStorageSync('gameItem')
|
||||
})
|
||||
|
||||
const list = ref([
|
||||
"https://files.wanzhuanyongcheng.com/file/img/yaotouzi/banner/qietu.png",
|
||||
]);
|
||||
const list = ref(['https://files.wanzhuanyongcheng.com/file/img/yaotouzi/banner/qietu.png'])
|
||||
|
||||
const startGame = () => {
|
||||
console.log(info.value);
|
||||
console.log(info.value)
|
||||
Taro.navigateTo({
|
||||
url: info.value.url,
|
||||
});
|
||||
};
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '游戏大厅'
|
||||
navigationBarTitleText: '游戏大厅',
|
||||
})
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
border-radius: 20px;
|
||||
text-align: center;
|
||||
line-height: 300px;
|
||||
background-image: url("../../static/qietu.png");
|
||||
background-image: url('../../static/qietu.png');
|
||||
background-size: 100% 100%;
|
||||
position: relative;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
position: absolute;
|
||||
width: 150px;
|
||||
height: 100px;
|
||||
background-image: url("../../static/an.png");
|
||||
background-image: url('../../static/an.png');
|
||||
background-size: 100% 100%;
|
||||
right: 30px;
|
||||
bottom: 10px;
|
||||
|
||||
@@ -11,42 +11,42 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from "vue";
|
||||
import Taro from "@tarojs/taro";
|
||||
import "./index.scss";
|
||||
import { ref } from 'vue'
|
||||
import Taro from '@tarojs/taro'
|
||||
import './index.scss'
|
||||
|
||||
Taro.useLoad((options) => {
|
||||
Taro.setStorageSync("uid", options.uid);
|
||||
if (Taro.getStorageSync("uid")) {
|
||||
Taro.setStorageSync('uid', options.uid)
|
||||
if (Taro.getStorageSync('uid')) {
|
||||
Taro.showToast({
|
||||
title: `登陆成功`,
|
||||
icon: "none",
|
||||
});
|
||||
getList();
|
||||
icon: 'none',
|
||||
})
|
||||
getList()
|
||||
} else {
|
||||
Taro.showToast({
|
||||
title: "登陆失败,请重新进入游戏大厅",
|
||||
icon: "none",
|
||||
});
|
||||
title: '登陆失败,请重新进入游戏大厅',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
const list = ref([]);
|
||||
const list = ref([])
|
||||
|
||||
const getList = async () => {
|
||||
Taro.request({
|
||||
url: `${process.env.TARO_APP_HOME}`,
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
success: ({ data: res }) => {
|
||||
list.value = res.data.data || [];
|
||||
list.value = res.data.data || []
|
||||
},
|
||||
});
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
const toPage = (item: any) => {
|
||||
Taro.setStorageSync("gameItem", item);
|
||||
Taro.setStorageSync('gameItem', item)
|
||||
Taro.navigateTo({
|
||||
url: `/pages/game_detail/index?id=${item.ID}`,
|
||||
});
|
||||
};
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '摇骰子'
|
||||
navigationBarTitleText: '摇骰子',
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.index {
|
||||
background-color: #23684B;
|
||||
background-color: #23684b;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
@@ -22,12 +22,11 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
|
||||
image {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border-radius: 50%;
|
||||
border: 2px solid #FFFFFF;
|
||||
border: 2px solid #ffffff;
|
||||
}
|
||||
|
||||
.userText {
|
||||
@@ -48,9 +47,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.right {
|
||||
background-color: #429C78;
|
||||
background-color: #429c78;
|
||||
border-radius: 50px;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
@@ -59,7 +57,7 @@
|
||||
padding: 10px;
|
||||
|
||||
.icon {
|
||||
background-image: url("../../../static/dz.png");
|
||||
background-image: url('../../../static/dz.png');
|
||||
background-size: 100% 100%;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
@@ -106,7 +104,7 @@
|
||||
justify-content: flex-start;
|
||||
|
||||
.text {
|
||||
background-color: #E9422F;
|
||||
background-color: #e9422f;
|
||||
width: 55px;
|
||||
height: 55px;
|
||||
text-align: center;
|
||||
@@ -124,13 +122,12 @@
|
||||
}
|
||||
|
||||
.right {
|
||||
|
||||
.btn {
|
||||
width: 137px;
|
||||
background: linear-gradient(-180deg, #FBE039, #FDC413);
|
||||
background: linear-gradient(-180deg, #fbe039, #fdc413);
|
||||
font-size: 30px;
|
||||
text-align: center;
|
||||
border: 1px solid #FFEDC5;
|
||||
border: 1px solid #ffedc5;
|
||||
border-radius: 26px;
|
||||
}
|
||||
}
|
||||
@@ -184,7 +181,6 @@
|
||||
.item1 {
|
||||
width: 24%;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.opt1 {
|
||||
@@ -249,7 +245,7 @@
|
||||
}
|
||||
|
||||
.base {
|
||||
background-image: url("../../../static/cais.png");
|
||||
background-image: url('../../../static/cais.png');
|
||||
background-size: 100% 100%;
|
||||
//flex: 1;
|
||||
width: 43%;
|
||||
@@ -262,13 +258,13 @@
|
||||
overflow: hidden;
|
||||
|
||||
.qz {
|
||||
background-image: url("../../../static/qz.png");
|
||||
background-image: url('../../../static/qz.png');
|
||||
background-size: 100% 100%;
|
||||
width: 90%;
|
||||
height: 25%;
|
||||
margin-bottom: 20px;
|
||||
line-height: 100px;
|
||||
color: #FBE039;
|
||||
color: #fbe039;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
@@ -288,7 +284,7 @@
|
||||
padding: 0 50px;
|
||||
|
||||
.btn1 {
|
||||
background-image: url("../../../static/cz.png");
|
||||
background-image: url('../../../static/cz.png');
|
||||
background-size: 100% 100%;
|
||||
width: 150px;
|
||||
height: 100px;
|
||||
@@ -297,7 +293,7 @@
|
||||
}
|
||||
|
||||
.btn2 {
|
||||
background-image: url("../../../static/ssd.png");
|
||||
background-image: url('../../../static/ssd.png');
|
||||
background-size: 100% 100%;
|
||||
width: 150px;
|
||||
height: 100px;
|
||||
@@ -306,7 +302,7 @@
|
||||
}
|
||||
|
||||
.btn3 {
|
||||
background-image: url("../../../static/tz.png");
|
||||
background-image: url('../../../static/tz.png');
|
||||
background-size: 100% 100%;
|
||||
width: 150px;
|
||||
height: 100px;
|
||||
@@ -322,7 +318,9 @@
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.btn1, .btn2, .btn3 {
|
||||
.btn1,
|
||||
.btn2,
|
||||
.btn3 {
|
||||
&:active {
|
||||
animation: btn ease 0.3s;
|
||||
}
|
||||
@@ -363,7 +361,7 @@
|
||||
.expanding-div {
|
||||
width: 10px;
|
||||
height: 90px;
|
||||
background-image: url("../../../static/qzzz.png");
|
||||
background-image: url('../../../static/qzzz.png');
|
||||
background-size: 100% 100%;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
@@ -419,7 +417,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.card {
|
||||
width: 92%;
|
||||
padding: 20px;
|
||||
@@ -432,7 +429,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.close {
|
||||
width: 35px;
|
||||
height: 35px;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<view class="left">
|
||||
<image :src="userInfo.avatarUrl"></image>
|
||||
<view class="userText">
|
||||
<view class="userName">{{ userInfo.nickName || "用户" }}</view>
|
||||
<view class="userName">{{ userInfo.nickName || '用户' }}</view>
|
||||
<view class="userScore">积分: {{ userInfo.integral || 0 }}</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -34,12 +34,8 @@
|
||||
<view>剩余{{ time }}s开奖</view>
|
||||
</view>
|
||||
<view class="right">
|
||||
<view class="btn" @click="utils.vibrateShort(() => toPage(1))"
|
||||
>开奖记录</view
|
||||
>
|
||||
<view class="btn mt-15" @click="utils.vibrateShort(() => toPage(2))"
|
||||
>投注记录</view
|
||||
>
|
||||
<view class="btn" @click="utils.vibrateShort(() => toPage(1))">开奖记录</view>
|
||||
<view class="btn mt-15" @click="utils.vibrateShort(() => toPage(2))">投注记录</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 选项区 -->
|
||||
@@ -61,8 +57,9 @@
|
||||
class="close"
|
||||
v-if="item.status"
|
||||
@click.stop="utils.vibrateShort(() => clearOneBet(item))"
|
||||
>x</view
|
||||
>
|
||||
x
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="opt1" v-if="odds1.length > 0">
|
||||
@@ -82,8 +79,9 @@
|
||||
class="close"
|
||||
v-if="odds1[0].status"
|
||||
@click.stop="utils.vibrateShort(() => clearOneBet(odds1[0]))"
|
||||
>x</view
|
||||
>
|
||||
x
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="subColor item"
|
||||
@@ -100,8 +98,9 @@
|
||||
class="close"
|
||||
v-if="odds1[1].status"
|
||||
@click.stop="utils.vibrateShort(() => clearOneBet(odds1[1]))"
|
||||
>x</view
|
||||
>
|
||||
x
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="base">
|
||||
@@ -110,9 +109,9 @@
|
||||
{{ qzTitle }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="expanding-div" v-if="isShow"
|
||||
>{{ nowKJInfo.Start }} - {{ nowKJInfo.End }}</view
|
||||
>
|
||||
<view class="expanding-div" v-if="isShow">
|
||||
{{ nowKJInfo.Start }} - {{ nowKJInfo.End }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="optt">
|
||||
<view
|
||||
@@ -131,8 +130,9 @@
|
||||
class="close"
|
||||
v-if="odds1[2].status"
|
||||
@click.stop="utils.vibrateShort(() => clearOneBet(odds1[2]))"
|
||||
>x</view
|
||||
>
|
||||
x
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view
|
||||
class="subColor item"
|
||||
@@ -165,19 +165,16 @@
|
||||
class="close"
|
||||
v-if="item.status"
|
||||
@click.stop="utils.vibrateShort(() => clearOneBet(item))"
|
||||
>x</view
|
||||
>
|
||||
x
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view style="height: 25%" scroll-y>
|
||||
<view
|
||||
class="card subColor"
|
||||
v-for="(item,index) in kjList as any[]"
|
||||
:key="index"
|
||||
>
|
||||
<view class="card subColor" v-for="(item,index) in kjList as any[]" :key="index">
|
||||
<view>
|
||||
<view
|
||||
>第{{ item.Periods }}期开奖:
|
||||
<view>
|
||||
第{{ item.Periods }}期开奖:
|
||||
<text style="color: red">{{ item.Start }} , {{ item.End }}</text>
|
||||
<text
|
||||
v-for="(num, i) in item.Name"
|
||||
@@ -201,124 +198,115 @@
|
||||
</scroll-view>
|
||||
<!-- 底部操作栏 -->
|
||||
<view class="subColor bottomBar">
|
||||
<view class="btn1" @click="utils.vibrateShort(() => clearBet(true))"
|
||||
>重置</view
|
||||
>
|
||||
<view class="btn2" @click="utils.vibrateShort(() => changeOdd())"
|
||||
>X{{ oddVal }}</view
|
||||
>
|
||||
<view class="btn3" @click="utils.vibrateShort(() => verifyBet())"
|
||||
>投注</view
|
||||
>
|
||||
<view class="btn1" @click="utils.vibrateShort(() => clearBet(true))">重置</view>
|
||||
<view class="btn2" @click="utils.vibrateShort(() => changeOdd())">X{{ oddVal }}</view>
|
||||
<view class="btn3" @click="utils.vibrateShort(() => 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";
|
||||
import utils from "@/utils";
|
||||
import { ref } from 'vue'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { app } from '@/config'
|
||||
import { getGameOption, getKaiJiangList, getJfDz } from '@/api'
|
||||
import utils from '@/utils'
|
||||
|
||||
const ws = ref<null | WebSocket>(null);
|
||||
const ws = ref<null | WebSocket>(null)
|
||||
|
||||
// 是否显示开奖动画
|
||||
const isShow = ref(false);
|
||||
const isShow = ref(false)
|
||||
|
||||
// 是否开启文字放大动画
|
||||
const isExpanding = ref(false);
|
||||
const isExpanding = ref(false)
|
||||
|
||||
interface Odd {
|
||||
id?: number;
|
||||
name?: string;
|
||||
odds?: number;
|
||||
markNum?: number;
|
||||
status?: boolean;
|
||||
flicker?: boolean;
|
||||
numStr?: number;
|
||||
id?: number
|
||||
name?: string
|
||||
odds?: number
|
||||
markNum?: number
|
||||
status?: boolean
|
||||
flicker?: boolean
|
||||
numStr?: number
|
||||
}
|
||||
|
||||
const odds = ref<Odd[]>([]);
|
||||
const odds = ref<Odd[]>([])
|
||||
|
||||
const odds1 = ref<Odd[]>([]);
|
||||
const odds1 = ref<Odd[]>([])
|
||||
|
||||
const odds2 = ref<Odd[]>([]);
|
||||
const odds2 = ref<Odd[]>([])
|
||||
|
||||
const qzTitle = ref("请投注");
|
||||
const qzTitle = ref('请投注')
|
||||
|
||||
const time = ref(0);
|
||||
const time = ref(0)
|
||||
|
||||
const nowKJInfo = ref<{
|
||||
Start?: string;
|
||||
End?: string;
|
||||
Periods?: number;
|
||||
}>({});
|
||||
Start?: string
|
||||
End?: string
|
||||
Periods?: number
|
||||
}>({})
|
||||
|
||||
const userInfo = ref<{
|
||||
pulse?: number;
|
||||
integral?: number;
|
||||
nickName?: string;
|
||||
avatarUrl?: string;
|
||||
}>({});
|
||||
pulse?: number
|
||||
integral?: number
|
||||
nickName?: string
|
||||
avatarUrl?: string
|
||||
}>({})
|
||||
|
||||
const zjObj = ref<any>([]);
|
||||
const zjObj = ref<any>([])
|
||||
|
||||
const iMsgNum = ref(0);
|
||||
const iMsgNum = ref(0)
|
||||
|
||||
const numColor = (num: string) => {
|
||||
switch (num) {
|
||||
case "大":
|
||||
return "red";
|
||||
case "小":
|
||||
return "green";
|
||||
case '大':
|
||||
return 'red'
|
||||
case '小':
|
||||
return 'green'
|
||||
// case '单':
|
||||
// return 'orange'
|
||||
// case '双':
|
||||
// return 'blue'
|
||||
case "和":
|
||||
return "purple";
|
||||
case '和':
|
||||
return 'purple'
|
||||
default:
|
||||
return "black";
|
||||
return 'black'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Taro.useDidShow(() => {
|
||||
startMusic(
|
||||
"https://files.wanzhuanyongcheng.com/file/music/yaotouzi/bg.MP3",
|
||||
true
|
||||
);
|
||||
startMusic('https://files.wanzhuanyongcheng.com/file/music/yaotouzi/bg.MP3', true)
|
||||
|
||||
initWs();
|
||||
initData();
|
||||
});
|
||||
initWs()
|
||||
initData()
|
||||
})
|
||||
|
||||
Taro.useDidHide(() => {
|
||||
console.log("useDidHide");
|
||||
ws.value?.close();
|
||||
});
|
||||
console.log('useDidHide')
|
||||
ws.value?.close()
|
||||
})
|
||||
|
||||
const initData = () => {
|
||||
qzTitle.value = "请投注";
|
||||
getOddList();
|
||||
getKJList();
|
||||
getUserInfo();
|
||||
};
|
||||
qzTitle.value = '请投注'
|
||||
getOddList()
|
||||
getKJList()
|
||||
getUserInfo()
|
||||
}
|
||||
|
||||
const arr = ["2+2", "3+3", "4+4", "5+5", "6+6"];
|
||||
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 arr1 = ["大", "小", "和"];
|
||||
const arr2 = ["3", "4", "5", "6", "8", "9", "10", "11"];
|
||||
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 = [];
|
||||
const res = await getGameOption()
|
||||
odds.value = []
|
||||
odds1.value = []
|
||||
odds2.value = []
|
||||
res.data.data.forEach((item: any) => {
|
||||
const { name, ID, odds: odd, max } = item;
|
||||
const { name, ID, odds: odd, max } = item
|
||||
const newItem = {
|
||||
id: ID,
|
||||
name: name,
|
||||
@@ -328,260 +316,257 @@ const getOddList = async () => {
|
||||
numStr: 0,
|
||||
status: false,
|
||||
flicker: false,
|
||||
};
|
||||
if (Taro.getStorageSync("odds")) {
|
||||
odds.value = Taro.getStorageSync("odds");
|
||||
odds1.value = Taro.getStorageSync("odds1");
|
||||
odds2.value = Taro.getStorageSync("odds2");
|
||||
}
|
||||
if (Taro.getStorageSync('odds')) {
|
||||
odds.value = Taro.getStorageSync('odds')
|
||||
odds1.value = Taro.getStorageSync('odds1')
|
||||
odds2.value = Taro.getStorageSync('odds2')
|
||||
} else {
|
||||
if (arr1.includes(name)) {
|
||||
odds1.value.push(newItem);
|
||||
odds1.value.push(newItem)
|
||||
} else if (arr.includes(name)) {
|
||||
odds.value.push(newItem);
|
||||
odds.value.push(newItem)
|
||||
} else if (arr2.includes(name)) {
|
||||
odds2.value.push(newItem);
|
||||
odds2.value.push(newItem)
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
// const el = odds2.value.splice(0, 1)[0];
|
||||
// odds2.value.splice(4, 0, el);
|
||||
// console.log(odds1.value)
|
||||
};
|
||||
}
|
||||
|
||||
// 获取个人信息
|
||||
const getUserInfo = async () => {
|
||||
const res = await getJfDz(Taro.getStorageSync("uid"));
|
||||
userInfo.value = res.data.data;
|
||||
};
|
||||
const res = await getJfDz(Taro.getStorageSync('uid'))
|
||||
userInfo.value = res.data.data
|
||||
}
|
||||
|
||||
const kJData = ref<any>([]);
|
||||
const kjList = ref<any>([]);
|
||||
const kJData = ref<any>([])
|
||||
const kjList = ref<any>([])
|
||||
|
||||
// 开奖列表
|
||||
const getKJList = async () => {
|
||||
const res = await getKaiJiangList();
|
||||
kJData.value = res.data.data;
|
||||
const res = await getKaiJiangList()
|
||||
kJData.value = res.data.data
|
||||
kjList.value = res.data.data.map((item: any) => {
|
||||
return {
|
||||
...item,
|
||||
Name: item.Name.split("-"),
|
||||
};
|
||||
});
|
||||
};
|
||||
Name: item.Name.split('-'),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 初始化游戏
|
||||
const initWs = () => {
|
||||
ws.value = new WebSocket(`${app.API_WS()}`);
|
||||
ws.value = new WebSocket(`${app.API_WS()}`)
|
||||
ws.value.onopen = async () => {
|
||||
Taro.showToast({
|
||||
title: "连接游戏服务器成功",
|
||||
title: '连接游戏服务器成功',
|
||||
mask: true,
|
||||
icon: "none",
|
||||
});
|
||||
};
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
|
||||
ws.value.onmessage = async (e: any) => {
|
||||
const res = JSON.parse(e.data);
|
||||
const res = JSON.parse(e.data)
|
||||
switch (res.code) {
|
||||
case 200:
|
||||
let num = Number(res.data);
|
||||
time.value = num;
|
||||
let num = Number(res.data)
|
||||
time.value = num
|
||||
if (num === 5) {
|
||||
openDraw();
|
||||
openDraw()
|
||||
}
|
||||
break;
|
||||
break
|
||||
case 401:
|
||||
Taro.showToast({
|
||||
title: "未登录",
|
||||
title: '未登录',
|
||||
mask: true,
|
||||
icon: "none",
|
||||
});
|
||||
break;
|
||||
icon: 'none',
|
||||
})
|
||||
break
|
||||
case 403:
|
||||
Taro.showToast({
|
||||
title: "未能操作",
|
||||
title: '未能操作',
|
||||
mask: true,
|
||||
icon: "none",
|
||||
});
|
||||
break;
|
||||
icon: 'none',
|
||||
})
|
||||
break
|
||||
case 400:
|
||||
Taro.showToast({
|
||||
title: "豆子不足",
|
||||
title: '豆子不足',
|
||||
mask: true,
|
||||
icon: "none",
|
||||
});
|
||||
break;
|
||||
icon: 'none',
|
||||
})
|
||||
break
|
||||
case 5:
|
||||
Taro.showToast({
|
||||
title: "投注成功",
|
||||
title: '投注成功',
|
||||
mask: true,
|
||||
icon: "none",
|
||||
});
|
||||
break;
|
||||
icon: 'none',
|
||||
})
|
||||
break
|
||||
case 100:
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
});
|
||||
break;
|
||||
icon: 'none',
|
||||
})
|
||||
break
|
||||
case 101:
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
});
|
||||
break;
|
||||
icon: 'none',
|
||||
})
|
||||
break
|
||||
case 301:
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
});
|
||||
icon: 'none',
|
||||
})
|
||||
setTimeout(() => {
|
||||
Taro.navigateBack({
|
||||
delta: 1,
|
||||
});
|
||||
}, 2000);
|
||||
})
|
||||
}, 2000)
|
||||
default:
|
||||
iMsgNum.value++;
|
||||
zjObj.value = res;
|
||||
break;
|
||||
iMsgNum.value++
|
||||
zjObj.value = res
|
||||
break
|
||||
}
|
||||
};
|
||||
}
|
||||
ws.value.onerror = () => {
|
||||
console.log("连接游戏服务器失败");
|
||||
console.log('连接游戏服务器失败')
|
||||
Taro.showToast({
|
||||
title: "连接游戏服务器失败",
|
||||
title: '连接游戏服务器失败',
|
||||
mask: true,
|
||||
icon: "none",
|
||||
});
|
||||
};
|
||||
};
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const isKj = ref(false);
|
||||
const isKj = ref(false)
|
||||
// 开奖倒计时
|
||||
const openDraw = () => {
|
||||
isExpanding.value = true;
|
||||
isKj.value = true;
|
||||
startMusic(
|
||||
"https://files.wanzhuanyongcheng.com/file/music/yaotouzi/djs.MP3",
|
||||
false
|
||||
);
|
||||
isExpanding.value = true
|
||||
isKj.value = true
|
||||
startMusic('https://files.wanzhuanyongcheng.com/file/music/yaotouzi/djs.MP3', false)
|
||||
for (let i = 5; i > 0; i--) {
|
||||
setTimeout(() => {
|
||||
// i <= 3 && (fontColor.value = "red");
|
||||
qzTitle.value = i.toString();
|
||||
}, 1000 * (5 - i));
|
||||
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();
|
||||
isExpanding.value = false
|
||||
const res = await getKaiJiangList()
|
||||
nowKJInfo.value = res.data.data[0]
|
||||
qzTitle.value = `${nowKJInfo.value?.Periods || 0}期开奖`
|
||||
playAminExpand()
|
||||
setTimeout(() => {
|
||||
startFlicker();
|
||||
}, 6000);
|
||||
isKj.value = false;
|
||||
}, 5000);
|
||||
};
|
||||
startFlicker()
|
||||
}, 6000)
|
||||
isKj.value = false
|
||||
}, 5000)
|
||||
}
|
||||
|
||||
const oddVal = ref(100);
|
||||
const oddVal = ref(100)
|
||||
const changeOdd = () => {
|
||||
switch (oddVal.value) {
|
||||
case 100:
|
||||
oddVal.value = 1000;
|
||||
break;
|
||||
oddVal.value = 1000
|
||||
break
|
||||
// case 10:
|
||||
// oddVal.value = 100
|
||||
// break
|
||||
case 1000:
|
||||
oddVal.value = 100;
|
||||
break;
|
||||
oddVal.value = 100
|
||||
break
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const clearBet = (val: boolean) => {
|
||||
clearItems(odds.value, val);
|
||||
clearItems(odds1.value, val);
|
||||
clearItems(odds2.value, val);
|
||||
savsData();
|
||||
};
|
||||
clearItems(odds.value, val)
|
||||
clearItems(odds1.value, val)
|
||||
clearItems(odds2.value, val)
|
||||
savsData()
|
||||
}
|
||||
|
||||
const clearItems = (items: any[], isClear: boolean = false) => {
|
||||
items.forEach((item: any) => {
|
||||
item.markNum = 0;
|
||||
item.markNum = 0
|
||||
if (isClear) {
|
||||
item.numStr = 0;
|
||||
item.status = false;
|
||||
item.numStr = 0
|
||||
item.status = false
|
||||
}
|
||||
});
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
const addNum = (item: any) => {
|
||||
if (isKj.value)
|
||||
return Taro.showToast({
|
||||
title: "正在开奖,不能下注",
|
||||
icon: "none",
|
||||
});
|
||||
if (item.name === "单" || item.name === "双")
|
||||
title: '正在开奖,不能下注',
|
||||
icon: 'none',
|
||||
})
|
||||
if (item.name === '单' || item.name === '双')
|
||||
return Taro.showToast({
|
||||
title: `${item.name}不能下注`,
|
||||
icon: "none",
|
||||
});
|
||||
item.status = true;
|
||||
item.markNum += oddVal.value;
|
||||
item.numStr += oddVal.value;
|
||||
icon: 'none',
|
||||
})
|
||||
item.status = true
|
||||
item.markNum += oddVal.value
|
||||
item.numStr += oddVal.value
|
||||
if (item.markNum >= item.max && item.numStr >= item.max) {
|
||||
item.markNum = item.max;
|
||||
item.numStr = item.max;
|
||||
item.markNum = item.max
|
||||
item.numStr = item.max
|
||||
Taro.showToast({
|
||||
title: `单注不能超过${item.max}`,
|
||||
icon: "none",
|
||||
});
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
savsData();
|
||||
};
|
||||
savsData()
|
||||
}
|
||||
|
||||
// 投注
|
||||
const verifyBet = () => {
|
||||
if (isKj.value)
|
||||
return Taro.showToast({
|
||||
title: "正在开奖,不能下注",
|
||||
icon: "none",
|
||||
});
|
||||
title: '正在开奖,不能下注',
|
||||
icon: 'none',
|
||||
})
|
||||
|
||||
let numCount = 0;
|
||||
let numCount = 0
|
||||
|
||||
odds.value.forEach((item: any) => {
|
||||
if (item.markNum > 0) {
|
||||
numCount += item.markNum;
|
||||
numCount += item.markNum
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
odds1.value.forEach((item: any) => {
|
||||
if (item.markNum > 0) {
|
||||
numCount += item.markNum;
|
||||
numCount += item.markNum
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
odds2.value.forEach((item: any) => {
|
||||
if (item.markNum > 0) {
|
||||
numCount += item.markNum;
|
||||
numCount += item.markNum
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
if (numCount === 0)
|
||||
return Taro.showToast({
|
||||
title: "请选择选项,再投注",
|
||||
icon: "none",
|
||||
});
|
||||
title: '请选择选项,再投注',
|
||||
icon: 'none',
|
||||
})
|
||||
|
||||
if (numCount > (userInfo.value?.pulse as number))
|
||||
return Taro.showToast({
|
||||
title: "投注豆子不足",
|
||||
icon: "none",
|
||||
});
|
||||
title: '投注豆子不足',
|
||||
icon: 'none',
|
||||
})
|
||||
|
||||
const data: any[] = [];
|
||||
const data: any[] = []
|
||||
|
||||
odds.value.forEach((item: any) => {
|
||||
if (item.markNum > 0) {
|
||||
@@ -589,9 +574,9 @@ const verifyBet = () => {
|
||||
bid: item.id,
|
||||
number: item.markNum,
|
||||
name: item.name,
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
odds1.value.forEach((item: any) => {
|
||||
if (item.markNum > 0) {
|
||||
@@ -599,9 +584,9 @@ const verifyBet = () => {
|
||||
bid: item.id,
|
||||
number: item.markNum,
|
||||
name: item.name,
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
odds2.value.forEach((item: any) => {
|
||||
if (item.markNum > 0) {
|
||||
@@ -609,103 +594,97 @@ const verifyBet = () => {
|
||||
bid: item.id,
|
||||
number: item.markNum,
|
||||
name: item.name,
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
ws.value?.send(
|
||||
JSON.stringify({
|
||||
type: 1,
|
||||
data: data,
|
||||
})
|
||||
);
|
||||
)
|
||||
|
||||
setTimeout(() => {
|
||||
getUserInfo();
|
||||
}, 1000);
|
||||
getUserInfo()
|
||||
}, 1000)
|
||||
|
||||
qzTitle.value = "已投注";
|
||||
clearBet(false);
|
||||
savsData();
|
||||
};
|
||||
qzTitle.value = '已投注'
|
||||
clearBet(false)
|
||||
savsData()
|
||||
}
|
||||
|
||||
// 前往开奖和投注记录
|
||||
const toPage = (type: number) => {
|
||||
Taro.navigateTo({
|
||||
url: `/pages/yaotouzi/records/index?type=${type}`,
|
||||
});
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
// 播放展开动画
|
||||
const playAminExpand = () => {
|
||||
isShow.value = true;
|
||||
startMusic(
|
||||
"https://files.wanzhuanyongcheng.com/file/music/yaotouzi/kj.MP3",
|
||||
false
|
||||
);
|
||||
isShow.value = true
|
||||
startMusic('https://files.wanzhuanyongcheng.com/file/music/yaotouzi/kj.MP3', false)
|
||||
setTimeout(() => {
|
||||
isShow.value = false;
|
||||
initData();
|
||||
}, 10000);
|
||||
};
|
||||
isShow.value = false
|
||||
initData()
|
||||
}, 10000)
|
||||
}
|
||||
|
||||
// 开始闪烁
|
||||
const startFlicker = () => {
|
||||
flickerItems(odds.value);
|
||||
flickerItems(odds1.value);
|
||||
flickerItems(odds2.value);
|
||||
zjObj.value = [];
|
||||
};
|
||||
flickerItems(odds.value)
|
||||
flickerItems(odds1.value)
|
||||
flickerItems(odds2.value)
|
||||
zjObj.value = []
|
||||
}
|
||||
|
||||
const flickerItems = (items: any[]) => {
|
||||
delData();
|
||||
delData()
|
||||
items.forEach((item) => {
|
||||
zjObj.value.forEach((item2: any) => {
|
||||
if (item.name === item2.name) {
|
||||
item.flicker = true;
|
||||
item.flicker = true
|
||||
setTimeout(() => {
|
||||
item.flicker = false;
|
||||
}, 3000);
|
||||
item.flicker = false
|
||||
}, 3000)
|
||||
}
|
||||
});
|
||||
});
|
||||
startMusic(
|
||||
"https://files.wanzhuanyongcheng.com/file/music/yaotouzi/bg.MP3",
|
||||
true
|
||||
);
|
||||
};
|
||||
})
|
||||
})
|
||||
startMusic('https://files.wanzhuanyongcheng.com/file/music/yaotouzi/bg.MP3', true)
|
||||
}
|
||||
|
||||
const innerAudioContext = Taro.createInnerAudioContext();
|
||||
const innerAudioContext = Taro.createInnerAudioContext()
|
||||
|
||||
const startMusic = (path: string, loop: boolean = false) => {
|
||||
// const innerAudioContext = Taro.createInnerAudioContext()
|
||||
innerAudioContext.autoplay = true;
|
||||
innerAudioContext.src = path;
|
||||
innerAudioContext.loop = loop;
|
||||
innerAudioContext.onPlay();
|
||||
innerAudioContext.onError();
|
||||
};
|
||||
innerAudioContext.autoplay = true
|
||||
innerAudioContext.src = path
|
||||
innerAudioContext.loop = loop
|
||||
innerAudioContext.onPlay()
|
||||
innerAudioContext.onError()
|
||||
}
|
||||
|
||||
const clearOneBet = (item: Odd) => {
|
||||
item.markNum = 0;
|
||||
item.numStr = 0;
|
||||
item.status = false;
|
||||
savsData();
|
||||
};
|
||||
item.markNum = 0
|
||||
item.numStr = 0
|
||||
item.status = false
|
||||
savsData()
|
||||
}
|
||||
|
||||
const savsData = () => {
|
||||
Taro.setStorageSync("odds", odds.value);
|
||||
Taro.setStorageSync("odds1", odds1.value);
|
||||
Taro.setStorageSync("odds2", odds2.value);
|
||||
};
|
||||
Taro.setStorageSync('odds', odds.value)
|
||||
Taro.setStorageSync('odds1', odds1.value)
|
||||
Taro.setStorageSync('odds2', odds2.value)
|
||||
}
|
||||
|
||||
const delData = () => {
|
||||
Taro.removeStorageSync("odds");
|
||||
Taro.removeStorageSync("odds1");
|
||||
Taro.removeStorageSync("odds2");
|
||||
};
|
||||
Taro.removeStorageSync('odds')
|
||||
Taro.removeStorageSync('odds1')
|
||||
Taro.removeStorageSync('odds2')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "./index.scss";
|
||||
@import './index.scss';
|
||||
</style>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default definePageConfig({
|
||||
navigationBarBackgroundColor: '#23684B',
|
||||
enablePullDownRefresh: true
|
||||
enablePullDownRefresh: true,
|
||||
})
|
||||
|
||||
@@ -3,15 +3,16 @@
|
||||
<template v-if="typeNum === 1">
|
||||
<view class="card" v-for="(item,index) in list as any[]" :key="index">
|
||||
<view>
|
||||
<view
|
||||
>第{{ item.Periods }}期开奖:
|
||||
<view>
|
||||
第{{ item.Periods }}期开奖:
|
||||
<text
|
||||
v-for="(num, i) in item.Name"
|
||||
:key="i"
|
||||
:style="{
|
||||
color: numColor(num),
|
||||
}"
|
||||
>{{ num }},
|
||||
>
|
||||
{{ num }},
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -19,24 +20,20 @@
|
||||
</template>
|
||||
<template v-else>
|
||||
<view v-if="list.length > 0">
|
||||
<view
|
||||
class="card desc"
|
||||
v-for="(item,index) in list as any[]"
|
||||
:key="index"
|
||||
>
|
||||
<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>
|
||||
点数:
|
||||
<text style="color: red">{{ item.Name }}</text>
|
||||
</view>
|
||||
<view class="sub">
|
||||
投注时间:
|
||||
<text>{{ item.DrawTime }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view style="text-align: right">
|
||||
<view style="color: red"
|
||||
>+{{ item.DrawNum }}积分</view
|
||||
>
|
||||
<view style="color: red">+{{ item.DrawNum }}积分</view>
|
||||
<view style="color: green">-{{ item.Number }}豆子</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -49,59 +46,59 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from "vue";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { getKaiJiangList, getTzJl } from "@/api";
|
||||
import { ref } from 'vue'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { getKaiJiangList, getTzJl } from '@/api'
|
||||
|
||||
const list = ref<any[]>([]);
|
||||
const list = ref<any[]>([])
|
||||
|
||||
const typeNum = ref(0);
|
||||
const typeNum = ref(0)
|
||||
|
||||
Taro.useLoad((options) => {
|
||||
typeNum.value = Number(options.type);
|
||||
typeNum.value = Number(options.type)
|
||||
Taro.setNavigationBarTitle({
|
||||
title: options.type === "1" ? "开奖记录" : "投注记录",
|
||||
});
|
||||
getData();
|
||||
});
|
||||
title: options.type === '1' ? '开奖记录' : '投注记录',
|
||||
})
|
||||
getData()
|
||||
})
|
||||
|
||||
Taro.usePullDownRefresh(() => {
|
||||
getData();
|
||||
});
|
||||
getData()
|
||||
})
|
||||
|
||||
const numColor = (num: string) => {
|
||||
switch (num) {
|
||||
case "大":
|
||||
return "red";
|
||||
case "小":
|
||||
return "green";
|
||||
case "单":
|
||||
return "orange";
|
||||
case "双":
|
||||
return "blue";
|
||||
case "和":
|
||||
return "purple";
|
||||
case '大':
|
||||
return 'red'
|
||||
case '小':
|
||||
return 'green'
|
||||
case '单':
|
||||
return 'orange'
|
||||
case '双':
|
||||
return 'blue'
|
||||
case '和':
|
||||
return 'purple'
|
||||
default:
|
||||
return "black";
|
||||
return 'black'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const getData = async () => {
|
||||
let res: any;
|
||||
let res: any
|
||||
if (typeNum.value === 1) {
|
||||
res = await getKaiJiangList();
|
||||
res = await getKaiJiangList()
|
||||
list.value = res.data.data.map((item: any) => {
|
||||
return {
|
||||
...item,
|
||||
Name: item.Name.split("-"),
|
||||
};
|
||||
});
|
||||
Name: item.Name.split('-'),
|
||||
}
|
||||
})
|
||||
} else {
|
||||
res = await getTzJl(Taro.getStorageSync("uid"));
|
||||
list.value = res.data.data || [];
|
||||
res = await getTzJl(Taro.getStorageSync('uid'))
|
||||
list.value = res.data.data || []
|
||||
}
|
||||
Taro.stopPullDownRefresh();
|
||||
};
|
||||
Taro.stopPullDownRefresh()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import Taro from "@tarojs/taro";
|
||||
|
||||
export default {
|
||||
vibrateShort: (Func: Function) =>
|
||||
Taro.vibrateShort({
|
||||
type: "medium",
|
||||
complete: () => {
|
||||
Func();
|
||||
},
|
||||
}),
|
||||
};
|
||||
import Taro from '@tarojs/taro'
|
||||
|
||||
export default {
|
||||
vibrateShort: (Func: Function) =>
|
||||
Taro.vibrateShort({
|
||||
type: 'medium',
|
||||
complete: () => {
|
||||
Func()
|
||||
},
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {app} from '@/config';
|
||||
import Taro from '@tarojs/taro';
|
||||
import { app } from '@/config'
|
||||
import Taro from '@tarojs/taro'
|
||||
|
||||
export interface RequestParams {
|
||||
url: string;
|
||||
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
||||
header?: object;
|
||||
data?: string | object;
|
||||
url: string
|
||||
method: 'GET' | 'POST' | 'PUT' | 'DELETE'
|
||||
header?: object
|
||||
data?: string | object
|
||||
}
|
||||
|
||||
const request = (request: RequestParams): Promise<any> => {
|
||||
@@ -21,15 +21,15 @@ const request = (request: RequestParams): Promise<any> => {
|
||||
header: request.header || {},
|
||||
data: request.data || {},
|
||||
success: (res) => {
|
||||
resolve(res.data);
|
||||
Taro.hideLoading();
|
||||
resolve(res.data)
|
||||
Taro.hideLoading()
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(err);
|
||||
Taro.hideLoading();
|
||||
reject(err)
|
||||
Taro.hideLoading()
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default request;
|
||||
export default request
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
"jsx": "preserve",
|
||||
"allowJs": true,
|
||||
"resolveJsonModule": true,
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
],
|
||||
"typeRoots": ["node_modules/@types"],
|
||||
"paths": {
|
||||
"@/*": ["src/*"]
|
||||
}
|
||||
|
||||
22
types/global.d.ts
vendored
22
types/global.d.ts
vendored
@@ -1,20 +1,20 @@
|
||||
/// <reference types="@tarojs/taro" />
|
||||
|
||||
declare module '*.png';
|
||||
declare module '*.gif';
|
||||
declare module '*.jpg';
|
||||
declare module '*.jpeg';
|
||||
declare module '*.svg';
|
||||
declare module '*.css';
|
||||
declare module '*.less';
|
||||
declare module '*.scss';
|
||||
declare module '*.sass';
|
||||
declare module '*.styl';
|
||||
declare module '*.png'
|
||||
declare module '*.gif'
|
||||
declare module '*.jpg'
|
||||
declare module '*.jpeg'
|
||||
declare module '*.svg'
|
||||
declare module '*.css'
|
||||
declare module '*.less'
|
||||
declare module '*.scss'
|
||||
declare module '*.sass'
|
||||
declare module '*.styl'
|
||||
|
||||
declare namespace NodeJS {
|
||||
interface ProcessEnv {
|
||||
/** NODE 内置环境变量, 会影响到最终构建生成产物 */
|
||||
NODE_ENV: 'development' | 'production',
|
||||
NODE_ENV: 'development' | 'production'
|
||||
/** 当前构建的平台 */
|
||||
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user