<template>
  <view class="front-wrapper">
    <view class="tips-title" v-if="!vdata.adList.length">等待商家发起收款</view>
    <JeepayBanner v-else :list="vdata.adList" :interval="vdata.changeTime" height="calc(100vh - 150rpx)" />
  </view>
</template>

<script setup>
import { reactive, ref } from 'vue'
import { onReady, onLoad } from '@dcloudio/uni-app'
import storageManage from '@/commons/utils/storageManage.js'
import { $adBannerList } from '@/http/apiManager'
import envConfig from '@/env/config.js'

// 接收 后屏 通讯 去支付页面
onReady(() => {
  wxfaceapp.onRemoteMessage(function (res) {
    const content = JSON.parse(res.content)
    if (content.type == 'toPay')
      return uni.navigateTo({
        url: '/pages/frontPay/frontPay',
      })
    if (content.type == 'adBanner') {
      envConfig.changeEnv(content.env)
      console.log('content.env', content.env)
      envConfig.changeEnv(content.env)
      storageManage.token(content.token) //存入token 
      return getAd()
    }
  })
  // 关闭扫码器
  wxfaceapp.stopCodeScanner({})
})
const vdata = reactive({})

function getAd () {
  $adBannerList().then(({ bizData }) => {
    if (!bizData) return vdata.adList = []
    vdata.adList = JSON.parse(bizData.appContent) || []
    vdata.changeTime = bizData.changeTime
  })
}

</script>

<style lang="scss" scoped>
.front-wrapper {
  // padding: 0.01rpx;
  width: 100%;
}

.swiper {
  height: 100%;
}

.swiper-item {
  display: block;
  height: 100%;
  line-height: 300rpx;
  text-align: center;
}

.swiper-list {
  margin-top: 40rpx;
  margin-bottom: 0;
}

.uni-common-mt {
  margin-top: 60rpx;
  position: relative;
}

.info {
  position: absolute;
  right: 20rpx;
}

.uni-padding-wrap {
  width: 550rpx;
  padding: 0 100rpx;
}

.tips-title {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 160rpx auto;
  width: 85%;
  height: 180rpx;
  font-size: 32rpx;
  font-weight: 600;
  letter-spacing: 2rpx;
  color: #fff;
  border-radius: 14rpx;
  background-color: rgba($color: #64ec46, $alpha: .7);
}
</style>
