<template>
  <section class="voteDetail">
    <u-parse :html="detail.endDisplay"/>
    <AiBottomBtn background="#fff">
      <div flex class="pad-l32 pad-r16 pad-b16 pad-t16">
        <AiHighlight class="fill color-999" content="当前票数：@v" value="21345" color="#FF6900"/>
        <div class="text circle mar-l16" @click="handleVote">投票</div>
      </div>
    </AiBottomBtn>
  </section>
</template>

<script>
import {mapState, mapActions} from "vuex"

export default {
  name: "voteDetail",
  appName: "投票详情",
  computed: {
    ...mapState(['user']),
  },
  data() {
    return {
      detail: {}
    }
  },
  methods: {
    ...mapActions(['getWechatToken', 'getCode']),
    getDetail() {
      this.$http.post("/app/vote/detail", null, {}).then(res => {
        if (res?.data) {
          this.detail = res.data
          document.title = this.detail.name
        }
      })
    },
    handleVote() {
      if (!this.user.token) {//未登录,获取openId和token
        this.$http.get("/app/appdvcpconfig/getMpAppid", {withoutToken: true}).then(res => {
          if (res?.code == 0 && res?.data) {
            this.getCode({scope: "snsapi_userinfo", appid: res.data})
          }
        })
      } else {//已登录,直接投票

      }
    },
  },
  onShow() {
    this.getDetail()
  }
}
</script>

<style lang="scss" scoped>
.voteDetail {
  background: #F3F6F9;
  min-height: 100vh;
}
</style>
