init
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
margin: 20px auto;
|
||||
padding: 10px;
|
||||
border-radius: 50px;
|
||||
background-color: #74c0fc;
|
||||
background-color: #7950f2;
|
||||
color: #fff;
|
||||
width: 300px;
|
||||
text-align: center;
|
||||
|
||||
@@ -188,6 +188,9 @@
|
||||
width: 300px;
|
||||
height: 100px;
|
||||
margin-bottom: 20px;
|
||||
line-height: 100px;
|
||||
color: #FBE039;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,9 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="base">
|
||||
<view class="qz"></view>
|
||||
<view class="qz">
|
||||
{{ qzTitle }}
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<view class="subColor item">
|
||||
@@ -85,6 +87,11 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref} from 'vue'
|
||||
import Taro from '@tarojs/taro'
|
||||
import {app} from '@/config'
|
||||
|
||||
|
||||
let ws: any = null;
|
||||
|
||||
const odds = ref([
|
||||
{
|
||||
@@ -183,6 +190,73 @@ const odd2 = ref([
|
||||
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>
|
||||
|
||||
@@ -13,8 +13,19 @@ import {ref} from "vue";
|
||||
import Taro from "@tarojs/taro";
|
||||
import "./index.scss";
|
||||
|
||||
Taro.useLoad(() => {
|
||||
console.log("Taro.useLoad");
|
||||
Taro.useLoad((options) => {
|
||||
if (options.uid) {
|
||||
Taro.showToast({
|
||||
title: "登陆成功",
|
||||
icon: "none",
|
||||
})
|
||||
Taro.setStorageSync("uid", options.uid)
|
||||
} else {
|
||||
Taro.showToast({
|
||||
title: "登陆失败,请重新进入游戏大厅",
|
||||
icon: "none",
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const list = ref([
|
||||
|
||||
Reference in New Issue
Block a user