<template>
  <view>
    <view class="evaluate_body">
      <view class="title">
        请您对本次的服务做一个评价
        <text>*</text>
      </view>
      <view class="star_contents_body">
        <up-icon
          v-for="(i, index) in 5"
          :key="index"
          name="star-fill"
          size="25px"
          :color="index < useModel.dataForm.value.rating ? '#FFD415' : '#ddd'"
          @click="onClickCurrent(i)"
        ></up-icon>
      </view>
      <view class="textarea_body">
        <textarea v-model="useModel.dataForm.value.content" placeholder="说点什么呗？" />
      </view>
    </view>
    <hs-footer btnParimaryName="提交" />
  </view>
</template>
<script lang="ts" setup>
import { Apis } from '@/gen/Apis'
import { onLoad } from '@dcloudio/uni-app'
import useModel from './model'

onLoad(e => {
  useModel.dataForm.value.orders_id = e?.id
  onShow(e)
})

const onShow = (e: any) => {
  // Apis.Order.OrderReviews.Show(e).then(res => {
  //   if (res?.data) {
  //     useModel.dataForm.value = res?.data
  //   }
  // })
}

const onClickCurrent = (idx: Number) => {
  console.log(idx, 'idx')
  useModel.dataForm.value.rating = idx
}
const onSubmit = () => {
  if (!useModel?.dataForm?.value?.rating) {
    uni.showToast({
      title: '请设置评分',
      duration: 1000,
      icon: 'none'
    })
    return false
  }
  // Apis.Order.OrderReviews.Store(useModel?.dataForm?.value).then(res => {
  //   uni.showToast({
  //     title: '提交成功，感谢您的评价!',
  //     duration: 2000,
  //     icon: 'none'
  //   })
  //   setTimeout(() => {
  //     uni.navigateBack()
  //   }, 1000)
  // })
}
</script>
<style lang="scss">
@import './style.scss';
</style>
