index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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 SectionHeading from '@/components/section-heading.vue'
  7. import { abc } from '../../core/libs/pngs'
  8. import { getAppMaterials, getBanners, getByDictType, getMaterials } from '../../core/libs/requests'
  9. import { close, phone } from '../../core/libs/svgs'
  10. import { BannerMode, DictType, MaterialDealer, MaterialsList } from '../../core/libs/models'
  11. import routerIcon from '@designer-hub/assets/src/assets/svgs/router'
  12. import Banner from '@/pages/home/components/banner.vue'
  13. // import materialDealers from '@designer-hub/assets/src/libs/assets/materialDealers'
  14. import { useRouter } from '../../core/utils/router'
  15. import PageHelperEvo from '@/components/page-helper-evo.vue'
  16. import { handleCall, openLocation } from '../../core/utils/common'
  17. const router = useRouter()
  18. const { data: materialDealerData, run: setMaterialDealerData } = useRequest(
  19. () => getAppMaterials(),
  20. { initialData: [] },
  21. )
  22. const { data: materialOperationTypes, run: setMaterialOperationTypes } = useRequest(
  23. () => getByDictType(DictType.memberMaterialsOperationType),
  24. { initialData: [] },
  25. )
  26. const { data: materialBrandTypes, run: setMaterialBrandTypes } = useRequest(
  27. () => getByDictType(DictType.memberMaterialsBrandType),
  28. { initialData: [] },
  29. )
  30. const { data: banners, run: setBanners } = useRequest(
  31. () => getBanners({ mode: BannerMode.Material }),
  32. { initialData: [] },
  33. )
  34. const dealerPanelState = ref(false)
  35. const currentDeraler = ref<MaterialDealer>()
  36. const pieces = ref([
  37. {
  38. title: '材料小课堂',
  39. desc: '全方位了解',
  40. icon: abc,
  41. gridItemClass: 'col-start-1 row-start-1',
  42. path: '/pages/material/mini-class/index',
  43. },
  44. {
  45. title: '推荐材料商',
  46. desc: '优选推荐商',
  47. icon: 'https://image.zhuchaohui.com/zhucaohui/86236d61c75904763cd1247db239b25fa2d8cb8222e4575d29581f58e5d69036.png',
  48. gridItemClass: 'col-start-2 row-start-1',
  49. path: '/pages/material/recommend/index',
  50. isMore: false,
  51. },
  52. // {
  53. // title: '积分计算机',
  54. // desc: '积分小帮手',
  55. // icon: calculator,
  56. // gridItemClass: 'col-start-2 row-start-1',
  57. // path: '/pages/material/calculator/index',
  58. // },
  59. // {
  60. // title: '推荐材料商',
  61. // desc: '我们将优先洽谈大家推荐的材料商',
  62. // icon: materialDealers,
  63. // gridItemClass: 'col-start-1 col-end-3 row-start-2',
  64. // isMore: true,
  65. // path: '/pages/material/recommend/index',
  66. // },
  67. ])
  68. const current = ref<number>(0)
  69. const swiperList = computed(() => banners.value.map((it) => it.bannerImgUrl))
  70. const materialsByBrandLevel = ref<{ list: MaterialDealer[] }[]>([])
  71. const handleMenuItemClick = ({ path }: any) => {
  72. router.push(path)
  73. }
  74. const toDetail = (id: number) => {
  75. uni.navigateTo({
  76. url: `/pages/material/detail/index?id=${id}`,
  77. })
  78. }
  79. function handleClick(e) {
  80. console.log(e)
  81. }
  82. function onChange(e) {
  83. console.log(e)
  84. }
  85. onMounted(async () => {
  86. await setMaterialDealerData()
  87. console.log(materialDealerData.value)
  88. await Promise.all([setMaterialBrandTypes(), setMaterialOperationTypes(), setBanners()])
  89. // const reqs = data.value.map((it) =>
  90. // getMaterials({ brandLevel: it.value }).then(({ data }) => data),
  91. // )
  92. // materialsByBrandLevel.value = await Promise.all(reqs)
  93. // console.log(materialsByBrandLevel.value)
  94. // const res = await getAppMaterials()
  95. // console.log(res)
  96. })
  97. </script>
  98. <template>
  99. <view class="">
  100. <view class="bg-black w-full pos-relative aspect-[1.26/1]">
  101. <!-- <wd-img
  102. width="100%"
  103. height="100%"
  104. src="https://image.zhuchaohui.com/zhucaohui/f866f4f72392e8f4627d8f5d6628739ad7f0907d3703139e7cdbcb999b803dfe.jpg"
  105. /> -->
  106. <!-- <wd-swiper
  107. custom-class="rounded-2xl overflow-hidden aspect-[1.26/1]"
  108. width="100%"
  109. height="100%"
  110. :list="swiperList"
  111. autoplay
  112. v-model:current="current"
  113. :indicator="{ type: 'dots-bar' } as any"
  114. @click="handleClick"
  115. @change="onChange"
  116. ></wd-swiper> -->
  117. <Banner
  118. :mode="BannerMode.Material"
  119. aspect="1.26/1"
  120. customIndicatorClass="customIndicatorClass"
  121. ></Banner>
  122. </view>
  123. <view class="bg-[#f5f5f5] relative bottom-4 rounded-t-2xl py-1">
  124. <div class="my-6 grid grid-cols-2 grid-gap-3.5 mx-3.5">
  125. <template v-for="it of pieces" :key="it.title">
  126. <div :class="it.gridItemClass" @click="handleMenuItemClick(it)">
  127. <card custom-class="flex justify-between items-center gap-2">
  128. <view class="flex items-end justify-end">
  129. <wd-img :src="it.icon" :width="42" :height="42"></wd-img>
  130. </view>
  131. <div class="flex-1 flex flex-col justify-around h-full">
  132. <div
  133. class="text-black/80 text-base font-normal font-['PingFang_SC'] leading-[10.18px]"
  134. >
  135. {{ it.title }}
  136. </div>
  137. <div
  138. class="mt-1 text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal"
  139. >
  140. {{ it.desc }}
  141. </div>
  142. </div>
  143. <div v-if="it.isMore" class="mr--4">
  144. <wd-button
  145. custom-class="text-black/40!"
  146. type="icon"
  147. icon="arrow-right"
  148. icon-color=""
  149. ></wd-button>
  150. </div>
  151. </card>
  152. </div>
  153. </template>
  154. </div>
  155. <!-- <template v-for="({ brandLevelName, materialsList }, i) in materialDealerData" :key="i">
  156. <SectionHeading :title="brandLevelName" custom-class="mx-3.5"></SectionHeading>
  157. </template> -->
  158. <SectionHeading :title="'积分商家'" custom-class="mx-3.5"></SectionHeading>
  159. <PageHelperEvo :request="getMaterials" :query="{}">
  160. <template #default="{ source }">
  161. <div class="my-6 px-3.5 grid grid-cols-2 gap-x-2.5 gap-y-4">
  162. <template v-for="(it, i) in source.list" :key="i">
  163. <div class="" @click="toDetail(it.id)">
  164. <Card class="h-full">
  165. <div class="flex flex-col items-center">
  166. <wd-img
  167. width="78"
  168. height="78"
  169. custom-class="border border-[#f2f2f2] border-solid rounded-full overflow-hidden"
  170. :src="it.logoUrl"
  171. ></wd-img>
  172. <div
  173. class="my-4 text-black/90 text-base font-normal font-['PingFang_SC'] leading-[10.18px]"
  174. >
  175. {{ it.materialsName }}
  176. </div>
  177. <div
  178. class="mb-4 text-black/60 text-sm font-normal font-['PingFang_SC'] leading-[10.18px]"
  179. >
  180. <!-- 进口品牌 -->
  181. {{
  182. (it.brandType,
  183. materialBrandTypes.find(({ value }) => value === String(it.brandType))
  184. ?.label)
  185. }}
  186. |
  187. {{
  188. materialOperationTypes.find(({ value }) => value === String(it.manageType))
  189. ?.label
  190. }}
  191. </div>
  192. <div @click.stop>
  193. <wd-button
  194. size="small"
  195. custom-class="my-4"
  196. @click.stop="() => ((dealerPanelState = true), (currentDeraler = it))"
  197. >
  198. 联系商家
  199. </wd-button>
  200. </div>
  201. <div
  202. class="text-black/30 text-xs font-normal font-['PingFang_SC'] leading-[10.18px]"
  203. >
  204. {{ it.virtualArrival || it.cumulativeStoreNum || 0 }}次到店打卡
  205. </div>
  206. </div>
  207. </Card>
  208. </div>
  209. </template>
  210. </div>
  211. </template>
  212. </PageHelperEvo>
  213. </view>
  214. <!-- <wd-action-sheet v-model="dealerPanelState">
  215. <div class="relative absolute">
  216. <div class="absolute top--4">x</div>
  217. </div>
  218. <view style="padding: 15px 15px 150px 15px">内容</view>
  219. </wd-action-sheet> -->
  220. <wd-overlay :show="dealerPanelState" @click="dealerPanelState = false">
  221. <view class="wrapper flex flex-col justify-end h-full">
  222. <div class="w-full flex justify-end mb-4">
  223. <div class="mr-3.5">
  224. <wd-button type="text" custom-class="w-8! h-8! p-0!" size="small">
  225. <wd-img :src="close" width="28" height="28" custom-class="vertical-bottom"></wd-img>
  226. </wd-button>
  227. </div>
  228. </div>
  229. <div class="bg-neutral-100 rounded-tl-2xl rounded-tr-2xl p-3.5" @click.stop="">
  230. <div class="flex flex-col">
  231. <template
  232. v-for="(
  233. { shopAddr, shopName, shopContactPhone, ...shop }, i
  234. ) in currentDeraler?.shopList"
  235. :key="i"
  236. >
  237. <div class="bg-white rounded-2.5 p-3.5 flex items-center">
  238. <div class="text-black/40 flex-1 border-r-2 border-r-[#f6f6f6] border-r-solid pr-4">
  239. <div
  240. class="text-black/90 text-lg font-normal font-['PingFang_SC'] leading-normal"
  241. >
  242. {{ shopName }}
  243. </div>
  244. <div>
  245. <wd-icon name="location" size="15"></wd-icon>
  246. <span
  247. class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal"
  248. >
  249. {{ shopAddr }}
  250. </span>
  251. </div>
  252. </div>
  253. <wd-button
  254. type="text"
  255. size="small"
  256. custom-class=" bg-[#f2f2f2]! p-0! ml-4"
  257. @click="handleCall(shopContactPhone)"
  258. >
  259. <wd-img width="28" height="28" :src="phone"></wd-img>
  260. </wd-button>
  261. <wd-button
  262. type="text"
  263. size="small"
  264. custom-class=" bg-[#f2f2f2]! p-0! ml-4"
  265. @click="
  266. openLocation({
  267. latitude: shop.longitude,
  268. longitude: shop.latitude,
  269. name: shopName,
  270. address: shopAddr,
  271. })
  272. "
  273. >
  274. <wd-img width="28" height="28" :src="routerIcon"></wd-img>
  275. </wd-button>
  276. </div>
  277. </template>
  278. </div>
  279. </div>
  280. </view>
  281. </wd-overlay>
  282. </view>
  283. </template>
  284. <style lang="scss">
  285. :deep(.customIndicatorClass) {
  286. bottom: 80rpx !important;
  287. }
  288. </style>