import { Text, View } from '@tarojs/components'
import Taro from '@tarojs/taro'
import { memo } from 'react'
import classnames from 'classnames'
import AmountShow from '../amountShow'
import styles from './index.module.scss'
import MCheckbox from '@/components/checkbox'
import Popup from '@/components/popup'
import SearchInput from '@/components/searchInput'

interface Param {
  show?: true | false
  onClose?: () => void
  offlineInfo?: {
    account_name: string
    bank_of_deposit: string
    transfer_remittance_account: string
  }
  showKong?: true | false
}
const OfflinePay = ({ show = true, onClose, offlineInfo, showKong = true }: Param) => {
  // 复制功能
  const clipboardData = () => {
    Taro.setClipboardData({
      data: `开户名称：${offlineInfo?.account_name};\n\r 开户银行：${offlineInfo?.bank_of_deposit};\n\r 转账汇款账号：${offlineInfo?.transfer_remittance_account};`,
      success(res) {
        Taro.showToast({
          icon: 'none',
          title: '复制成功',
        })
      },
    })
  }
  // //复制功能
  const copy = (index) => {
    let res: any = ''
    if (index === 1) {
      res = offlineInfo?.account_name
    }
    else if (index === 2) {
      res = offlineInfo?.bank_of_deposit
    }
    else if (index === 3) {
      res = offlineInfo?.transfer_remittance_account
    }
    Taro.setClipboardData({
      data: res || '',
      success(res) {
        Taro.showToast({
          icon: 'none',
          title: '复制成功',
        })
      },
    })
  }
  return (
    <View className={styles.offlinePay_main}>
      <Popup show={show} showTitle={false} onClose={onClose} >
        <View className={styles.offlinePay_con}>
          <View className={classnames('iconfont icon-a-moreback', styles.miconfont_title)} onClick={onClose}></View>
          <View className={styles.title}>线下汇款</View>
          <View className={styles.offlinePay_list}>
            <View className={styles.flexBox}>
              <View className={styles.title}>开户名称</View>
              <View className={styles.leftFlex}>
                <Text className={styles.offlinePay_con_text}>{offlineInfo?.account_name}</Text>
                <View className={styles.btn} onClick={() => { copy(1) }}>复制</View>
              </View>
            </View>
            <View className={styles.flexBox}>
              <View className={styles.title}>开户银行</View>
              <View className={styles.leftFlex}>
                <Text className={styles.offlinePay_con_text}>{offlineInfo?.bank_of_deposit}</Text>
                <View className={styles.btn} onClick={() => { copy(2) }}>复制</View>
              </View>
            </View>
            <View className={styles.flexBox}>
              <View className={styles.title}>转账汇款账号</View>
              <View className={styles.leftFlex}>
                <Text className={styles.offlinePay_con_text}>{offlineInfo?.transfer_remittance_account}</Text>
                <View className={styles.btn} onClick={() => { copy(3) }}>复制</View>
              </View>
            </View>
            {/* <SearchInput showBorder={false} title='开户银行' titleStyle={{ fontSize: '23rpx' }}>
                            <Text className={styles.offlinePay_con_text}>{offlineInfo?.bank_of_deposit}</Text>
                        </SearchInput>
                        <SearchInput showBorder={false} title='转账汇款账号' titleStyle={{ fontSize: '23rpx' }}>
                            <Text className={styles.offlinePay_con_text}>{offlineInfo?.transfer_remittance_account}</Text>
                        </SearchInput> */}
          </View>
          <View className={styles.btns} onClick={clipboardData}>复制信息</View>
        </View>
        {
          showKong && <View className={styles.kongBox}></View>
        }

      </Popup>
    </View>

  )
}
export default memo(OfflinePay)
