shopKeeper.jsx 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. import { React, useState, useEffect, useRef } from 'react'
  2. import Taro, { useRouter } from '@tarojs/taro'
  3. import CustomNav from '@/components/CustomNav'
  4. import Picker from '@/components/Picker'
  5. import Popup from '@/components/Popup'
  6. import ShopUsed from '@/components/ShopUsed' //已核销
  7. import ShopUnused from '@/components/ShopUnused' //未核销
  8. import SearchBar from '@/components/SearchBar'
  9. import { getShopList, getShopMoney, getAccount, getVerifiedOrder, setGetVerifiedOrder } from '@/services/shopBoss'
  10. import List from '@/components/List';
  11. import eyes from '@/assets/icons/shopKeeper/小眼睛.png'
  12. import ceyes from '@/assets/icons/shopKeeper/小眼睛-闭上.png'
  13. import iconsearch from '@/assets/icons/housemantj/search.png'
  14. import ms from '@/assets/icons/housemantj/ms3.jpg'
  15. import ToggleRole from '@/components/toggleRole/ToggleRole'
  16. import cutoverUser from '@/assets/icons/UserCenter/cutoverUser.png'
  17. import './shopKeeper.less'
  18. import { useMemo } from 'react'
  19. export default (props) => {
  20. const { shopList, shop, onHotelChange, shopMoney, verifiedOrder, isVerified, onVarified, onVarifiedTwo, setVer } = props
  21. const { params } = useRouter()
  22. const { tabJump } = params || {}
  23. const [activeTab, setActiveTab] = useState(0)
  24. const [phone, setPhone] = useState()
  25. // const [isVerified, setisVerified] = useState(0)
  26. // const [queryParams, setQueryParams] = useState({ isVerified: isVerified, pageNum: 1, pageSize: 10, shopId: shop?.shopId, phone: phone })
  27. const queryParams = useMemo(() => ({
  28. shopId: shop?.shopId,
  29. isVerified: `${tabJump}` === '1' ? 1 : 0,
  30. phone: phone || '',
  31. }), [phone, shop?.shopId, tabJump])
  32. // 获取资源表信息
  33. const [alllist, setAllList] = useState([])
  34. const [isyear, setYear] = useState(true)
  35. const [isMomth, setMonth] = useState(false)
  36. //小眼睛开关
  37. const handleYear = () => {
  38. isyear ? setYear(false) : setYear(true)
  39. }
  40. const handleMonth = () => {
  41. isMomth ? setMonth(false) : setMonth(true)
  42. }
  43. const handleHotelChange = (e, current) => {
  44. onHotelChange(current)
  45. }
  46. const handelSearch = (e) => {
  47. const val = e.detail.value
  48. setPhone(val)
  49. }
  50. useEffect(() => {
  51. if (tabJump) {
  52. setActiveTab(tabJump - 0)
  53. }
  54. }, [tabJump])
  55. const handleTabChange = (e) => {
  56. const { index } = e.detail
  57. setActiveTab(index)
  58. }
  59. const tabs = [
  60. {
  61. title: '未核销订单',
  62. },
  63. {
  64. title: '已核销订单',
  65. },
  66. ]
  67. //给父组件传val
  68. const handleVarified = () => {
  69. onVarified()
  70. }
  71. const [showCutover, setShowCutover] = useState(false)
  72. const ShowMoldeOn = () => {
  73. setShowCutover(true)
  74. }
  75. const onClose = () => {
  76. setShowCutover(false)
  77. }
  78. return (
  79. <view>
  80. <view>
  81. </view>
  82. <ToggleRole showCutover={showCutover} onClose={onClose} maskClosable={showCutover} role='shop' />
  83. <view style={{ padding: '30rpx', height: '100%' }}>
  84. <scroll-view scroll-y scroll-view='true' bindscrolltoupper='upper' bindscrolltolower='lower' bindscroll='scroll' style={{ height: 'calc(100vh - 120px)' }}>
  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 : '******'}</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 : '******'}</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. <>
  127. <List
  128. style={{ height: 'calc(100% - 145px)' }}
  129. request={getVerifiedOrder}
  130. params={queryParams}
  131. onDataChange={setAllList}
  132. render={({ item, index }) => <ShopUnused key={(index)} item={item} />}
  133. >
  134. </List>
  135. </>
  136. }
  137. {/* 已核销 */}
  138. {activeTab === 1 &&
  139. <>
  140. <List
  141. style={{ height: 'calc(100% - 145px)' }}
  142. request={getVerifiedOrder}
  143. params={queryParams}
  144. onDataChange={setAllList}
  145. render={({ item, index }) => <ShopUsed verifiedOrder={verifiedOrder} key={(index)} item={item} />}
  146. >
  147. </List>
  148. </>
  149. }
  150. </view>
  151. {/* <view className='botton'>已经到底了~</view> */}
  152. </scroll-view>
  153. </view>
  154. </view>
  155. )
  156. }