<!-- https://cxzx.smcic.net/topic/qinshufa/assets/logp.png -->
<template>
  <van-row class="shanshipin" :style="color ? 'background:'+ color : ''">
    <van-col span="12" style="padding-left: 15px">
      <img
        style="
          width: 40px;
          border-radius: 5px;
          vertical-align: middle;
          margin-right: 5px;
        "
        src="https://cxzx.smcic.net/topic/qinshufa/assets/logp.png"
        alt=""
        srcset=""
      />
      <span style="vertical-align: middle">闪视频</span>
    </van-col>
    <van-col span="12" style="text-align: right; padding-right: 15px">
      <van-button
        style="margin-top: -5px"
        type="danger"
        size="small"
        color="#c11616"
        @click="download"
        >下载</van-button
      >
    </van-col>
  </van-row>
</template>
<script setup>
import { showToast } from 'vant';
import { defineProps } from 'vue';
/**
 * window.$originData.orginParames.title 页面标题
 * window.$originData.orginParames.parameters 固定参数值
 * window.$originData.urlParames url参数
 */
defineProps({
  color: String,
});

import { isIpad, isIphone, isIpod, isWechat } from '@/utils/isTerminal.js';
let time = undefined;
function getDownloadUrl() {
  let url = 'https://ssp.sxtvs.com.cn/app/shp.apk';
  if (isIpad || isIpod || isIphone)
    url =
      'https://apps.apple.com/cn/app/%E9%97%AA%E8%A7%86%E9%A2%91/id1498056575';
  return url;
}

function download() {
  if (time) clearTimeout(time);
  time = window.setTimeout(() => {
    window.SL &&
      window.SL.Interactive.AppClick({
        page_name: '官网',
        event_type: 'downloadApp',
      });
    const url = getDownloadUrl();
    if (isIpad || isIpod || isIphone) return (location.href = url);
    if (isWechat) return showToast('请在浏览器打开下载app');
    location.href = url;
  }, 200);
}
</script>
<style scoped>
.shanshipin {
  position: fixed;
  padding-bottom: 10px;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70px;
  line-height: 70px;
  background: #fff;
  z-index: 5;
  font-size: 16px;
}
</style>
