<template>
  <div class="side-menu fixed z-index-1 bottom-0 right-0 mb50 mr30 fn-flex fn-flex-center fn-flex-column">
    <ul class="ulib-r750 bg-000-op60 text-center">
      <li class="" v-for="(item, index) in menuItems" :key="index">
        <template v-if="name">
          <router-link :to="item.path" v-if="name === item.name">
            <div class="imgsize-80X80 fn-flex fn-flex-column fn-flex-center justify-center text-center font-24">
              <i :class="[item.icon,'color-fff']"></i>
              <span class="color-fff mt10">{{ item.name }}</span>
            </div>
          </router-link>
        </template>
        <template v-else>
          <router-link :to="item.path" v-if="route.path !== item.path">
            <div class="imgsize-80X80 fn-flex fn-flex-column fn-flex-center justify-center text-center font-24">
              <i :class="[item.icon,'color-fff']"></i>
              <span class="color-fff mt10">{{ item.name }}</span>
            </div>
          </router-link>
        </template>
      </li>
    </ul>
    <div v-if="route.path=='/' && isWechatBrowser" class="mt20 imgsize-100X100 text-center font-24 pos-rel">
      <img src="@/assets/side-link.png" alt="">
      <wx-open-launch-weapp id="launch-btn" :appid="third_mp.appId" :username="third_mp.username" :path="third_mp.path"
                            style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">
        <component :is="'script'" type="text/wxtag-template">
          <div class="btn" style="position: absolute;top: 0;left: 0;width: 100%;height: 100%;opacity: 0;">打开小程序
          </div>
        </component>
      </wx-open-launch-weapp>
    </div>
  </div>
</template>

<script setup>
import { useRoute } from 'vue-router'
import { WechatAuth } from '@/utils/wechat'

const route = useRoute()
const props = defineProps({
  name: {
    type: String,
    default: ''
  }
})
const menuItems = [
  { name: '首页', icon: 'icon-custom icon-home', path: '/', needLogin: false },
  { name: '我的', icon: 'icon-custom icon-my', path: '/my', needLogin: true }
]
const third_mp = {
  appId: 'wx740f441fe242082c',
  username: 'gh_abd358c96583',
  path: '/pages/guide/localPolicy'
}
const isWechatBrowser = WechatAuth.isWechatBrowser();
</script>

<style>

</style>