import { Text, View } from '@tarojs/components'
import Taro, { setClipboardData } from '@tarojs/taro'
import { memo } from 'react'
import styles from './index.module.scss'
import { formatDateTime } from '@/common/fotmat'

export interface OrderInfoParam {
  order_no?: string
  create_time?: string
}

export default memo((props: OrderInfoParam) => {
  const handleCopy = () => {
    setClipboardData({ data: props.order_no || '' })
  }
  return <View className={styles.order_info}>
    <View className={styles.order_info_title}>订单信息</View>
    <View className={styles.order_info_list}>
      <View className={styles.order_info_item}>
        <Text className={styles.left}>订单编号：</Text>
        <View className={styles.right}>
          <Text>{props.order_no}</Text>
          <View className={styles.copy_btn} onClick={handleCopy}>复制</View>
        </View>
      </View>
      <View className={styles.order_info_item}>
        <Text className={styles.left}>创建时间：</Text>
        <View className={styles.right}>{formatDateTime(props.create_time)}</View>
      </View>
    </View>
  </View>
})
