<template>
  <JeepayBackground :bgImgView="true">
    <JeepayCustomNavbar :transparent="true" bgDefaultColor="#eff5ff" title="我的" />

    <!-- 业务操作 -->
    <view class="my-wrapper">
      <view class="user-info">
        <image :src="vdata.userInfo.avatarUrl" mode="scaleToFill" />
        <view class="user-main">
          <view class="user-name">{{ vdata.userInfo.realname }}</view>
          <view class="user-phone">{{ vdata.userInfo.telphone }}</view>
        </view>
      </view>
    </view>
    <JeepayNavigation :navList="navList1" />
    <view class="line"></view>
    <JeepayNavigation :navList="navList2" />
    <!-- 广告部分组件 -->
    <blcok v-for="v in vdata.adList" :key="v.adverId">
      <JeepayBanner :list="v.appContent" :interval='v.changeTime' v-if="v.appPlaceType == 2" />
      <JeepayAdCard :list='v.appContent' v-if="v.appPlaceType == 1" />
    </blcok>
  </JeepayBackground>
</template>

<script setup>
import { reactive, ref, onMounted } from 'vue'
import go from '@/commons/utils/go.js'
import { onPageScroll, onShow } from '@dcloudio/uni-app'
import storageManage from '@/commons/utils/storageManage.js'
import { $userInfo, $adList } from '@/http/apiManager.js'

onPageScroll(() => { })
const vdata = reactive({
  userInfo: storageManage.userInfo(),
  adList: []
})

const navList1 = [
  { title: '商户信息', icon: '/static/indexImg/mch-info.svg', pageUrl: '/pages/mchInfo/mchInfo', entId: 'ENT_MCH_INFO' },
  { title: '通知接收人', icon: '/static/indexImg/user-contact.svg', pageUrl: '/pages/noticeManage/noticeManage', entId: 'ENT_MCH_WXMP_USER_LIST' },
  { title: '支付宝代运营授权', icon: '/static/indexImg/icon-ali-pay.svg', pageUrl: 'PAGES_AD_ALIOPERATION',entId:'ENT_MCH_ALIPAY_SP_OPERATION' },
  { title: '关于我们', icon: '/static/indexImg/icon-about.svg', pageUrl: '/pages/aboutMch/aboutMch' },
]
const navList2 = [{ title: '设置', icon: '/static/indexImg/icon-setup.svg', pageUrl: '/pages/userSetUp/userSetUp' }]
onShow(() => {
  userInfo()
})

const userInfo = () => {
  $userInfo().then(({ bizData }) => {
    vdata.userInfo = bizData
    // 保存用户数据
    storageManage.userInfo(bizData)
  })
}
// 请求我的页面广告
$adList({ appPlace: 3 }).then(({ bizData }) => {
  bizData.forEach(v => {
    v.appContent = JSON.parse(v.appContent)
  })
  vdata.adList = bizData
  console.log('bizdata', bizData)
})
const jumpPage = (url) => uni.navigateTo({ url })
const toLogin = () => uni.navigateTo({ url: '/pages/login/index' })
</script>

<style scoped>
/deep/ .bg-img-view {
  background: url('/static/indexImg/user-bg.svg');
}
</style>

<style lang="scss" scoped>
.my-wrapper {
  width: 100%;
  height: 268rpx;
  margin-top: 40rpx;

  .user-info {
    display: flex;
    align-items: center;
    padding: 0 50rpx;

    height: 160rpx;

    image {
      width: 160rpx;
      height: 160rpx;
      border-radius: 32rpx;
      background-color: tomato;
    }

    .user-main {
      margin-left: 30rpx;

      .user-name {
        font-size: 36rpx;
      }

      .user-phone {
        margin-top: 20rpx;
        color: rgba(0, 0, 0, 0.5);
        font-size: 30rpx;
      }
    }
  }
}

.line {
  height: 30rpx;
}

.to-login {
  margin-top: 50rpx;
  text-align: center;
  background-color: #fff;
  padding: 20rpx;
}
</style>
