import { useState, useEffect, useMemo } from 'react'
import Taro from '@tarojs/taro'
import CustomNav from '@/components/CustomNav'
import Popup from '@/components/Popup'
import List from '@/components/List';
import Picker from '@/components/Picker'
import { getShopList, getShopMoney, getAccount, getVerifiedOrder, setGetVerifiedOrder } from '@/services/shopBoss'
import ShopCommission from '@/components/ShopCommission'
import eyes from '@/assets/icons/shopKeeper/小眼睛.png'
import ceyes from '@/assets/icons/shopKeeper/小眼睛-闭上.png'
import cutoverUser from '@/assets/icons/UserCenter/cutoverUser.png'
import touristOFF from '@/assets/icons/UserCenter/touristOFF.png'
import hotelBossOFF from '@/assets/icons/UserCenter/hotelBossOFF.png'
import shopBossON from '@/assets/icons/UserCenter/shopBossON.png'
import ToggleRole from '@/components/toggleRole/ToggleRole'


import './spreadMoney.less'

const getList = (id) => (params) => getAccount(id, params)

export default (props) => {
  const { shopList, shop, onHotelChange, shopMoney } = props
  const [showCutover, setShowCutover] = useState(false)
  const [isyear, setYear] = useState(false)
  const [isMomth, setMonth] = useState(false)
  const acc = shopMoney?.acc
  const { accountId } = acc

  const queryParams = useMemo(() => ({

  }), [])


  const reqestAPI = getList(shopMoney?.acc?.accountId)




  //小眼睛开关
  const handleYear = () => {
    isyear ? setYear(false) : setYear(true)
  }
  const handleMonth = () => {
    isMomth ? setMonth(false) : setMonth(true)
  }

  //商铺更改
  const handleHotelChange = (shopId, current) => {
    onHotelChange(current)
  }



  const ShowMoldeOn = () => {
    setShowCutover(true)
  }
  const onClose = () => {
    setShowCutover(false)
  }

  return (
    <view>
      <view>
      </view>
      <ToggleRole showCutover={showCutover} maskClosable={showCutover} onClose={onClose} role='shop' />
      <view style={{ padding: '30rpx', height: '100%' }}>
        <scroll-view scroll-y="true" scroll-view='true' bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" style={{ height: 'calc(100vh - 120px)' }}>
          <view className='storexx'>
            <view className='storeName'>店名：<Picker style={{ display: 'inline-block' }} placeholder="请选择商铺" value={shop?.shopId} kv={['shopName', 'shopId']} dicts={shopList} onChange={handleHotelChange} /></view>
            <view onClick={ShowMoldeOn} className='User-info-cutover'>
              <image className='User-info-cutover-image' src={cutoverUser} />
            </view>
            <view className='tip'>（计算收入以核销为准）</view>
            <view className='money'>
              <view className='sleft'>
                <view className='lword'>全年推广收入（税前）</view>
                <view className='yearMoney'>
                  <text>{isyear ? (shopMoney?.totalCharges / 100).toFixed(2) : '******'}</text>元
                  <image className='micon' src={isyear ? eyes : ceyes} onClick={handleYear} />
                </view>
              </view>
              <view className='line' />
              <view className='sright'>
                <view className='rword'>当月推广收入（税前）</view>
                <view className='monthMoney'>
                  <text>{isMomth ? (shopMoney?.currentCharges / 100).toFixed(2) : '******'}</text>元
                  <image className='micon2' src={isMomth ? eyes : ceyes} onClick={handleMonth}></image>
                </view></view>
            </view>
          </view>
          <view className='title'>推广收入记录</view>
          <List
            style={{ height: 'calc(100% - 145px)' }}
            request={reqestAPI}
            params={queryParams}

            render={({ item, index }) => <ShopCommission key={(index)} item={item} />}
          >
          </List>
        </scroll-view>
      </view>

    </view>
  )
}