feat(custom): 新增webview
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
export default defineAppConfig({
|
export default defineAppConfig({
|
||||||
pages: [
|
pages: [
|
||||||
'pages/index/index',
|
'pages/index/index',
|
||||||
|
'pages/webview/index',
|
||||||
'pages/yaotouzi/index/index',
|
'pages/yaotouzi/index/index',
|
||||||
'pages/game_detail/index',
|
'pages/game_detail/index',
|
||||||
'pages/yaotouzi/records/index',
|
'pages/yaotouzi/records/index',
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="index">
|
<view class="index">
|
||||||
<swiper class="swiper" :circular="true" :autoplay="true">
|
<swiper class="swiper" :circular="true" :autoplay="true">
|
||||||
<swiper-item v-for="(item, index) in list" :key="index">
|
<swiper-item v-for="(item, index) in list" :key="index">
|
||||||
<image :src="item" />
|
<image :src="item" />
|
||||||
</swiper-item>
|
</swiper-item>
|
||||||
</swiper>
|
</swiper>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<!-- <view>摇骰子</view> -->
|
<!-- <view>摇骰子</view> -->
|
||||||
|
|
||||||
<rich-text :nodes="info.introduction"></rich-text>
|
<rich-text :nodes="info.introduction"></rich-text>
|
||||||
<view class="btn" @click="startGame()">开始游戏</view>
|
<view class="btn" @click="startGame()">开始游戏</view>
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
@@ -23,13 +23,20 @@ const info = ref<any>({})
|
|||||||
const list = ref<string[]>([])
|
const list = ref<string[]>([])
|
||||||
|
|
||||||
Taro.useLoad(() => {
|
Taro.useLoad(() => {
|
||||||
info.value = Taro.getStorageSync('gameItem')
|
info.value = Taro.getStorageSync('gameItem')
|
||||||
list.value.push(info.value.cover)
|
list.value.push(info.value.cover)
|
||||||
})
|
})
|
||||||
|
|
||||||
const startGame = () => {
|
const startGame = () => {
|
||||||
|
// 判断url中是否含有http
|
||||||
|
if (info.value.url.indexOf('http') === -1) {
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url: info.value.url,
|
url: info.value.url,
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
Taro.navigateTo({
|
||||||
|
url: `/pages/webview/index?url=${info.value.url}`,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
3
src/pages/webview/index.config.ts
Normal file
3
src/pages/webview/index.config.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export default definePageConfig({
|
||||||
|
navigationBarTitleText: 'webview',
|
||||||
|
})
|
||||||
18
src/pages/webview/index.vue
Normal file
18
src/pages/webview/index.vue
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<web-view :src="src" />
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import Taro from '@tarojs/taro'
|
||||||
|
|
||||||
|
const src = ref('')
|
||||||
|
|
||||||
|
Taro.useLoad((e) => {
|
||||||
|
src.value = `${e.url}?uid=${Taro.getStorageSync('uid')}`
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss"></style>
|
||||||
Reference in New Issue
Block a user