<template>
  <view class="order-data-root" @tap="getOrderRealTime">
    <view class="title-root">
      <view>
        <text class="text">今日完成实时数据</text>
        <jx-icon icon="wenhaoxiao" color="#cfcccc" @tap.stop="explain" />
      </view>

      <view class="see-more" v-if="showMore">
        <text>更多</text>
        <jx-icon icon="gengduo" color="#cfcccc" />
      </view>
    </view>

    <view class="order-money">
      <view class="money">
        <text class="number">{{ price }}</text>
        <text>门店收益</text>
      </view>
      <view class="order">
        <text class="number">{{ count }}</text>
        <text>有效订单量</text>
      </view>
      <view class="order1">
        <text class="number">-{{ actualFee }}</text>
        <text>运费</text>
      </view>
    </view>
  </view>
</template>
  
<script lang="ts" setup>
import jxIcon from '@/components/jx-icon/jx-icon.vue'
import { computed, Ref } from 'vue'

interface propsType {
  saleInfo: AnyObject
  showMore?: boolean
}
const props = defineProps<propsType>()

/*************************************************
 * 扣除运费
 */
const actualFee: Ref<number | string> = computed(() => {
  return props.saleInfo.actualFee || '0'
})

/*************************************************
 * 门店收益
 */
const price = computed(() => {
  return props.saleInfo.realEarningPrice
    ? (props.saleInfo.realEarningPrice / 100).toFixed(2)
    : '0.00'
})

/*************************************************
 * 有效订单量
 */
const count = computed(() => {
  return props.saleInfo.count || '0'
})

/**
 * 打开说明窗口
 */
function explain() {
  uni.jxAlert({
    title: '说明',
    content: `实际收入: 从当日0时到当前时间的实际获得，不再扣点，已扣除售后退款\r\n有效订单: 统计时间内，已支付订单中未被取消的订单数量`,
  })
}

/**
 * 跳转到营业数据
 */
function getOrderRealTime() {
  if (props.showMore != true) return
  uni.navigateTo({
    url: '/subPages/merchantChild/orderRealTimeJxgy/orderRealTimeJxgy',
  })
}
</script>
  
  <style lang="scss" scoped>
@import './orderDataJxgy.scss';
</style>