<template>
  <view class="container">
    <ModuleTitle :title="recommendTheme.themeName" />

    <view class="container-scroll font-size-0 scroll-x whitespace-nowrap">
      <view class="card-item bg-white inline-block rounded-[20px] mr-8"
        v-for="(item, index) in recommendTheme.recommendPostsList" :key="index" @click="sendReply(item)">
        <view class="m-4 relative">
          <image class="card-img rounded-[16px] relative z-10" :src="item.coverPhoto" mode="aspectFill" />

          <view class="shadow absolute rounded-[16px]"></view>
        </view>

        <view class="card-text border-box">
          <view class="font-size-11 text-[#99a0ae] ellipsis-1">
            {{ item.topic }}
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { defineProps } from "vue";
import { SEND_MESSAGE_CONTENT_TEXT, SEND_MESSAGE_COMMAND_TYPE } from "@/constant/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>

<style lang="scss" scoped>
@import "./styles/index.scss";
</style>
