shopKeeper.jsx 5.9KB

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