<template>
  <div class="container">
    <ModuleTitle :title="recommendTheme.themeName" />
    <div class="container-scroll">
      <div v-for="(item, index) in recommendTheme.recommendPostsList" :key="index">
        <div class="mk-card-item" @click="sendReply(item)">
          <img class="card-img" :src="item.coverPhoto" mode="widthFix"></img>
          <span class="card-text">{{ item.topic }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

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