优惠券
This commit is contained in:
parent
c55fc2954f
commit
f83048f3e9
@ -46,16 +46,24 @@
|
|||||||
<view
|
<view
|
||||||
class="btn-primary"
|
class="btn-primary"
|
||||||
:class="{ disabled: ticketCount <= 0 || entering }"
|
:class="{ disabled: ticketCount <= 0 || entering }"
|
||||||
@tap="enterGame"
|
@tap="enterGame('minesweeper')"
|
||||||
>
|
>
|
||||||
<text class="enter-btn-text">{{ entering ? '正在进入...' : (ticketCount > 0 ? '立即开局' : '资格不足') }}</text>
|
<text class="enter-btn-text">{{ entering ? '正在进入...' : (ticketCount > 0 ? '立即开局' : '资格不足') }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
class="btn-free"
|
||||||
|
:class="{ disabled: entering }"
|
||||||
|
@tap="enterGame('minesweeper_free')"
|
||||||
|
>
|
||||||
|
<text class="free-btn-text">🍭 免费试玩 (正式场获胜有奖)</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
class="btn-secondary"
|
class="btn-secondary"
|
||||||
style="margin-top: 24rpx; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 55rpx; height: 110rpx; display: flex; align-items: center; justify-content: center;"
|
|
||||||
@tap="goRoomList"
|
@tap="goRoomList"
|
||||||
>
|
>
|
||||||
<text style="color: #94a3b8; font-size: 32rpx; font-weight: 600;">📡 对战列表 / 围观</text>
|
<text class="secondary-btn-text">📡 对战列表 / 围观</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -98,8 +106,10 @@ export default {
|
|||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async enterGame() {
|
async enterGame(code) {
|
||||||
if (this.ticketCount <= 0 || this.entering) return
|
const targetCode = code || this.gameCode
|
||||||
|
if (targetCode !== 'minesweeper_free' && this.ticketCount <= 0) return
|
||||||
|
if (this.entering) return
|
||||||
|
|
||||||
this.entering = true
|
this.entering = true
|
||||||
try {
|
try {
|
||||||
@ -107,7 +117,7 @@ export default {
|
|||||||
url: '/api/app/games/enter',
|
url: '/api/app/games/enter',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: {
|
data: {
|
||||||
game_code: this.gameCode
|
game_code: targetCode
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -310,10 +320,57 @@ export default {
|
|||||||
&.disabled {
|
&.disabled {
|
||||||
background: $text-disabled;
|
background: $text-disabled;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
|
opacity: 0.6;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-free {
|
||||||
|
margin-top: 24rpx;
|
||||||
|
height: 110rpx;
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 55rpx;
|
||||||
|
background: rgba($brand-primary, 0.15);
|
||||||
|
border: 1px solid rgba($brand-primary, 0.3);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
transition: all 0.2s;
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
transform: scale(0.98);
|
||||||
|
background: rgba($brand-primary, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.free-btn-text {
|
||||||
|
color: $brand-primary;
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary {
|
||||||
|
margin-top: 24rpx;
|
||||||
|
background: rgba(255,255,255,0.05);
|
||||||
|
border: 1px solid rgba(255,255,255,0.1);
|
||||||
|
border-radius: 55rpx;
|
||||||
|
height: 110rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.secondary-btn-text {
|
||||||
|
color: #94a3b8;
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
.enter-btn-text {
|
.enter-btn-text {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
letter-spacing: 2rpx;
|
letter-spacing: 2rpx;
|
||||||
|
|||||||
@ -117,9 +117,14 @@ class NakamaManager {
|
|||||||
// 抖音小程序需要在用户交互后才能建立 WebSocket 连接
|
// 抖音小程序需要在用户交互后才能建立 WebSocket 连接
|
||||||
// 这里不自动连接,由业务层在适当时机调用 connect()
|
// 这里不自动连接,由业务层在适当时机调用 connect()
|
||||||
resolve(this.session);
|
resolve(this.session);
|
||||||
|
} else {
|
||||||
|
// 检查是否收到 HTML 响应(通常意味着跳转或安全拦截)
|
||||||
|
if (typeof res.data === 'string' && (res.data.trim().toLowerCase().startsWith('<!doctype') || res.data.trim().toLowerCase().startsWith('<html'))) {
|
||||||
|
reject(new Error('游戏服务器地址配置错误或被拦截 (收到 HTML 响应)。请在后台管理检查游戏服务器地址设置。'));
|
||||||
} else {
|
} else {
|
||||||
reject(new Error('Authentication failed: ' + JSON.stringify(res.data)));
|
reject(new Error('Authentication failed: ' + JSON.stringify(res.data)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
reject(new Error('Authentication request failed: ' + err.errMsg));
|
reject(new Error('Authentication request failed: ' + err.errMsg));
|
||||||
|
|||||||
@ -85,17 +85,26 @@ export function redeemProductByPoints(user_id, product_id, quantity) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let cachedSystemInfo = null
|
||||||
|
|
||||||
|
function getSystemInfo() {
|
||||||
|
if (cachedSystemInfo) return cachedSystemInfo
|
||||||
|
try {
|
||||||
|
cachedSystemInfo = uni.getSystemInfoSync()
|
||||||
|
return cachedSystemInfo
|
||||||
|
} catch (_) {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getLanguage() {
|
function getLanguage() {
|
||||||
try { return (uni.getSystemInfoSync().language || 'zh-CN') } catch (_) { return 'zh-CN' }
|
return getSystemInfo().language || 'zh-CN'
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPlatform() {
|
function getPlatform() {
|
||||||
try {
|
|
||||||
// 简单判断当前运行平台
|
// 简单判断当前运行平台
|
||||||
if (typeof wx !== 'undefined') return 'mp-weixin'
|
if (typeof wx !== 'undefined') return 'mp-weixin'
|
||||||
const info = uni.getSystemInfoSync()
|
return getSystemInfo().platform || 'unknown'
|
||||||
return info.platform || 'unknown'
|
|
||||||
} catch (_) { return 'unknown' }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDeviceId() {
|
function getDeviceId() {
|
||||||
@ -110,7 +119,7 @@ function getDeviceId() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildDefaultHeaders() {
|
function buildDefaultHeaders() {
|
||||||
const info = uni.getSystemInfoSync()
|
const info = getSystemInfo()
|
||||||
const lang = info.language || 'zh-CN'
|
const lang = info.language || 'zh-CN'
|
||||||
const platform = info.platform || 'unknown'
|
const platform = info.platform || 'unknown'
|
||||||
const brand = info.brand || ''
|
const brand = info.brand || ''
|
||||||
@ -120,7 +129,7 @@ function buildDefaultHeaders() {
|
|||||||
const screen = `${info.screenWidth}x${info.screenHeight}`
|
const screen = `${info.screenWidth}x${info.screenHeight}`
|
||||||
const pixelRatio = info.pixelRatio || 1
|
const pixelRatio = info.pixelRatio || 1
|
||||||
const windowSize = `${info.windowWidth}x${info.windowHeight}`
|
const windowSize = `${info.windowWidth}x${info.windowHeight}`
|
||||||
return {
|
const headers = {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
'X-Requested-With': 'XMLHttpRequest',
|
'X-Requested-With': 'XMLHttpRequest',
|
||||||
@ -135,7 +144,12 @@ function buildDefaultHeaders() {
|
|||||||
'X-Screen': screen,
|
'X-Screen': screen,
|
||||||
'X-Pixel-Ratio': pixelRatio,
|
'X-Pixel-Ratio': pixelRatio,
|
||||||
'X-Window': windowSize,
|
'X-Window': windowSize,
|
||||||
'Cache-Control': 'no-cache',
|
'Cache-Control': 'no-cache'
|
||||||
'User-Agent': `UniApp/${platform} (${brand} ${model}; ${osName} ${osVersion}) MiniProgram`
|
|
||||||
}
|
}
|
||||||
|
// 小程序环境禁止设置 User-Agent
|
||||||
|
// #ifndef MP
|
||||||
|
headers['User-Agent'] = `UniApp/${platform} (${brand} ${model}; ${osName} ${osVersion})`
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
return headers
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user