index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <route lang="json5">
  2. { layout: 'tabbar', style: { navigationBarTitleText: '材料', navigationStyle: 'custom' } }
  3. </route>
  4. <script setup lang="ts">
  5. import Card from '@/components/card.vue'
  6. import { abc } from '../../core/libs/pngs'
  7. import {
  8. getAppMaterials,
  9. getBanners,
  10. getByDictType,
  11. getMaterials,
  12. getBannerLogo,
  13. } from '../../core/libs/requests'
  14. import { close, phone } from '../../core/libs/svgs'
  15. import { BannerMode, DictType, MaterialDealer, MaterialsList } from '../../core/libs/models'
  16. import routerIcon from '@designer-hub/assets/src/assets/svgs/router'
  17. import Banner from '@/pages/home/components/banner.vue'
  18. import { useRouter } from '../../core/utils/router'
  19. import { handleCall, openLocation } from '../../core/utils/common'
  20. import { NetImages } from '@/core/libs/net-images'
  21. const searchParams = ref({
  22. manageBrandSet: [],
  23. manageTypeSet: [],
  24. })
  25. const query = computed(() => {
  26. return {
  27. manageBrandSet: searchParams.value.manageBrandSet.join(','),
  28. manageTypeSet: searchParams.value.manageTypeSet.join(','),
  29. }
  30. })
  31. const translateType = ref<string>('')
  32. const router = useRouter()
  33. const { data: materialDealerData, run: setMaterialDealerData } = useRequest(
  34. () => getAppMaterials(),
  35. { initialData: [] },
  36. )
  37. const { data: materialOperationTypes, run: setMaterialOperationTypes } = useRequest(
  38. () => getByDictType(DictType.memberMaterialsOperationType),
  39. { initialData: [] },
  40. )
  41. const { data: materialBrandTypes, run: setMaterialBrandTypes } = useRequest(
  42. () => getByDictType(DictType.memberMaterialsBrandType),
  43. { initialData: [] },
  44. )
  45. // 经营品牌 materialsManageBrand
  46. const { data: materialsManageBrand, run: setMaterialsManageBrand } = useRequest(
  47. () => getByDictType(DictType.materialsManageBrand),
  48. { initialData: [] },
  49. )
  50. const { data: materials, run: setMaterials } = useRequest(() => getMaterials(query.value), {
  51. initialData: {},
  52. })
  53. const { data: banners, run: setBanners } = useRequest(
  54. () => getBanners({ mode: BannerMode.Material }),
  55. { initialData: [] },
  56. )
  57. const { data: bannersLogo, run: setBannersLogo } = useRequest(
  58. () => getBannerLogo({ modeType: BannerMode.Cooperation }),
  59. { initialData: [] },
  60. )
  61. const dealerPanelState = ref(false)
  62. const currentDeraler = ref<MaterialDealer>()
  63. const pieces = ref([
  64. {
  65. title: '材料小课堂',
  66. desc: '全方位了解',
  67. icon: abc,
  68. gridItemClass: 'col-start-1 row-start-1',
  69. path: '/pages/material/mini-class/index',
  70. },
  71. {
  72. title: '推荐材料商',
  73. desc: '优选推荐商',
  74. icon: 'https://image.zhuchaohui.com/zhucaohui/86236d61c75904763cd1247db239b25fa2d8cb8222e4575d29581f58e5d69036.png',
  75. gridItemClass: 'col-start-2 row-start-1',
  76. path: '/pages/material/recommend/index',
  77. isMore: false,
  78. },
  79. // {
  80. // title: '积分计算机',
  81. // desc: '积分小帮手',
  82. // icon: calculator,
  83. // gridItemClass: 'col-start-2 row-start-1',
  84. // path: '/pages/material/calculator/index',
  85. // },
  86. // {
  87. // title: '推荐材料商',
  88. // desc: '我们将优先洽谈大家推荐的材料商',
  89. // icon: materialDealers,
  90. // gridItemClass: 'col-start-1 col-end-3 row-start-2',
  91. // isMore: true,
  92. // path: '/pages/material/recommend/index',
  93. // },
  94. ])
  95. const current = ref<number>(0)
  96. const swiperList = computed(() => banners.value.map((it) => it.bannerImgUrl))
  97. const materialsByBrandLevel = ref<{ list: MaterialDealer[] }[]>([])
  98. const handleTranslateType = (value: string) => {
  99. if (translateType.value === value) {
  100. translateType.value = ''
  101. } else {
  102. translateType.value = value
  103. }
  104. }
  105. const handleMenuItemClick = ({ path }: any) => {
  106. router.push(path)
  107. }
  108. const toDetail = (id: number) => {
  109. uni.navigateTo({
  110. url: `/pages/material/detail/index?id=${id}`,
  111. })
  112. }
  113. const resetSearch = () => {
  114. searchParams.value = {
  115. manageBrandSet: [],
  116. manageTypeSet: [],
  117. }
  118. translateType.value = ''
  119. setMaterials()
  120. }
  121. const submitSearch = () => {
  122. setMaterials()
  123. }
  124. onMounted(async () => {
  125. await setMaterialDealerData()
  126. console.log(materialDealerData.value)
  127. await Promise.all([
  128. setMaterialBrandTypes(),
  129. setMaterialsManageBrand(),
  130. setMaterialOperationTypes(),
  131. setBanners(),
  132. setBannersLogo(),
  133. setMaterials(),
  134. ])
  135. console.log('setBannersLogo', bannersLogo.value)
  136. })
  137. </script>
  138. <template>
  139. <view class="">
  140. <view class="bg-black w-full pos-relative aspect-[1.26/1]">
  141. <Banner
  142. :mode="BannerMode.Material"
  143. aspect="1.26/1"
  144. customIndicatorClass="customIndicatorClass"
  145. ></Banner>
  146. </view>
  147. <view class="bg-[#f5f5f5] relative bottom-4 rounded-t-2xl py-1">
  148. <div class="my-6 grid grid-cols-2 grid-gap-3.5 mx-3.5">
  149. <template v-for="it of pieces" :key="it.title">
  150. <div :class="it.gridItemClass" @click="handleMenuItemClick(it)">
  151. <card custom-class="flex justify-between items-center gap-2">
  152. <view class="flex items-end justify-end">
  153. <wd-img :src="it.icon" :width="42" :height="42"></wd-img>
  154. </view>
  155. <div class="flex-1 flex flex-col justify-around h-full">
  156. <div
  157. class="text-black/80 text-base font-normal font-['PingFang_SC'] leading-[10.18px]"
  158. >
  159. {{ it.title }}
  160. </div>
  161. <div
  162. class="mt-1 text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal"
  163. >
  164. {{ it.desc }}
  165. </div>
  166. </div>
  167. <div v-if="it.isMore" class="mr--4">
  168. <wd-button
  169. custom-class="text-black/40!"
  170. type="icon"
  171. icon="arrow-right"
  172. icon-color=""
  173. ></wd-button>
  174. </div>
  175. </card>
  176. </div>
  177. </template>
  178. </div>
  179. <!-- <template v-for="({ brandLevelName, materialsList }, i) in materialDealerData" :key="i">
  180. <SectionHeading :title="brandLevelName" custom-class="mx-3.5"></SectionHeading>
  181. </template> -->
  182. <div class="mx-14px py-3.5 bg-[#fff] rounded-2xl">
  183. <div class="text-center text-sm font-bold text-black/85 mb-3.5">合作商家</div>
  184. <div class="px-3.5 grid grid-cols-2 gap-x-2.5 gap-y-4">
  185. <wd-img
  186. width="100%"
  187. height="30"
  188. src="https://image.zhuchaohui.com/zhucaohui/e9352960e272c774da6aa8618691b3bbdbaa5b906c9c4ef2513db2695435a713.jpg"
  189. ></wd-img>
  190. <wd-img
  191. width="100%"
  192. height="30"
  193. src="https://image.zhuchaohui.com/zhucaohui/e9352960e272c774da6aa8618691b3bbdbaa5b906c9c4ef2513db2695435a713.jpg"
  194. ></wd-img>
  195. </div>
  196. </div>
  197. <div class="text-black/85 mx-14px">
  198. <div class="flex items-center justify-between py-3.5">
  199. <div class="text-xl">积分商家</div>
  200. <div class="text-sm text-black/65 flex items-center px-2.5">
  201. <div
  202. class="w-100px text-right flex items-center justify-end"
  203. @click="handleTranslateType('brandType')"
  204. >
  205. <div
  206. :class="[
  207. translateType === 'brandType' || searchParams.manageBrandSet.length > 0
  208. ? 'color-[#0CBE7D]'
  209. : '',
  210. ]"
  211. >
  212. 品牌
  213. </div>
  214. <wd-icon
  215. :color="
  216. translateType === 'brandType' || searchParams.manageBrandSet.length > 0
  217. ? '#0CBE7D'
  218. : ''
  219. "
  220. :name="
  221. translateType === 'brandType' || searchParams.manageBrandSet.length > 0
  222. ? 'caret-down-small'
  223. : 'caret-up-small'
  224. "
  225. size="14px"
  226. ></wd-icon>
  227. </div>
  228. <div
  229. class="w-100px text-right flex items-center justify-end"
  230. @click="handleTranslateType('manageType')"
  231. >
  232. <div
  233. :class="[
  234. translateType === 'manageType' || searchParams.manageTypeSet.length > 0
  235. ? 'color-[#0CBE7D]'
  236. : '',
  237. ]"
  238. >
  239. 类型
  240. </div>
  241. <wd-icon
  242. :color="
  243. translateType === 'manageType' || searchParams.manageTypeSet.length > 0
  244. ? '#0CBE7D'
  245. : ''
  246. "
  247. :name="
  248. translateType === 'manageType' || searchParams.manageTypeSet.length > 0
  249. ? 'caret-down-small'
  250. : 'caret-up-small'
  251. "
  252. size="14px"
  253. ></wd-icon>
  254. </div>
  255. </div>
  256. </div>
  257. <!-- 查询条件 -->
  258. <div
  259. class="rounded-xl bg-[#fff] overflow-hidden ease-in-out transition-property-[height] duration-300"
  260. :class="translateType ? 'h-auto' : 'h-0'"
  261. v-if="translateType"
  262. >
  263. <template v-if="translateType === 'brandType'">
  264. <wd-checkbox-group v-model="searchParams.manageBrandSet" cell shape="button">
  265. <wd-checkbox
  266. v-for="it in materialsManageBrand"
  267. checked-color="#0CBE7D"
  268. :key="it.value"
  269. :modelValue="it.value"
  270. >
  271. {{ it.label }}
  272. </wd-checkbox>
  273. </wd-checkbox-group>
  274. </template>
  275. <template v-else>
  276. <wd-checkbox-group v-model="searchParams.manageTypeSet" cell shape="button">
  277. <wd-checkbox
  278. v-for="it in materialOperationTypes"
  279. checked-color="#0CBE7D"
  280. :key="it.value"
  281. :modelValue="it.value"
  282. >
  283. {{ it.label }}
  284. </wd-checkbox>
  285. </wd-checkbox-group>
  286. </template>
  287. <!-- 确定按钮 -->
  288. <div class="flex items-center justify-between pb-20px pt-10px">
  289. <wd-button plain type="success" custom-class="h-38px! w-154px!" @click="resetSearch">
  290. 重置
  291. </wd-button>
  292. <wd-button type="success" custom-class="h-38px! w-154px!" @click="submitSearch">
  293. 确认
  294. </wd-button>
  295. </div>
  296. </div>
  297. </div>
  298. <div class="px-3.5 pb-3.5">
  299. <template v-for="([key, it], i) in Object.entries(materials)" :key="i">
  300. <div class="flex items-center gap-2 py-4">
  301. {{ key.toString() }}
  302. </div>
  303. <div class="grid grid-cols-2 gap-x-2.5 gap-y-4">
  304. <Card class="h-full" v-for="item in it" :key="item.id">
  305. <div class="flex flex-col items-center" @click="toDetail(item.id)">
  306. <wd-img
  307. width="78"
  308. height="78"
  309. custom-class="border border-[#f2f2f2] border-solid rounded-full overflow-hidden"
  310. :src="item.logoUrl"
  311. ></wd-img>
  312. <div
  313. class="my-4 text-black/90 text-base font-normal font-['PingFang_SC'] leading-[10.18px]"
  314. >
  315. {{ item.materialsName }}
  316. </div>
  317. <div
  318. class="mb-4 text-black/60 text-sm font-normal font-['PingFang_SC'] leading-[10.18px]"
  319. >
  320. <!-- 进口品牌 -->
  321. {{
  322. (item.brandType,
  323. materialBrandTypes.find(({ value }) => value === String(item.brandType))?.label)
  324. }}
  325. |
  326. {{
  327. materialOperationTypes
  328. .filter(({ value }) => item.manageType.includes(Number.parseInt(value)))
  329. .map((i) => i.label)?.[0]
  330. }}
  331. </div>
  332. <div @click.stop>
  333. <wd-button
  334. size="small"
  335. custom-class="my-4"
  336. @click.stop="() => ((dealerPanelState = true), (currentDeraler = item))"
  337. >
  338. 联系商家
  339. </wd-button>
  340. </div>
  341. <div
  342. class="text-black/30 text-xs font-normal font-['PingFang_SC'] leading-[10.18px]"
  343. >
  344. {{ item.virtualArrival || item.cumulativeStoreNum || 0 }}次到店打卡
  345. </div>
  346. </div>
  347. </Card>
  348. </div>
  349. </template>
  350. <template v-if="Object.keys(materials).length === 0">
  351. <div class="flex-grow flex flex-col justify-center">
  352. <wd-status-tip :image="NetImages.NotContent" tip="暂无内容"></wd-status-tip>
  353. </div>
  354. </template>
  355. </div>
  356. </view>
  357. <wd-overlay :show="dealerPanelState" @click="dealerPanelState = false">
  358. <view class="wrapper flex flex-col justify-end h-full">
  359. <div class="w-full flex justify-end mb-4">
  360. <div class="mr-3.5">
  361. <wd-button type="text" custom-class="w-8! h-8! p-0!" size="small">
  362. <wd-img :src="close" width="28" height="28" custom-class="vertical-bottom"></wd-img>
  363. </wd-button>
  364. </div>
  365. </div>
  366. <div class="bg-neutral-100 rounded-tl-2xl rounded-tr-2xl p-3.5" @click.stop="">
  367. <div class="flex flex-col">
  368. <template
  369. v-for="(
  370. { shopAddr, shopName, shopContactPhone, ...shop }, i
  371. ) in currentDeraler?.shopList"
  372. :key="i"
  373. >
  374. <div class="bg-white rounded-2.5 p-3.5 flex items-center">
  375. <div class="text-black/40 flex-1 border-r-2 border-r-[#f6f6f6] border-r-solid pr-4">
  376. <div
  377. class="text-black/90 text-lg font-normal font-['PingFang_SC'] leading-normal"
  378. >
  379. {{ shopName }}
  380. </div>
  381. <div>
  382. <wd-icon name="location" size="15"></wd-icon>
  383. <span
  384. class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal"
  385. >
  386. {{ shopAddr }}
  387. </span>
  388. </div>
  389. </div>
  390. <wd-button
  391. type="text"
  392. size="small"
  393. custom-class=" bg-[#f2f2f2]! p-0! ml-4"
  394. @click="handleCall(shopContactPhone)"
  395. >
  396. <wd-img width="28" height="28" :src="phone"></wd-img>
  397. </wd-button>
  398. <wd-button
  399. type="text"
  400. size="small"
  401. custom-class=" bg-[#f2f2f2]! p-0! ml-4"
  402. @click="
  403. openLocation({
  404. latitude: shop.longitude,
  405. longitude: shop.latitude,
  406. name: shopName,
  407. address: shopAddr,
  408. })
  409. "
  410. >
  411. <wd-img width="28" height="28" :src="routerIcon"></wd-img>
  412. </wd-button>
  413. </div>
  414. </template>
  415. </div>
  416. </div>
  417. </view>
  418. </wd-overlay>
  419. </view>
  420. </template>
  421. <style lang="scss">
  422. :deep(.customIndicatorClass) {
  423. bottom: 80rpx !important;
  424. }
  425. :deep(.wd-checkbox__btn-check) {
  426. display: none !important;
  427. }
  428. :deep(.wd-checkbox.is-button.is-checked .wd-checkbox__label) {
  429. background-color: rgba($color: #0cbe7d, $alpha: 0.06);
  430. }
  431. </style>