<template>
  <div class="bottomCont">
    <template v-if="shopInfo.showPowerByAntFlag">
      <div class="bc1 flex">
        <i></i>
        <p @click="showVConsoles">底线在此,不能更低了</p>
        <i></i>
      </div>
      <div class="bc2">
        <img :src="shopInfo.logoUrl" alt />
      </div>
      <div class="bc3">
        <!-- 送颂 -->
        <p v-if="shopInfo.shopCode=='songsong'">送颂科技提供技术支持</p>
        <!-- 嗨有料 -->
        <p v-else-if="shopInfo.shopCode=='HYL' || shopInfo.shopCode=='Id9uwD' "></p>
        <!-- <p
          v-else-if="Array.isArray(this.$store.state.sceneModule.songCopyright)"
          @click="showCookie"
        >{{this.$store.state.sceneModule.songCopyright.some(item=>item==shopInfo.shopCode)?'送颂科技提供技术支持':'小工蚁(上股交N板企业300258)提供平台服务'}}</p> -->
      </div>
    </template>
    <div class="height7"></div>
    <div class="hide-wrap" v-if="showHideWrap" @click="showActionSheet">
      <i class="ant-fenlei-line" style="font-size:22px"></i>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
import { DFSImg } from "@/utils/index";
const app = getApp();
const { log } = app;
export default {
  data() {
    return {
      shopInfo: {
        logoUrl: '',
        showPowerByAntFlag: true,
      },
      showVConsole : 0,
      showHideWrap : false,
      attemptNum: 0, //获取logo次数
    };
  },
  computed:{
    globalDataShopInfo() {
      return this.mpApp.globalData.shopInfo;
    }
  },
  watch:{
    globalDataShopInfo:{
      handler(newVal,oldVal){
        if(newVal){
          console.log(newVal,'------------------globalDataShopInfo')
          this.shopInfo = this.mpApp.globalData.shopInfo
          if(this.shopInfo && this.shopInfo.logoUrl) {
            this.shopInfo.logoUrl = DFSImg(this.shopInfo.logoUrl, 400, 400)
          }
          if(this.shopInfo) {
            this.shopInfo.showPowerByAntFlag = !(this.shopInfo.hidePowerByAntFlag == 1)
          }
          console.log(this.shopInfo,'this.shopInfo')
        }
      },
      immediate: true,
    }
  },
  created(){
    // this.shopInfo = this.mpApp.globalData.shopInfo
    // this.shopInfo.logoUrl = DFSImg(this.shopInfo.logoUrl, 400, 400)
    console.log(this.shopInfo,'mpapp123')

    if(wx.getStorageSync('workBox')){
      this.showHideWrap = true
    }
    this.mpApp.showActionSheet = this.showActionSheet;
  },
  onLoad() {
    console.log('bottomCont-------onLoad');
    this.setLogoUrl();
    console.log(this.shopInfo.logoUrl,'bottomCont-onLoad-logoUrl')
    log.info(this.shopInfo.logoUrl,'bottomCont-onLoad-logoUrl')
  },
  onShow(){
  },
  methods:{
    setLogoUrl(){
      if(!this.shopInfo.logoUrl && this.attemptNum<5) {
        this.attemptNum ++;
        setTimeout(() => {
          this.shopInfo.logoUrl = wx.getStorageSync("logoUrl");
          this.setLogoUrl();
        }, 500);
      }
    },
    showVConsoles(){

      this.showVConsole++;
      if (this.showVConsole >= 10) {
        this.showVConsole=0;

        wx.setStorageSync('workBox','1')
        this.showHideWrap = true
        
      }
      
    },
    showActionSheet(){
      this.showHideWrap = true
      let vm = this
      let accountInfo = wx.getAccountInfoSync(); 
      let version = accountInfo.miniProgram.version; // 1.0.0 小程序版本号
      let itemList = ['复制页面路径', '隐藏工具箱'];
      if(version){
        itemList.push(`当前版本号:${version}`)
      }
      wx.showActionSheet({
        itemList,
        success (res) {
          console.log(res.tapIndex)

          if(res.tapIndex == 0){
            vm.copyUrl()
          }else if(res.tapIndex == 1){
            vm.hideUtils()
          }
        },
        fail (res) {
          console.log(res.errMsg)
        }
      })
    },
    copyUrl(){
      let pages = getCurrentPages()
      let currentPage = pages[pages.length - 1]
      
      let route = currentPage.route
      let options = currentPage.options
      console.log(route,options,'currentPage')
      let query = ''
      for(let attr in options){
        query = attr + '=' + options[attr] + '&'
      }
      let href = '/' + route

      if(query){
        href += '?' + query
      }
      console.log(query)
      wx.setClipboardData({
        data: href,
        success (res) {

        }
      })
    },
    hideUtils(){
      this.showHideWrap = false
      wx.removeStorageSync('workBox','1')
    }
  }
}
</script>

<style lang="scss" scoped>
  .bottomCont {
    width: 100%;
    position: absolute;
    padding: 10px 0;
    z-index:10;
    div {
      width: 70%;
      margin: 0 auto;
      text-align: center;
      color: #999;
      font-size: 13px;
    }
    .bc1 {
      justify-content: space-between;
      align-items: center;
      i {
        width: 15%;
        height: 1px;
        background: #c3c3c3;
      }
    }
    .bc2 {
      width: 64px;
      height: 64px;
      margin-top: 20px;
      margin-bottom: 10px;
      img {
        width: 100%;
        height: 100%;
        object-fit: contain;
      }
    }
    .height7{
      width:100%;
      height: 130rpx;
    }
  }
  .hide-wrap{
    width: 40px !important;
    height: 40px;
    border-radius: 50%;
    background-color: white;
    position: fixed;
    bottom: 100px;
    right: 20px;
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: rgba(0, 0, 0, 0.5) 0px 0px 5px;
    font-size: 20px;
  }
</style>