productDetail.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. <route lang="json5" type="page">
  2. {
  3. layout: 'default',
  4. style: {
  5. navigationStyle: 'custom',
  6. },
  7. }
  8. </route>
  9. <script lang="ts" setup>
  10. // 必须导入需要用到的页面生命周期(即使在当前页面上没有直接使用到)
  11. // eslint-disable-next-line unused-imports/no-unused-imports
  12. import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
  13. import useZPaging from 'z-paging/components/z-paging/js/hooks/useZPaging.js'
  14. import { myFavoriteAdd, myFavoriteDel } from '@/api/mine'
  15. import { preOrder as _preOrder } from '@/api/order'
  16. import { carousel, getDetail, pinkList } from '@/api/product'
  17. import { requireLogin } from '@/hooks/usePageAuth'
  18. import { t } from '@/locale'
  19. import { formatNumber } from '@/utils/index'
  20. import { goBack, toPage } from '@/utils/page'
  21. import { toast } from '@/utils/toast'
  22. import CustomTooltip from './components/CustomTooltip.vue'
  23. import NotificationCarousel from './components/NotificationCarousel.vue'
  24. defineOptions({
  25. name: 'ProductDetail', // 商品详情
  26. })
  27. // 获取屏幕边界到安全区域距离
  28. const systemInfo = uni.getSystemInfoSync()
  29. const safeAreaInsets = systemInfo.safeAreaInsets
  30. // z-paging
  31. const paging = ref(null)
  32. // 类似mixins,如果是页面滚动务必要写这一行,并传入当前ref绑定的paging,注意此处是paging,而非paging.value
  33. useZPaging(paging)
  34. function goHome() {
  35. uni.switchTab({
  36. url: '/pages/index/index',
  37. })
  38. }
  39. // 添加导航栏背景色变量
  40. const navBgColor = ref('transparent')
  41. const changeNavbarThreshold = 300 // 滚动到这个高度时改变导航栏颜色
  42. const showTip = ref(false)
  43. onPageScroll((e) => {
  44. // 根据滚动高度改变导航栏背景色
  45. if (e.scrollTop > changeNavbarThreshold) {
  46. navBgColor.value = '#ffffff'
  47. }
  48. else {
  49. navBgColor.value = 'transparent'
  50. }
  51. })
  52. const productId = ref('') // 商品id
  53. const isPageLoading = ref(true) // 页面加载状态
  54. const detail = ref<any>({
  55. sliderImage: '',
  56. flatPattern: '',
  57. })
  58. const pinkInfo = ref<any>([])
  59. // 添加通知轮播数据
  60. const notifications = ref([
  61. { id: 1, name: 'Aamir Khan', time: '10s' },
  62. { id: 2, name: 'John Smith', time: '30s' },
  63. { id: 3, name: 'Maria Garcia', time: '1m' },
  64. ])
  65. async function getCarousel() {
  66. const res = await carousel(productId.value)
  67. notifications.value = res.data
  68. }
  69. // 点击页面任意地方隐藏提示
  70. function handlePageClick() {
  71. if (showTip.value) {
  72. showTip.value = false
  73. }
  74. }
  75. // 生命周期钩子
  76. onMounted(() => {
  77. showTip.value = true // 显示提示
  78. })
  79. // 搜索结果
  80. // 轮播图
  81. const current = ref<number>(0)
  82. // 拼团类型 join-加团 open-开团
  83. const groupType = ref('open')
  84. const pinkId = ref('') // 拼团id
  85. const joinOrderId = ref('') // 加团的拼团-订单id
  86. // sku 逻辑
  87. const showSku = ref(false)
  88. function openSku(type: string, id?: string, pinkOrderId?: string) {
  89. groupType.value = type
  90. // 区分不同的入团场景
  91. if (type === 'join') {
  92. if (id && pinkOrderId) {
  93. // 从拼团列表点击入团 - 加入指定拼团
  94. pinkId.value = id
  95. joinOrderId.value = pinkOrderId
  96. }
  97. else {
  98. // 从底部按钮点击入团 - 清空之前的参数,避免参数混乱
  99. pinkId.value = ''
  100. joinOrderId.value = ''
  101. }
  102. }
  103. else {
  104. // 开团场景 - 清空拼团相关参数
  105. pinkId.value = ''
  106. joinOrderId.value = ''
  107. }
  108. showSku.value = true
  109. }
  110. const formData = ref({
  111. productNum: 1,
  112. selectedSpecs: {}, // 存储选中的规格 { 颜色: '红色', 尺寸: 'M' }
  113. })
  114. const matchedAttrValue = ref<any>({})
  115. // 计算选中规格的文案
  116. const selectedSpecsText = computed(() => {
  117. if (!formData.value.selectedSpecs || Object.keys(formData.value.selectedSpecs).length === 0) {
  118. return ''
  119. }
  120. // 按照attr的顺序生成文案
  121. const specTexts = []
  122. if (detail.value.attr) {
  123. detail.value.attr.forEach((attr) => {
  124. const selectedValue = formData.value.selectedSpecs[attr.attrName]
  125. if (selectedValue) {
  126. specTexts.push(`${attr.attrName}: ${selectedValue}`)
  127. }
  128. })
  129. }
  130. return specTexts.length > 0 ? ` ${specTexts.join(',')}` : ''
  131. })
  132. // 选择规格方法
  133. function selectSpec(attrName, specValue) {
  134. formData.value.selectedSpecs[attrName] = specValue
  135. // 按照attr的顺序重新构建对象
  136. const orderedSpecs = {}
  137. if (detail.value.attr) {
  138. detail.value.attr.forEach((attr) => {
  139. if (formData.value.selectedSpecs[attr.attrName]) {
  140. orderedSpecs[attr.attrName] = formData.value.selectedSpecs[attr.attrName]
  141. }
  142. })
  143. }
  144. // 打印当前选中的规格
  145. const selectedSpecsJson = JSON.stringify(orderedSpecs)
  146. console.log('当前选中规格:', selectedSpecsJson)
  147. // 检查是否所有规格都已选中
  148. const totalAttrs = detail.value.attr ? detail.value.attr.length : 0
  149. const selectedAttrs = Object.keys(orderedSpecs).length
  150. if (selectedAttrs === totalAttrs && totalAttrs > 0) {
  151. // 所有规格都选中了,匹配 attrValue
  152. matchedAttrValue.value = findMatchingAttrValue(orderedSpecs)
  153. if (matchedAttrValue.value) {
  154. console.log('匹配到的规格组合:', matchedAttrValue.value)
  155. console.log('对应的图片:', matchedAttrValue.value.image)
  156. }
  157. else {
  158. console.log('未找到匹配的规格组合')
  159. }
  160. }
  161. }
  162. // 匹配 attrValue 中对应的规格组合
  163. function findMatchingAttrValue(selectedSpecs) {
  164. if (!detail.value.attrValue || !Array.isArray(detail.value.attrValue)) {
  165. return null
  166. }
  167. return detail.value.attrValue.find((attrValue) => {
  168. // 将 attrValue 的规格转换为对象进行比较
  169. const attrValueSpecs = {}
  170. if (attrValue.suk) {
  171. // 假设 suk 格式类似 "红色,M" 或者其他分隔符
  172. const sukParts = attrValue.suk.split(',')
  173. if (detail.value.attr && sukParts.length === detail.value.attr.length) {
  174. detail.value.attr.forEach((attr, index) => {
  175. attrValueSpecs[attr.attrName] = sukParts[index].trim()
  176. })
  177. }
  178. }
  179. // 比较选中的规格和当前 attrValue 的规格是否完全匹配
  180. const selectedKeys = Object.keys(selectedSpecs)
  181. const attrValueKeys = Object.keys(attrValueSpecs)
  182. if (selectedKeys.length !== attrValueKeys.length) {
  183. return false
  184. }
  185. return selectedKeys.every(key => selectedSpecs[key] === attrValueSpecs[key])
  186. })
  187. }
  188. // 查询商品详情
  189. async function queryDetail() {
  190. const res = await getDetail({ id: productId.value })
  191. console.log(res)
  192. detail.value = res.data
  193. // 默认选择第一个规格
  194. setDefaultSpecs()
  195. paging.value.complete()
  196. }
  197. // 查询商品拼团信息
  198. async function queryPinkInfo() {
  199. const res = await pinkList({ cid: detail.value.cid })
  200. if (res.code === '200') {
  201. const result = []
  202. // 循环截取:每次从 i 开始,取 maxLength 个元素
  203. for (let i = 0; i < res.data.list.length; i += 3) {
  204. const subArr = res.data.list.slice(i, i + 3)
  205. result.push(subArr)
  206. }
  207. console.log(result)
  208. pinkInfo.value = result
  209. }
  210. }
  211. // 设置默认规格选择
  212. function setDefaultSpecs() {
  213. if (detail.value.attr && detail.value.attr.length > 0) {
  214. const defaultSpecs = {}
  215. // 为每个规格属性选择第一个值
  216. detail.value.attr.forEach((attr) => {
  217. if (attr.attrImgValues && attr.attrImgValues.length > 0) {
  218. defaultSpecs[attr.attrName] = attr.attrImgValues[0].name
  219. }
  220. })
  221. // 更新选中的规格
  222. formData.value.selectedSpecs = defaultSpecs
  223. // 按照attr的顺序重新构建对象
  224. const orderedSpecs = {}
  225. detail.value.attr.forEach((attr) => {
  226. if (formData.value.selectedSpecs[attr.attrName]) {
  227. orderedSpecs[attr.attrName] = formData.value.selectedSpecs[attr.attrName]
  228. }
  229. })
  230. // 匹配对应的规格组合
  231. matchedAttrValue.value = findMatchingAttrValue(orderedSpecs)
  232. if (matchedAttrValue.value) {
  233. console.log('默认选中规格:', JSON.stringify(orderedSpecs))
  234. console.log('默认匹配到的规格组合:', matchedAttrValue.value)
  235. console.log('默认对应的图片:', matchedAttrValue.value.image)
  236. }
  237. }
  238. }
  239. // 收藏/取消收藏
  240. async function toggleFavorite() {
  241. if (!requireLogin()) {
  242. return
  243. }
  244. try {
  245. if (detail.value.favoriteFlag) {
  246. // 取消收藏
  247. const res = await myFavoriteDel({ id: detail.value.favoriteId })
  248. if (res.code === '200') {
  249. await queryDetail()
  250. toast.success(t('productDetail.unfavoriteSuccess'))
  251. }
  252. }
  253. else {
  254. // 添加收藏
  255. const res = await myFavoriteAdd({ productIdList: [productId.value] })
  256. if (res.code === '200') {
  257. await queryDetail() // 重新获取详情,更新 favoriteId
  258. toast.success(t('productDetail.favoriteSuccess'))
  259. }
  260. }
  261. }
  262. catch (error) {
  263. console.error('收藏操作失败:', error)
  264. }
  265. }
  266. const loading = ref<boolean>(false)
  267. // 预下单
  268. async function preOrder() {
  269. if (!requireLogin()) {
  270. return
  271. }
  272. loading.value = true
  273. try {
  274. const data = {
  275. orderDetails: {
  276. attrValueId: matchedAttrValue.value.id,
  277. productId: productId.value,
  278. cid: detail.value.cid,
  279. productNum: formData.value.productNum,
  280. },
  281. preOrderType: 'buyNow',
  282. }
  283. const res = await _preOrder(data)
  284. if (res.code === '200') {
  285. showSku.value = false
  286. toPage(
  287. {
  288. url: '/pages/productDetail/checkOut',
  289. params: {
  290. preOrderId: res.data,
  291. joinOrderId: joinOrderId.value,
  292. pinkId: pinkId.value,
  293. cid: detail.value.cid,
  294. groupType: groupType.value,
  295. },
  296. },
  297. )
  298. }
  299. }
  300. finally {
  301. loading.value = false
  302. }
  303. }
  304. // 商品详情初始化
  305. onLoad((options) => {
  306. productId.value = options.productId || ''
  307. })
  308. onShow(async () => {
  309. try {
  310. isPageLoading.value = true
  311. getCarousel()
  312. await queryDetail()
  313. await queryPinkInfo()
  314. }
  315. finally {
  316. isPageLoading.value = false
  317. }
  318. })
  319. </script>
  320. <template>
  321. <z-paging ref="paging" :use-page-scroll="!showSku" refresher-only @on-refresh="queryDetail" @click="handlePageClick">
  322. <wd-navbar :bordered="false" safe-area-inset-top fixed :left-arrow="false" :custom-style="`background: ${navBgColor}; transition: background 0.3s;`" custom-class="h-auto!">
  323. <template #title>
  324. <view class="box-border h-full flex items-center justify-between p-24rpx">
  325. <image :src="`/static/icons/left-icon${navBgColor === '#ffffff' ? '-tr' : ''}.png`" class="h-56rpx w-56rpx" @click="() => goBack()" />
  326. <image :src="`/static/icons/share-icon${navBgColor === '#ffffff' ? '-tr' : ''}.png`" class="h-56rpx w-56rpx" @click="() => goBack()" />
  327. </view>
  328. </template>
  329. </wd-navbar>
  330. <!-- 页面加载时显示骨架屏 -->
  331. <template v-if="isPageLoading">
  332. <!-- 轮播图骨架屏 -->
  333. <wd-skeleton
  334. :row-col="[{ height: '750rpx' }]"
  335. animation="gradient"
  336. />
  337. <!-- 价格区域骨架屏 -->
  338. <view class="relative -top-24rpx">
  339. <view class="rounded-t-24rpx bg-white px-24rpx pb-24rpx pt-18rpx">
  340. <wd-skeleton
  341. :row-col="[
  342. { width: '200rpx', height: '40rpx' }, // 价格标签
  343. { width: '300rpx', height: '60rpx', marginTop: '12rpx' }, // 价格数值
  344. { width: '150rpx', height: '32rpx', marginTop: '16rpx' }, // 销量
  345. ]"
  346. animation="gradient"
  347. />
  348. </view>
  349. <view class="bg-white px-24rpx pb-24rpx pt-20rpx">
  350. <wd-skeleton
  351. :row-col="[
  352. { width: '100%', height: '60rpx' }, // 商品标题
  353. { width: '200rpx', height: '40rpx', marginTop: '16rpx' }, // 规格选择
  354. ]"
  355. animation="gradient"
  356. />
  357. </view>
  358. </view>
  359. <!-- 拼团规则骨架屏 -->
  360. <view class="mb-20rpx bg-white p-24rpx">
  361. <wd-skeleton
  362. :row-col="[
  363. { width: '200rpx', height: '40rpx' }, // 标题
  364. { width: '100%', height: '200rpx', marginTop: '20rpx' }, // 图片
  365. ]"
  366. animation="gradient"
  367. />
  368. </view>
  369. <!-- 拼团信息骨架屏 -->
  370. <view class="mb-20rpx bg-white px-24rpx pt-24rpx">
  371. <wd-skeleton
  372. :row-col="[
  373. { width: '200rpx', height: '40rpx' }, // 标题
  374. // 拼团列表项
  375. [
  376. [
  377. { width: '56rpx', height: '56rpx', type: 'circle' },
  378. { width: '56rpx', height: '56rpx', type: 'circle', marginLeft: '8rpx' },
  379. { width: '56rpx', height: '56rpx', type: 'circle', marginLeft: '8rpx' },
  380. ],
  381. { width: '200rpx', height: '28rpx', marginLeft: '16rpx' },
  382. { width: '120rpx', height: '60rpx', marginLeft: 'auto' },
  383. ],
  384. [
  385. [
  386. { width: '56rpx', height: '56rpx', type: 'circle' },
  387. { width: '56rpx', height: '56rpx', type: 'circle', marginLeft: '8rpx' },
  388. ],
  389. { width: '200rpx', height: '28rpx', marginLeft: '16rpx' },
  390. { width: '120rpx', height: '60rpx', marginLeft: 'auto' },
  391. ],
  392. ]"
  393. animation="gradient"
  394. />
  395. </view>
  396. <!-- 商品详情骨架屏 -->
  397. <view class="bg-white p-24rpx">
  398. <wd-skeleton
  399. :row-col="[
  400. { width: '200rpx', height: '40rpx' }, // 标题
  401. { width: '100%', height: '400rpx', marginTop: '20rpx' }, // 详情图1
  402. { width: '100%', height: '400rpx', marginTop: '20rpx' }, // 详情图2
  403. { width: '100%', height: '400rpx', marginTop: '20rpx' }, // 详情图3
  404. ]"
  405. animation="gradient"
  406. />
  407. </view>
  408. </template>
  409. <!-- 实际内容 -->
  410. <template v-else>
  411. <view class="relative">
  412. <wd-swiper
  413. v-model:current="current" :list="detail.sliderImage.split(',')" autoplay height="750rpx"
  414. custom-indicator-class="bottom-40rpx!" :indicator="{ type: 'fraction' }" indicator-position="bottom-right"
  415. image-mode="aspectFit"
  416. />
  417. <NotificationCarousel
  418. :notifications="notifications"
  419. :top="`${safeAreaInsets?.top + 52}px`"
  420. />
  421. </view>
  422. <view class="relative -top-24rpx">
  423. <view
  424. class="flex items-center justify-between rounded-t-24rpx from-[#FF3779] to-[#FF334A] bg-gradient-to-br px-24rpx pb-24rpx pt-18rpx text-white"
  425. >
  426. <view>
  427. <view class="mb-12rpx flex items-baseline">
  428. <text class="text-28rpx">
  429. {{ $t('productDetail.price') }}
  430. </text>
  431. <view class="ml-8rpx rounded-t-18rpx rounded-br-18rpx bg-#202221 px-12rpx text-24rpx">
  432. {{ detail.people || 0 }}GB
  433. </view>
  434. </view>
  435. <view>
  436. <text class="text-48rpx">
  437. <text class="text-28rpx">
  438. </text>{{ formatNumber(detail.price) }}
  439. </text>
  440. <text class="ml-22rpx text-28rpx line-through">
  441. ৳{{ formatNumber(detail.otPrice) }}
  442. </text>
  443. </view>
  444. </view>
  445. <text class="text-28rpx">
  446. {{ t('productDetail.sold', [detail.ficti]) }}
  447. </text>
  448. </view>
  449. <view class="bg-white px-24rpx pb-24rpx pt-20rpx text-32rpx">
  450. <view class="line-clamp-2font-bold mb-16rpx">
  451. {{ detail.storeName }}
  452. </view>
  453. <view class="flex items-center justify-between" @click="openSku('open')">
  454. <view>
  455. <text class="text-28rpx text-#757575">
  456. {{ selectedSpecsText }}
  457. </text>
  458. </view>
  459. <wd-icon name="arrow-right" color="#7D7D7D" size="36rpx" />
  460. </view>
  461. </view>
  462. </view>
  463. <view class="mb-20rpx bg-white p-24rpx">
  464. <view class="mb-20rpx flex items-center justify-between">
  465. <view
  466. class="flex items-center before:h-45rpx before:w-8rpx before:rounded-4rpx before:bg-#FF3778 before:content-empty"
  467. >
  468. <text class="ml-10rpx text-32rpx">
  469. {{ $t('productDetail.groupRules') }}
  470. </text>
  471. </view>
  472. <view class="flex items-center" @click="toPage({ url: '/pages/webLink/webLink', params: { title: $t('productDetail.viewRules'), link: 'http://' } })">
  473. <text class="mr-8rpx text-24rpx text-#3A444C">
  474. {{ $t('productDetail.viewRules') }}
  475. </text>
  476. <wd-icon name="arrow-right" color="#7D7D7D" size="24rpx" />
  477. </view>
  478. </view>
  479. <image src="/static/images/buy-flow.png" class="w-full" mode="widthFix" />
  480. </view>
  481. <view v-if="pinkInfo && pinkInfo.length" class="mb-20rpx bg-white px-24rpx pt-24rpx">
  482. <view
  483. class="mb-20rpx flex items-center before:h-45rpx before:w-8rpx before:rounded-4rpx before:bg-#FF3778 before:content-empty"
  484. >
  485. <text class="ml-10rpx text-32rpx">
  486. {{ $t('productDetail.ongoingGroup') }}
  487. </text>
  488. </view>
  489. <swiper
  490. autoplay
  491. vertical
  492. circular
  493. class="py-10rpx"
  494. :style="{ height: pinkInfo[0].length <= 3 ? `${pinkInfo[0].length * 80}rpx` : '240rpx' }"
  495. >
  496. <swiper-item v-for="(list, y) in pinkInfo" :key="y">
  497. <view class="flex flex-col gap-24rpx">
  498. <view v-for="(item, index) in list" :key="index" class="flex items-center justify-between">
  499. <view class="flex items-center">
  500. <view>
  501. <!-- 头像组 最多五个 -->
  502. <view class="mr-16rpx min-w-220rpx flex items-center">
  503. <view
  504. v-for="(e, i) in item.successAvatar.slice(0, 5)"
  505. :key="i"
  506. :style="{ marginLeft: i !== 0 ? '-20rpx' : '0', zIndex: 10 - i }"
  507. class="h-56rpx w-56rpx overflow-hidden border-2rpx border-white rounded-full border-solid"
  508. >
  509. <image :src="e ? e : '/static/images/default-avatar.png'" class="h-full w-full" mode="aspectFill" />
  510. </view>
  511. </view>
  512. </view>
  513. <view>
  514. <view class="text-28rpx">
  515. {{ $t('productDetail.need') }}
  516. <text class="text-[var(--wot-color-theme)]">
  517. {{ item.totalNum - item.remainNum }}
  518. </text>
  519. {{ $t('productDetail.more') }}
  520. </view>
  521. </view>
  522. </view>
  523. <wd-button size="small" @click="openSku('join', item.id, item.orderId)">
  524. {{ $t('productDetail.joinGroup') }}
  525. </wd-button>
  526. </view>
  527. </view>
  528. </swiper-item>
  529. </swiper>
  530. </view>
  531. <view class="bg-white p-24rpx">
  532. <view
  533. class="mb-20rpx flex items-center before:h-45rpx before:w-8rpx before:rounded-4rpx before:bg-#FF3778 before:content-empty"
  534. >
  535. <text class="ml-10rpx text-32rpx">
  536. {{ $t('productDetail.details') }}
  537. </text>
  538. </view>
  539. <view v-for="i in detail.flatPattern.split(',')" :key="i">
  540. <image
  541. :src="i"
  542. mode="widthFix"
  543. class="w-full"
  544. />
  545. </view>
  546. </view>
  547. </template>
  548. <!-- 底部按钮区域 -->
  549. <template #bottom>
  550. <view class="flex bg-white/60 px-28rpx py-30rpx backdrop-blur-20">
  551. <view class="mr-30rpx flex flex-1 items-center justify-around gap-20rpx">
  552. <view class="flex flex-col items-center justify-center">
  553. <image
  554. src="/static/icons/go-home.png"
  555. class="h-40rpx w-40rpx"
  556. @click="goHome"
  557. />
  558. <text class="text-18rpx text-#757575">
  559. {{ $t('productDetail.home') }}
  560. </text>
  561. </view>
  562. <view class="flex flex-col items-center justify-center" @click="toggleFavorite">
  563. <image
  564. v-if="detail.favoriteFlag"
  565. src="/static/icons/favorite-active.png"
  566. class="h-40rpx w-40rpx"
  567. />
  568. <image
  569. v-else
  570. src="/static/icons/favorite.png"
  571. class="h-40rpx w-40rpx"
  572. />
  573. <text class="text-18rpx text-#757575">
  574. {{ $t('productDetail.favorite') }}
  575. </text>
  576. </view>
  577. </view>
  578. <view class="flex items-center justify-end text-32rpx">
  579. <view class="relative">
  580. <view class="rounded-l-full bg-#2F2D31 px-34rpx py-18rpx text-white" @click="openSku('open')">
  581. {{ $t('productDetail.openGroup') }}
  582. </view>
  583. <CustomTooltip
  584. v-model:visible="showTip"
  585. />
  586. </view>
  587. <view class="rounded-r-full bg-[var(--wot-color-theme)] px-34rpx py-18rpx text-white" @click="openSku('join')">
  588. {{ $t('productDetail.joinGroup') }}
  589. </view>
  590. </view>
  591. </view>
  592. </template>
  593. </z-paging>
  594. <wd-action-sheet v-model="showSku" :z-index="9999">
  595. <view class="px-24rpx">
  596. <view class="mb-16rpx flex items-center gap-24rpx border-b-1 border-b-color-#e8e8e8 border-b-solid py-24rpx">
  597. <image
  598. :src="matchedAttrValue.image || detail?.image"
  599. class="h-160rpx w-160rpx shrink-0"
  600. mode="aspectFit"
  601. />
  602. <view class="flex-1">
  603. <view class="line-clamp-2 mb-32rpx text-28rpx">
  604. {{ detail.storeName }}
  605. </view>
  606. <view class="flex items-baseline">
  607. <view class="text-#FF0010">
  608. <text class="text-28rpx">
  609. </text>
  610. <text class="text-48rpx">
  611. {{ formatNumber(matchedAttrValue.price || 0) }}
  612. </text>
  613. </view>
  614. <view class="ml-20rpx text-28rpx text-#787878 line-through">
  615. ৳{{ formatNumber(matchedAttrValue.otPrice || 0) }}
  616. </view>
  617. </view>
  618. </view>
  619. </view>
  620. <view v-for="i in detail.attr" :key="i.id" class="mb-24rpx border-b-1 border-b-color-#e8e8e8 border-b-solid pb-40rpx">
  621. <view class="mb-12rpx text-32rpx">
  622. {{ i.attrName }}
  623. </view>
  624. <view class="grid grid-cols-4 gap-20rpx">
  625. <view v-for="(e, j) in i.attrImgValues" :key="j" class="flex flex-col justify-end">
  626. <view
  627. class="box-border flex flex-col border-1 border-transparent border-dashed bg-#F5F5F7 text-center"
  628. :style="{ borderColor: formData.selectedSpecs[i.attrName] === e.name ? 'var(--wot-color-theme)' : '' }"
  629. @click="selectSpec(i.attrName, e.name)"
  630. >
  631. <view>
  632. <view v-if="e.img" class="h-160rpx w-full">
  633. <image
  634. :src="e.img"
  635. class="h-full w-full"
  636. mode="aspectFit"
  637. />
  638. </view>
  639. <view class="py-12rpx text-22rpx text-#757575">
  640. {{ e.name }}
  641. </view>
  642. </view>
  643. </view>
  644. </view>
  645. </view>
  646. </view>
  647. <view class="mb-100rpx flex items-center justify-between text-32rpx">
  648. <view>{{ $t('productDetail.quantity') }}</view>
  649. <wd-input-number v-model="formData.productNum" :max="1" :min="1" />
  650. </view>
  651. <view class="py-24rpx">
  652. <wd-button block :loading="loading" :style="{ backgroundColor: groupType === 'open' ? '#2F2D31' : 'var(--wot-color-theme)' }" @click="preOrder">
  653. {{ groupType === 'open' ? $t('productDetail.openGroup') : $t('productDetail.joinGroup') }}
  654. </wd-button>
  655. </view>
  656. </view>
  657. </wd-action-sheet>
  658. </template>
  659. <style lang="scss" scoped>
  660. :deep() {
  661. .wd-navbar__title {
  662. margin: 0;
  663. max-width: 100%;
  664. }
  665. }
  666. </style>