Commit e1325640 authored by spc's avatar spc

fixed

parent 234b1e4a
......@@ -14,4 +14,6 @@ export const fetchHomeInfo = () => api.get('/c/user/index');
export const fetchCanEatIndex = () => api.get('/c/eat/index');
export const fetchCanEatJoin = (data) => api.post('/c/eat/join', data);
export const fetchHomeJSON = () => api.get('/c/front/content',{type:'home_V1'});
export const fetchHomeJSON = () => api.get('/c/front/content', { type: 'home_V1' });
export const fetchGameActConfigJSON = () => api.get('/c/front/content', { type: 'gameActConfig' });
<template>
<view class="webview-container">
<!-- Webview内容 -->
<web-view :src="webviewUrl" :key="webviewUrl" @message="getMessage"
class="webview-content"></web-view>
<web-view :src="webviewUrl" :key="webviewUrl" @message="getMessage" class="webview-content"></web-view>
</view>
</template>
......@@ -11,6 +10,7 @@ import { ref, watch, nextTick } from 'vue'
import { useUserStore } from '@/stores/user.js'
import { useGlobalStore } from '../../stores/global'
import { fetchSyWebviewJSON } from '../../api/sywebview'
import { fetchGameActConfigJSON } from '../../api/home'
import { onLoad, onShow, onShareAppMessage, onShareTimeline, onPageScroll } from "@dcloudio/uni-app";
import { jump, JumpType } from '../../utils'
import md from '../../md';
......@@ -80,16 +80,35 @@ const getMessage = (e) => {
share.value = messageData[messageData.length - 1]
}
}
let baseUrl = '' // 默认URL
// 初始化 webview URL
const initWebviewUrl = async () => {
// 使用固定的基础URL,从 options 中获取或使用默认值
const options = pageOptions.value
let baseUrl = 'https://momclub-test.feihe.com/h5/game/index.html'
if (!baseUrl) {
// 从接口获取游戏配置
const configRes = await fetchGameActConfigJSON()
console.log('游戏配置接口返回:', configRes)
if (configRes && configRes.data) {
const gameType = 'lianliankan'
if (configRes.data[gameType] && configRes.data[gameType].url) {
baseUrl = configRes.data[gameType].url
}
}
}
if (!baseUrl) {
uni.redirectTo({
url: '/pages/index/index'
})
return
}
// 如果 baseUrl 已经包含协议,直接使用;否则添加协议
if (!baseUrl.startsWith('http://') && !baseUrl.startsWith('https://')) {
......@@ -205,7 +224,6 @@ watch(() => registered.value, (newVal, oldVal) => {
if (newVal) {
nextTick(() => {
initWebviewUrl()
initWebviewUrl()
})
}
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment