<template>
  <view class="surveys_content">
    <view class="surveys_banner">
      <image
        v-if="
          useModel?.showData?.value?.survey?.cover_image &&
          useModel?.showData?.value?.survey?.cover_image[0]?.url
        "
        mode="aspectFill"
        :src="useModel?.showData?.value?.survey?.cover_image[0]?.url"
      />
      <image
        v-else
        mode="widthFix"
        src="https://pay-prod-1369486729.cos.ap-guangzhou.myqcloud.com/uploads/cs-test/01KPA2WCW71YA70R90YFZ6VFQQ.png"
      />
    </view>
    <view class="surveys_body">
      <view
        v-for="(i, index:number) in useModel?.showData?.value?.questions"
        :key="`item_${index}`"
        class="item_card"
      >
        <view class="title"
          >{{ index + 1 }}.题目：{{ i?.title }}<text v-if="i?.required">*</text></view
        >
        <view class="placeholder"> 提示：{{ i?.placeholder }} </view>
        <view class="p_t score_item_btn_group" v-if="i?.type === 'Score'">
          <view
            v-for="(k, idx) in useModel?.radioList"
            :key="`item_${index}_${idx}`"
            :class="`score_item_btn ${i?.score === k?.value ? 'score_item_btn_active' : ''}`"
            @click="method?.setAnswer(index, k?.value)"
            >{{ k?.label }}
          </view>
        </view>
        <view v-else class="p_t textarea_item">
          <up-textarea
            placeholder="请输入回答"
            style="height: 170rpx"
            :maxlength="i?.max_length || 140"
            count
            v-model="i.answer_content"
            placeholder-class="textarea_placeholder"
          />
        </view>
      </view>
    </view>
    <hs-footer @handleParmaryClick="method.handleSubmit" />
  </view>
</template>
<script setup lang="ts">
import { onLoad } from '@dcloudio/uni-app'
import method from './method'
import useModel from './model'
onLoad((e: any) => {
  method?.getShow(e?.id)
  console.log(e)
})
</script>
<style lang="scss">
@import './style.scss';
</style>
