<template>
  <div>
    <ModuleTitle :title="recommendTheme.themeName" />

    <div class="m-[4px_0_6px] text-[0px] overflow-x whitespace-nowrap">
      <div class="w-[128px] bg-white inline-block rounded-[20px] mr-[8px]"
        v-for="(item, index) in recommendTheme.recommendPostsList" :key="index" @click="sendReply(item)">
        <div class="m-[4px] relative">
          <img class="w-[120px] h-[120px] rounded-[16px] relative z-10" :src="item.coverPhoto" />

          <div
            class="w-[96px] h-[96px] bg-ink-200 rounded-[16px] absolute bottom-[-4px] left-50% transform translate-x-[-50%] z-1">
          </div>
        </div>

        <div class="p-[4px_8px_8px]">
          <div class="text-[11px] text-[#99A0AE] truncate">
            {{ item.topic }}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { defineProps } from "vue";
import { SEND_MESSAGE_CONTENT_TEXT, SEND_MESSAGE_COMMAND_TYPE } from "@/constants/constant";
import ModuleTitle from "@/components/ModuleTitle/index.vue";

const props = defineProps({
  recommendTheme: {
    type: Object,
    default: {},
  },
});

const sendReply = (item) => {
  if (item.userInputContentType && item.userInputContentType === '1') {
    const commonItem = { type: item.userInputContent, title: item.topic }
    uni.$emit(SEND_MESSAGE_COMMAND_TYPE, commonItem);
    return;
  }
  uni.$emit(SEND_MESSAGE_CONTENT_TEXT, item.userInputContent);
};
</script>
