index.vue 10 KB

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