<template>
  <view class="body-background"></view>
  <u-navbar
      :title="title"
      :auto-back="true"
      left-icon-size="40rpx"
      :safe-area-inset-top="true"
      :placeholder="true"
      bgColor="transparent"
  ></u-navbar>
  <view class="fxx-container row">
    <view class="fxx-logo">
      <u-image
          mode="widthFix"
          width="400"
          height="373.25"
          :src="staticImage.gwLogo"
      ></u-image>
    </view>
    <view class="fxx-content">
      <view class="content-title">
        顾问认证
      </view>
      <view class="content-main">
        <u-parse :content="content"></u-parse>
        <u-button
            type="primary"
            text="立即认证"
            shape="circle"
            :custom-style="{
              color:'#020B18',
              backgroundColor:'#FF9545',
              border:'none',
              fontSize:'36',
              fontWeight:'400',
              marginTop:'106rpx'
            }"
            @click="goForm"
        ></u-button>
      </view>
    </view>
  </view>
  <u-modal :show="modalShow" content="您的资料还未完善,确认前往完善?" @confirm="navTo('/pages/User/edit')" @close="navTo('/pages/Index/edit')" @cancel="navTo('/pages/Index/edit')"></u-modal>
</template>

<script>
import {
  imghost
} from '@/config/host.js'
import MzSubsection from '@/components/MzSubsection/Index.vue';
import api from '@/utils/functions.js';
import {userExtends} from "@/api/user";
import {advisorConfig, webConfig} from "@/api/other";

export default {
  components: {
    MzSubsection
  },
  data() {
    return {
      modalShow:false,
      current: 1,
      title: '顾问认证',
      loading: true,
      staticImage: {
        bg: imghost + '/BG.png',
        newIcon: imghost + '/new-icon.png',
        gwLogo: imghost + '/gw-logo.png',
        fxx1: imghost + '/fxx-1.png',
      },
      isTop: false,
      size: {
        height: 500,
      },
      userInfo:{},
      content:'',
    }
  },
  onLoad() {

  },
  computed: {
    api() {
      return api
    },
    sectionStyle() {
      const style = {};
      style.padding = '0 26rpx';
      style.position = 'sticky';
      style.zIndex = '9999';
      style.top = api.navHeight().systemBarHeight + 'px'
      return style;
    },
  },
  methods: {
    getDetail(item) {
      advisorConfig({type:'advisor'}).then(res => {
        this.content = res.data.advisor;
      })
    },
    checkSection(index) {
      this.current = index;
    },
    scrollToLower() {

    },
    navTo(url) {
      uni.navigateTo({
        url: url
      })
    },
    goForm(){
        this.navTo('/pages/Consultant/form');
    },
    getUserExtend() {
      userExtends().then((res) => {
        if(res.code === 200) {
          this.userInfo = res.data;
          uni.setStorageSync('user', res.data);
          this.$store.commit('userInfo', res.data);
        }
      });
    }
  },
  onPageScroll(res) {
    if (res.scrollTop <= 20) {
      uni.$emit('isTop', true);
    } else {
      uni.$emit('isTop', false);
    }
  },
  onShow(){
    let token = uni.getStorageSync('token');
    if (token) {
      this.getUserExtend();
    }

  },
  created() {
    // this.pagePadding = (api.navHeight().navPaddingTop +
    // 	api.navHeight().navHeight + (api.navHeight().headerPadding * 2))
  },
  mounted() {
    this.getDetail();
  },
}
</script>

<style lang="scss">
@import './components/index.scss';
</style>