<template>
  <view class="index">
    <swiper class="swiper" :circular="true" :autoplay="true">
      <swiper-item v-for="(item, index) in list" :key="index">
        <image :src="item" />
      </swiper-item>
    </swiper>
    <view class="container">
      <!-- <view>摇骰子</view> -->

      <rich-text :nodes="info.introduction"></rich-text>
      <view class="btn" @click="startGame()">开始游戏</view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import Taro from '@tarojs/taro'
import './index.scss'

const info = ref<any>({})
const list = ref<string[]>([])

Taro.useLoad(() => {
  info.value = Taro.getStorageSync('gameItem')
  list.value.push(info.value.cover)
})

const startGame = () => {
  // 判断url中是否含有http
  if (info.value.url.indexOf('http') === -1) {
    Taro.navigateTo({
      url: info.value.url,
    })
  } else {
    Taro.setStorageSync("url", `${info.value.url}?uid=${Taro.getStorageSync('uid')}&game_id=${info.value.ID}`)
    Taro.navigateTo({
      url: `/pages/webview/index`,
    })
  }
}
</script>
