productDetail.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857
  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]
  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. const socialPlatforms = ref([
  306. {
  307. name: 'copyLink',
  308. label: 'Copy Link',
  309. icon: '/static/icons/copy-link.png', // 占位图片路径
  310. },
  311. {
  312. name: 'facebook',
  313. label: 'Facebook',
  314. icon: '/static/icons/facebook.png', // 占位图片路径
  315. },
  316. {
  317. name: 'whatsapp',
  318. label: 'Whatsapp',
  319. icon: '/static/icons/whatsapp.png', // 占位图片路径
  320. },
  321. {
  322. name: 'instagram',
  323. label: 'Instagram',
  324. icon: '/static/icons/instagram.png', // 占位图片路径
  325. },
  326. {
  327. name: 'twitter',
  328. label: 'Twitter',
  329. icon: '/static/icons/twitter.png', // 占位图片路径
  330. },
  331. ])
  332. const showShare = ref<boolean>(false)
  333. const baseUrl = import.meta.env.VITE_H5_BASE_URL
  334. // 生成商品分享链接
  335. function generateShareLink() {
  336. // 基础域名 - 根据需求使用bandhubuy.shop.com
  337. const productUrl = `${baseUrl}/pages/productDetail/productDetail?productId=${productId.value}`
  338. // 分享文案格式:[BandhuBuy] + 商品链接 + 商品名称 + 邀请文案
  339. const productName = detail.value.storeName
  340. const shareText = `[BandhuBuy] ${productUrl} ${productName}\nGet it on BandhuBuy now!`
  341. return {
  342. url: productUrl,
  343. text: shareText,
  344. }
  345. }
  346. // 复制链接到剪贴板
  347. function copyToClipboard() {
  348. const { text } = generateShareLink()
  349. uni.setClipboardData({
  350. data: text,
  351. success: () => {},
  352. })
  353. }
  354. // 检查APP是否安装
  355. function checkAppInstalled(platform: string): boolean {
  356. const appSchemes = {
  357. facebook: { pname: 'com.facebook.katana', scheme: 'fb://' },
  358. whatsapp: { pname: 'com.whatsapp', scheme: 'whatsapp://' },
  359. instagram: { pname: 'com.instagram.android', scheme: 'instagram://' },
  360. twitter: { pname: 'com.twitter.android', scheme: 'twitter://' },
  361. }
  362. const appInfo = appSchemes[platform]
  363. if (!appInfo)
  364. return false
  365. return plus.runtime.isApplicationExist({
  366. pname: appInfo.pname,
  367. action: appInfo.scheme,
  368. })
  369. }
  370. // 打开社交媒体APP分享
  371. function openSocialApp(platform: string) {
  372. const { url, text } = generateShareLink()
  373. // 先复制分享内容到剪贴板
  374. uni.setClipboardData({
  375. data: text,
  376. success: () => {
  377. console.log('分享内容已复制到剪贴板')
  378. },
  379. })
  380. const shareUrls = {
  381. facebook: `fb://facewebmodal/f?href=${encodeURIComponent(url)}`,
  382. whatsapp: `whatsapp://send?text=${encodeURIComponent(text)}`,
  383. instagram: 'instagram://camera', // Instagram不支持直接分享链接,打开相机
  384. twitter: `twitter://post?message=${encodeURIComponent(text)}`,
  385. }
  386. const shareUrl = shareUrls[platform]
  387. if (shareUrl) {
  388. plus.runtime.openURL(shareUrl, (error) => {
  389. console.error('打开APP失败:', error)
  390. toast.info(t('share.appNotInstalled'))
  391. })
  392. }
  393. }
  394. // 统一分享处理方法
  395. function handleShare(platform: string) {
  396. if (platform === 'copyLink') {
  397. copyToClipboard()
  398. return
  399. }
  400. // 检查APP是否安装
  401. if (!checkAppInstalled(platform)) {
  402. toast.info(t('share.appNotInstalled'))
  403. return
  404. }
  405. // 打开对应的社交媒体APP
  406. openSocialApp(platform)
  407. // 关闭分享弹窗
  408. showShare.value = false
  409. }
  410. // 商品详情初始化
  411. onLoad((options) => {
  412. productId.value = options.productId || ''
  413. })
  414. onShow(async () => {
  415. try {
  416. isPageLoading.value = true
  417. getCarousel()
  418. await queryDetail()
  419. await queryPinkInfo()
  420. }
  421. finally {
  422. isPageLoading.value = false
  423. }
  424. })
  425. </script>
  426. <template>
  427. <z-paging ref="paging" :use-page-scroll="!showSku && !showShare" refresher-only @on-refresh="queryDetail" @click="handlePageClick">
  428. <wd-navbar :bordered="false" safe-area-inset-top fixed :left-arrow="false" :custom-style="`background: ${navBgColor}; transition: background 0.3s;`" custom-class="h-auto!">
  429. <template #title>
  430. <view class="box-border h-full flex items-center justify-between p-24rpx">
  431. <image :src="`/static/icons/left-icon${navBgColor === '#ffffff' ? '-tr' : ''}.png`" class="h-56rpx w-56rpx" @click="() => goBack()" />
  432. <image :src="`/static/icons/share-icon${navBgColor === '#ffffff' ? '-tr' : ''}.png`" class="h-56rpx w-56rpx" @click="showShare = true" />
  433. </view>
  434. </template>
  435. </wd-navbar>
  436. <!-- 页面加载时显示骨架屏 -->
  437. <template v-if="isPageLoading">
  438. <!-- 轮播图骨架屏 -->
  439. <wd-skeleton
  440. :row-col="[{ height: '750rpx' }]"
  441. animation="gradient"
  442. />
  443. <!-- 价格区域骨架屏 -->
  444. <view class="relative -top-24rpx">
  445. <view class="rounded-t-24rpx bg-white px-24rpx pb-24rpx pt-18rpx">
  446. <wd-skeleton
  447. :row-col="[
  448. { width: '200rpx', height: '40rpx' }, // 价格标签
  449. { width: '300rpx', height: '60rpx', marginTop: '12rpx' }, // 价格数值
  450. { width: '150rpx', height: '32rpx', marginTop: '16rpx' }, // 销量
  451. ]"
  452. animation="gradient"
  453. />
  454. </view>
  455. <view class="bg-white px-24rpx pb-24rpx pt-20rpx">
  456. <wd-skeleton
  457. :row-col="[
  458. { width: '100%', height: '60rpx' }, // 商品标题
  459. { width: '200rpx', height: '40rpx', marginTop: '16rpx' }, // 规格选择
  460. ]"
  461. animation="gradient"
  462. />
  463. </view>
  464. </view>
  465. <!-- 拼团规则骨架屏 -->
  466. <view class="mb-20rpx bg-white p-24rpx">
  467. <wd-skeleton
  468. :row-col="[
  469. { width: '200rpx', height: '40rpx' }, // 标题
  470. { width: '100%', height: '200rpx', marginTop: '20rpx' }, // 图片
  471. ]"
  472. animation="gradient"
  473. />
  474. </view>
  475. <!-- 拼团信息骨架屏 -->
  476. <view class="mb-20rpx bg-white px-24rpx pt-24rpx">
  477. <wd-skeleton
  478. :row-col="[
  479. { width: '200rpx', height: '40rpx' }, // 标题
  480. // 拼团列表项
  481. [
  482. [
  483. { width: '56rpx', height: '56rpx', type: 'circle' },
  484. { width: '56rpx', height: '56rpx', type: 'circle', marginLeft: '8rpx' },
  485. { width: '56rpx', height: '56rpx', type: 'circle', marginLeft: '8rpx' },
  486. ],
  487. { width: '200rpx', height: '28rpx', marginLeft: '16rpx' },
  488. { width: '120rpx', height: '60rpx', marginLeft: 'auto' },
  489. ],
  490. [
  491. [
  492. { width: '56rpx', height: '56rpx', type: 'circle' },
  493. { width: '56rpx', height: '56rpx', type: 'circle', marginLeft: '8rpx' },
  494. ],
  495. { width: '200rpx', height: '28rpx', marginLeft: '16rpx' },
  496. { width: '120rpx', height: '60rpx', marginLeft: 'auto' },
  497. ],
  498. ]"
  499. animation="gradient"
  500. />
  501. </view>
  502. <!-- 商品详情骨架屏 -->
  503. <view class="bg-white p-24rpx">
  504. <wd-skeleton
  505. :row-col="[
  506. { width: '200rpx', height: '40rpx' }, // 标题
  507. { width: '100%', height: '400rpx', marginTop: '20rpx' }, // 详情图1
  508. { width: '100%', height: '400rpx', marginTop: '20rpx' }, // 详情图2
  509. { width: '100%', height: '400rpx', marginTop: '20rpx' }, // 详情图3
  510. ]"
  511. animation="gradient"
  512. />
  513. </view>
  514. </template>
  515. <!-- 实际内容 -->
  516. <template v-else>
  517. <view class="relative">
  518. <wd-swiper
  519. v-model:current="current" :list="detail.sliderImage.split(',')" autoplay height="750rpx"
  520. custom-indicator-class="bottom-40rpx!" :indicator="{ type: 'fraction' }" indicator-position="bottom-right"
  521. image-mode="aspectFit"
  522. />
  523. <NotificationCarousel
  524. :notifications="notifications"
  525. :top="`${safeAreaInsets?.top + 52}px`"
  526. />
  527. </view>
  528. <view class="relative -top-24rpx">
  529. <view
  530. 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"
  531. >
  532. <view>
  533. <view class="mb-12rpx flex items-baseline">
  534. <text class="text-28rpx">
  535. {{ $t('productDetail.price') }}
  536. </text>
  537. <view class="ml-8rpx rounded-t-18rpx rounded-br-18rpx bg-#202221 px-12rpx text-24rpx">
  538. {{ detail.people || 0 }}GB
  539. </view>
  540. </view>
  541. <view>
  542. <text class="text-48rpx">
  543. <text class="text-28rpx">
  544. </text>{{ formatNumber(detail.price) }}
  545. </text>
  546. <text class="ml-22rpx text-28rpx line-through">
  547. ৳{{ formatNumber(detail.otPrice) }}
  548. </text>
  549. </view>
  550. </view>
  551. <text class="text-28rpx">
  552. {{ t('productDetail.sold', [detail.ficti]) }}
  553. </text>
  554. </view>
  555. <view class="bg-white px-24rpx pb-24rpx pt-20rpx text-32rpx">
  556. <view class="line-clamp-2font-bold mb-16rpx">
  557. {{ detail.storeName }}
  558. </view>
  559. <view class="flex items-center justify-between" @click="openSku('open')">
  560. <view>
  561. <text class="text-28rpx text-#757575">
  562. {{ selectedSpecsText }}
  563. </text>
  564. </view>
  565. <wd-icon name="arrow-right" color="#7D7D7D" size="36rpx" />
  566. </view>
  567. </view>
  568. </view>
  569. <view class="mb-20rpx bg-white p-24rpx">
  570. <view class="mb-20rpx flex items-center justify-between">
  571. <view
  572. class="flex items-center before:h-45rpx before:w-8rpx before:rounded-4rpx before:bg-#FF3778 before:content-empty"
  573. >
  574. <text class="ml-10rpx text-32rpx">
  575. {{ $t('productDetail.groupRules') }}
  576. </text>
  577. </view>
  578. <view class="flex items-center" @click="toPage({ url: '/pages/webLink/webLink', params: { title: t('productDetail.viewRulesLinkTitle'), link: 'https://www.aisoco.net/groupRules.html' } })">
  579. <text class="mr-8rpx text-24rpx text-#3A444C">
  580. {{ $t('productDetail.viewRules') }}
  581. </text>
  582. <wd-icon name="arrow-right" color="#7D7D7D" size="24rpx" />
  583. </view>
  584. </view>
  585. <image src="/static/images/buy-flow.png" class="w-full" mode="widthFix" />
  586. </view>
  587. <view v-if="pinkInfo && pinkInfo.length" class="mb-20rpx bg-white px-24rpx pt-24rpx">
  588. <view
  589. class="mb-20rpx flex items-center before:h-45rpx before:w-8rpx before:rounded-4rpx before:bg-#FF3778 before:content-empty"
  590. >
  591. <text class="ml-10rpx text-32rpx">
  592. {{ $t('productDetail.ongoingGroup') }}
  593. </text>
  594. </view>
  595. <swiper
  596. autoplay
  597. vertical
  598. circular
  599. class="py-10rpx"
  600. :style="{ height: pinkInfo[0].length <= 3 ? `${pinkInfo[0].length * 80}rpx` : '240rpx' }"
  601. >
  602. <swiper-item v-for="(list, y) in pinkInfo" :key="y">
  603. <view class="flex flex-col gap-24rpx">
  604. <view v-for="(item, index) in list" :key="index" class="flex items-center justify-between">
  605. <view class="flex items-center">
  606. <view>
  607. <!-- 头像组 最多五个 -->
  608. <view class="mr-16rpx min-w-220rpx flex items-center">
  609. <view
  610. v-for="(e, i) in item.successAvatar.slice(0, 5)"
  611. :key="i"
  612. :style="{ marginLeft: i !== 0 ? '-20rpx' : '0', zIndex: 10 - i }"
  613. class="h-56rpx w-56rpx overflow-hidden border-2rpx border-white rounded-full border-solid"
  614. >
  615. <image :src="e ? e : '/static/images/default-avatar.png'" class="h-full w-full" mode="aspectFill" />
  616. </view>
  617. </view>
  618. </view>
  619. <view>
  620. <view class="text-28rpx">
  621. {{ $t('productDetail.need') }}
  622. <text class="text-[var(--wot-color-theme)]">
  623. {{ item.totalNum - item.remainNum }}
  624. </text>
  625. {{ $t('productDetail.more') }}
  626. </view>
  627. </view>
  628. </view>
  629. <wd-button size="small" @click="openSku('join', item.id, item.orderId)">
  630. {{ $t('productDetail.joinGroup') }}
  631. </wd-button>
  632. </view>
  633. </view>
  634. </swiper-item>
  635. </swiper>
  636. </view>
  637. <view class="bg-white p-24rpx">
  638. <view
  639. class="mb-20rpx flex items-center before:h-45rpx before:w-8rpx before:rounded-4rpx before:bg-#FF3778 before:content-empty"
  640. >
  641. <text class="ml-10rpx text-32rpx">
  642. {{ $t('productDetail.details') }}
  643. </text>
  644. </view>
  645. <view v-for="i in detail.flatPattern.split(',')" :key="i">
  646. <image
  647. :src="i"
  648. mode="widthFix"
  649. class="w-full"
  650. />
  651. </view>
  652. </view>
  653. </template>
  654. <!-- 底部按钮区域 -->
  655. <template #bottom>
  656. <view class="flex bg-white/60 px-28rpx py-30rpx backdrop-blur-20">
  657. <view class="mr-30rpx flex flex-1 items-center justify-around gap-20rpx">
  658. <view class="flex flex-col items-center justify-center">
  659. <image
  660. src="/static/icons/go-home.png"
  661. class="h-40rpx w-40rpx"
  662. @click="goHome"
  663. />
  664. <text class="text-18rpx text-#757575">
  665. {{ $t('productDetail.home') }}
  666. </text>
  667. </view>
  668. <view class="flex flex-col items-center justify-center" @click="toggleFavorite">
  669. <image
  670. v-if="detail.favoriteFlag"
  671. src="/static/icons/favorite-active.png"
  672. class="h-40rpx w-40rpx"
  673. />
  674. <image
  675. v-else
  676. src="/static/icons/favorite.png"
  677. class="h-40rpx w-40rpx"
  678. />
  679. <text class="text-18rpx text-#757575">
  680. {{ $t('productDetail.favorite') }}
  681. </text>
  682. </view>
  683. </view>
  684. <view class="flex items-center justify-end text-32rpx">
  685. <view class="relative">
  686. <view class="rounded-l-full bg-#2F2D31 px-34rpx py-18rpx text-white" @click="openSku('open')">
  687. {{ $t('productDetail.openGroup') }}
  688. </view>
  689. <CustomTooltip
  690. v-model:visible="showTip"
  691. />
  692. </view>
  693. <view class="rounded-r-full bg-[var(--wot-color-theme)] px-34rpx py-18rpx text-white" @click="openSku('join')">
  694. {{ $t('productDetail.joinGroup') }}
  695. </view>
  696. </view>
  697. </view>
  698. </template>
  699. </z-paging>
  700. <wd-action-sheet v-model="showSku" :z-index="999">
  701. <view class="px-24rpx">
  702. <view class="mb-16rpx flex items-center gap-24rpx border-b-1 border-b-color-#e8e8e8 border-b-solid py-24rpx">
  703. <image
  704. :src="matchedAttrValue.image || detail?.image"
  705. class="h-160rpx w-160rpx shrink-0"
  706. mode="aspectFit"
  707. />
  708. <view class="flex-1">
  709. <view class="line-clamp-2 mb-32rpx text-28rpx">
  710. {{ detail.storeName }}
  711. </view>
  712. <view class="flex items-baseline">
  713. <view class="text-#FF0010">
  714. <text class="text-28rpx">
  715. </text>
  716. <text class="text-48rpx">
  717. {{ formatNumber(matchedAttrValue.price || 0) }}
  718. </text>
  719. </view>
  720. <view class="ml-20rpx text-28rpx text-#787878 line-through">
  721. ৳{{ formatNumber(matchedAttrValue.otPrice || 0) }}
  722. </view>
  723. </view>
  724. </view>
  725. </view>
  726. <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">
  727. <view class="mb-12rpx text-32rpx">
  728. {{ i.attrName }}
  729. </view>
  730. <view class="grid grid-cols-4 gap-20rpx">
  731. <view v-for="(e, j) in i.attrImgValues" :key="j" class="flex flex-col justify-end">
  732. <view
  733. class="box-border flex flex-col border-1 border-transparent border-dashed bg-#F5F5F7 text-center"
  734. :style="{ borderColor: formData.selectedSpecs[i.attrName] === e.name ? 'var(--wot-color-theme)' : '' }"
  735. @click="selectSpec(i.attrName, e.name)"
  736. >
  737. <view>
  738. <view v-if="e.img" class="h-160rpx w-full">
  739. <image
  740. :src="e.img"
  741. class="h-full w-full"
  742. mode="aspectFit"
  743. />
  744. </view>
  745. <view class="py-12rpx text-22rpx text-#757575">
  746. {{ e.name }}
  747. </view>
  748. </view>
  749. </view>
  750. </view>
  751. </view>
  752. </view>
  753. <view class="mb-100rpx flex items-center justify-between text-32rpx">
  754. <view>{{ $t('productDetail.quantity') }}</view>
  755. <wd-input-number v-model="formData.productNum" :max="1" :min="1" />
  756. </view>
  757. <view class="py-24rpx">
  758. <wd-button block :loading="loading" :style="{ backgroundColor: groupType === 'open' ? '#2F2D31' : 'var(--wot-color-theme)' }" @click="preOrder">
  759. {{ groupType === 'open' ? $t('productDetail.openGroup') : $t('productDetail.joinGroup') }}
  760. </wd-button>
  761. </view>
  762. </view>
  763. </wd-action-sheet>
  764. <wd-action-sheet v-model="showShare" title="Share with Friends and Family" :z-index="999" @close="showShare = false">
  765. <view class="flex justify-between gap-24rpx px-24rpx py-32rpx">
  766. <view
  767. v-for="item in socialPlatforms"
  768. :key="item.name"
  769. class="flex flex-col items-center"
  770. @click="handleShare(item.name)"
  771. >
  772. <view class="mb-20rpx">
  773. <image
  774. :src="item.icon"
  775. class="h-80rpx w-80rpx"
  776. mode="aspectFit"
  777. />
  778. </view>
  779. <text class="text-24rpx text-#666 font-medium">
  780. {{ item.label }}
  781. </text>
  782. </view>
  783. </view>
  784. </wd-action-sheet>
  785. </template>
  786. <style lang="scss" scoped>
  787. :deep() {
  788. .wd-navbar__title {
  789. margin: 0;
  790. max-width: 100%;
  791. }
  792. }
  793. </style>