import Taro from '@tarojs/taro'
import { getShopList, getVerifiedOrder, setGetVerifiedOrder } from '@/services/shopBoss'
import { View, Button, Text, Image } from '@tarojs/components'
import { useState, useEffect } from 'react'
import iconsearch from '@/assets/icons/housemantj/search.png'
import ms from '@/assets/icons/housemantj/ms3.jpg'
import cutoverUser from '@/assets/icons/UserCenter/cutoverUser.png'
import formatTimes from '@/utils/formatTime'
import './style.less'


export default (props) => {

  const { item, verifiedOrder } = props
  const verifyNo = item?.verifyNo
  const [buttonStyle, setButtonStyle] = useState('')


  const confirmOrder = () => {
    setGetVerifiedOrder(verifyNo).then((e) => {
      Taro.showToast({
        title: '核销成功',
        icon: 'success',
        duration: 2000,
      })
      setButtonStyle('none')

    })
  }




  return (
    <View className='orderCard'>
      <View style={{ overflow: 'hidden' }}>
        <View className='orderId'>订单编号：{item.orderId}</View>
        <View className='orderTime'>下单日期：{formatTimes(item.orderDate, 'yyyy-MM-dd hh:ss') || ''}</View>
      </View>
      <View className='order'>
        <Image className='orderImg' src={item.poster} mode='aspectFit' />
        <View className='orderRight'>
          <View className='foodName'>{item.description}</View>
          <View className='price'>合计金额：￥<Text style={{ fontSize: '24rpx' }}>{item.actualPrice / 100}</Text>元 <Text className='pnum'>数量：<Text>1</Text>张</Text> </View>
        </View>
        <View className='line' />
        <View className='phone'>客户手机：<Text>{item.phone.replace(/^(\d{3})\d{4}(\d+)/, "$1****$2") || ''}</Text>
          {
            !item.isConfirmVerified && <button className='Button-OK' onClick={confirmOrder} style={{ display: buttonStyle }}  >确认核销</button>
          }
        </View>
      </View>
    </View>
  )
}

