shopKeeper.jsx 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. import { React, useState, useEffect, useMemo, useRef } from 'react'
  2. import Taro, { useRouter } from '@tarojs/taro'
  3. import { getVerifiedOrder } from '@/services/shopBoss'
  4. import Picker from '@/components/Picker'
  5. import ShopUsed from '@/components/ShopUsed' //已核销
  6. import ShopUnused from '@/components/ShopUnused' //未核销
  7. import SearchBar from '@/components/SearchBar'
  8. import List from '@/components/List';
  9. import NoData from '@/components/NoData'
  10. import eyes from '@/assets/icons/shopKeeper/eyesON.png'
  11. import ceyes from '@/assets/icons/shopKeeper/eyesOFF.png'
  12. import ToggleRole from '@/components/toggleRole/ToggleRole'
  13. import cutoverUser from '@/assets/icons/UserCenter/cutoverUser.png'
  14. import './shopKeeper.less'
  15. export default (props) => {
  16. const { shopList, shop, onHotelChange, verifiedOrder, shopMoney, onVarified } = props
  17. const { params } = useRouter()
  18. const { tabJump } = params || {}
  19. const [activeTab, setActiveTab] = useState(0)
  20. const [phonea, setPhone] = useState()
  21. const [isVerifieda, setisVerified] = useState(0)
  22. const queryParams = useMemo(() => ({
  23. shopId: shop?.shopId,
  24. isVerified: isVerifieda,
  25. phone: phonea || '',
  26. }), [phonea, shop?.shopId, isVerifieda])
  27. // 获取资源表信息
  28. const [alllist, setAllList] = useState([])
  29. const [isyear, setYear] = useState(true)
  30. const [isMomth, setMonth] = useState(false)
  31. //小眼睛开关
  32. const handleYear = () => {
  33. isyear ? setYear(false) : setYear(true)
  34. }
  35. const handleMonth = () => {
  36. isMomth ? setMonth(false) : setMonth(true)
  37. }
  38. const handleHotelChange = (e, current) => {
  39. onHotelChange(current)
  40. }
  41. const listRef = useRef()
  42. const handelSearch = (e) => {
  43. const val = e.detail.value
  44. setPhone(val)
  45. }
  46. useEffect(() => {
  47. if (tabJump) {
  48. setActiveTab(tabJump - 0)
  49. }
  50. }, [tabJump])
  51. const handleTabChange = (e) => {
  52. const { index } = e.detail
  53. setActiveTab(index)
  54. setisVerified(index)
  55. //如果context有的话代表他滚动了 那么切换tab页就置顶
  56. if (listRef.current?.context) {
  57. listRef.current.context.scrollTo({ top: 0 })
  58. }
  59. }
  60. const tabs = [
  61. {
  62. title: '未核销订单',
  63. },
  64. {
  65. title: '已核销订单',
  66. },
  67. ]
  68. //给父组件传val
  69. const handleVarified = () => {
  70. onVarified()
  71. }
  72. const [showCutover, setShowCutover] = useState(false)
  73. const ShowMoldeOn = () => {
  74. setShowCutover(true)
  75. }
  76. const onClose = () => {
  77. setShowCutover(false)
  78. }
  79. return (
  80. <view>
  81. <view>
  82. </view>
  83. <ToggleRole showCutover={showCutover} maskClosable={showCutover} onClose={onClose} role='shop' />
  84. <view style={{ padding: '0 15px 0 15px', height: '100%' }}>
  85. <view className='storexx'>
  86. <view className='storeName'>店名:<Picker style={{ display: 'inline-block' }} placeholder='请选择商铺' value={shop?.shopId} kv={['shopName', 'shopId']} dicts={shopList} onChange={handleHotelChange} /></view>
  87. <view onClick={ShowMoldeOn} className='User-info-cutover'>
  88. <image className='User-info-cutover-image' src={cutoverUser} />
  89. </view>
  90. <view className='tip'>(计算收入以核销为准)</view>
  91. <view className='money'>
  92. <view className='sleft'>
  93. <view className='lword'>全年订单收入(税前)</view>
  94. <view className='yearMoney'>
  95. <text>{isyear ? (shopMoney?.totalCharges / 100).toFixed(2) : '******'}</text>元
  96. <image className='micon' src={isyear ? eyes : ceyes} onClick={handleYear} />
  97. </view>
  98. </view>
  99. <view className='line' />
  100. <view className='sright'>
  101. <view className='rword'>当月订单收入(税前)</view>
  102. <view className='monthMoney'>
  103. <text>{isMomth ? (shopMoney?.currentCharges / 100).toFixed(2) : '******'}</text>元
  104. <image className='micon2' src={isMomth ? eyes : ceyes} onClick={handleMonth}></image>
  105. </view></view>
  106. </view>
  107. </view>
  108. <view className='search'>
  109. <SearchBar placeholder='搜索订单(输入客户手机号码)' onBlur={handelSearch} />
  110. </view>
  111. <view className='index-tabs'>
  112. <mp-tabs
  113. tabClass='tabs-Unselected'
  114. swiperClass='tabs-swiper'
  115. activeClass='tabs-Selected'
  116. tabs={tabs}
  117. current={activeTab}
  118. onChange={handleTabChange}
  119. activeTab={activeTab}
  120. >
  121. </mp-tabs>
  122. </view>
  123. <view >
  124. {/* 未核销 */}
  125. {activeTab === 0 &&
  126. <view style={{ height: '45vh' }}>
  127. <List
  128. style={{ height: '100%' }}
  129. request={getVerifiedOrder}
  130. params={queryParams}
  131. onDataChange={setAllList}
  132. noData={<NoData />}
  133. render={({ item, index }) =>
  134. <ShopUnused key={(index)} item={item} />}
  135. >
  136. </List>
  137. </view>
  138. }
  139. {/* 已核销 */}
  140. {activeTab === 1 &&
  141. <view style={{ height: '45vh' }}>
  142. <List
  143. style={{ height: '100%' }}
  144. noData={<NoData />}
  145. request={getVerifiedOrder}
  146. params={queryParams}
  147. onDataChange={setAllList}
  148. render={({ item, index }) => <ShopUsed verifiedOrder={verifiedOrder} key={(index)} item={item} />}
  149. >
  150. </List>
  151. </view>
  152. }
  153. </view>
  154. </view>
  155. </view>
  156. )
  157. }