productDetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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 CustomTooltip from './components/CustomTooltip.vue'
  15. import NotificationCarousel from './components/NotificationCarousel.vue'
  16. defineOptions({
  17. name: 'ProductDetail', // 商品详情
  18. })
  19. // 获取屏幕边界到安全区域距离
  20. const systemInfo = uni.getSystemInfoSync()
  21. const safeAreaInsets = systemInfo.safeAreaInsets
  22. // z-paging
  23. const paging = ref(null)
  24. // 类似mixins,如果是页面滚动务必要写这一行,并传入当前ref绑定的paging,注意此处是paging,而非paging.value
  25. useZPaging(paging)
  26. // 添加导航栏背景色变量
  27. const navBgColor = ref('transparent')
  28. const changeNavbarThreshold = 300 // 滚动到这个高度时改变导航栏颜色
  29. const showTip = ref(false)
  30. onPageScroll((e) => {
  31. // 根据滚动高度改变导航栏背景色
  32. if (e.scrollTop > changeNavbarThreshold) {
  33. navBgColor.value = '#ffffff'
  34. }
  35. else {
  36. navBgColor.value = 'transparent'
  37. }
  38. })
  39. // 添加通知轮播数据
  40. const notifications = ref([
  41. { id: 1, name: 'Aamir Khan', time: '10s' },
  42. { id: 2, name: 'John Smith', time: '30s' },
  43. { id: 3, name: 'Maria Garcia', time: '1m' },
  44. ])
  45. // 点击页面任意地方隐藏提示
  46. function handlePageClick() {
  47. if (showTip.value) {
  48. showTip.value = false
  49. }
  50. }
  51. // 生命周期钩子
  52. onMounted(() => {
  53. showTip.value = true // 显示提示
  54. })
  55. // 搜索结果
  56. // 轮播图
  57. const current = ref<number>(0)
  58. const swiperList = ref([
  59. '/static/images/avatar.jpg',
  60. '/static/images/vip-info-bg.png',
  61. '/static/images/vip-level1.png',
  62. ])
  63. function handleClick(e) {
  64. // console.log(e)
  65. }
  66. function onChange(e) {
  67. // console.log(e)
  68. }
  69. // 添加头像列表数据
  70. const avatarList = ref([
  71. '/static/images/avatar.jpg',
  72. '/static/images/avatar.jpg',
  73. '/static/images/avatar.jpg',
  74. '/static/images/avatar.jpg',
  75. '/static/images/avatar.jpg',
  76. '/static/images/avatar.jpg',
  77. '/static/images/avatar.jpg',
  78. ])
  79. // sku 逻辑
  80. const showSku = ref(false)
  81. const formData = ref({
  82. colorSelect: 1,
  83. num: 1,
  84. })
  85. const dataList = ref([])
  86. function queryList(pageNo, pageSize) {
  87. // 此处请求仅为演示,请替换为自己项目中的请求
  88. setTimeout(() => {
  89. dataList.value = [
  90. { title: '123' },
  91. { title: '123' },
  92. { title: '123' },
  93. { title: '12345' },
  94. ]
  95. paging.value.complete(dataList.value)
  96. }, 1000)
  97. }
  98. </script>
  99. <template>
  100. <z-paging ref="paging" refresher-only use-page-scroll @query="queryList" @click="handlePageClick">
  101. <wd-navbar :bordered="false" safe-area-inset-top fixed :left-arrow="false" :custom-style="`background: ${navBgColor}; transition: background 0.3s;`" custom-class="h-auto!">
  102. <template #title>
  103. <view class="box-border h-full flex items-center justify-between p-24rpx">
  104. <image :src="`/static/icons/left-icon${navBgColor === '#ffffff' ? '-tr' : ''}.png`" class="h-56rpx w-56rpx" />
  105. <image :src="`/static/icons/menu-icon${navBgColor === '#ffffff' ? '-tr' : ''}.png`" class="h-56rpx w-56rpx" />
  106. </view>
  107. </template>
  108. </wd-navbar>
  109. <view class="relative">
  110. <wd-swiper
  111. v-model:current="current" :list="swiperList" autoplay height="750rpx"
  112. custom-indicator-class="bottom-40rpx!" :indicator="{ type: 'fraction' }" indicator-position="bottom-right"
  113. image-mode="aspectFit" @click="handleClick" @change="onChange"
  114. />
  115. <NotificationCarousel
  116. :notifications="notifications"
  117. :top="`${safeAreaInsets?.top + 52}px`"
  118. />
  119. </view>
  120. <view class="relative -top-24rpx">
  121. <view
  122. 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"
  123. >
  124. <view>
  125. <view class="mb-12rpx flex items-baseline">
  126. <text class="text-28rpx">
  127. Price
  128. </text>
  129. <view class="ml-8rpx rounded-t-18rpx rounded-br-18rpx bg-#202221 px-12rpx text-24rpx">
  130. 20GB
  131. </view>
  132. </view>
  133. <view>
  134. <text class="text-48rpx">
  135. <text class="text-28rpx">
  136. </text>1000.00
  137. </text>
  138. <text class="ml-22rpx text-28rpx line-through">
  139. ৳1999.00
  140. </text>
  141. </view>
  142. </view>
  143. <text class="text-28rpx">
  144. 1.8k sold
  145. </text>
  146. </view>
  147. <view class="bg-white px-24rpx pb-24rpx pt-20rpx text-32rpx">
  148. <view class="line-clamp-2font-bold mb-16rpx">
  149. BOLON Classic Aviator Polarized Sunglasses, Exclusive Eyewear Brand
  150. </view>
  151. <view class="flex items-center justify-between">
  152. <view>
  153. <text class="mr-20rpx">
  154. Color
  155. </text>
  156. <text class="text-#757575">
  157. Black Grey
  158. </text>
  159. </view>
  160. <wd-icon name="arrow-right" color="#7D7D7D" size="36rpx" />
  161. </view>
  162. </view>
  163. </view>
  164. <view class="mb-20rpx bg-white p-24rpx">
  165. <view class="mb-20rpx flex items-center justify-between">
  166. <view
  167. class="flex items-center before:h-45rpx before:w-8rpx before:rounded-4rpx before:bg-#FF3778 before:content-empty"
  168. >
  169. <text class="ml-10rpx text-32rpx">
  170. Group Rules
  171. </text>
  172. </view>
  173. <view class="flex items-center">
  174. <text class="mr-8rpx text-24rpx text-#3A444C">
  175. View Rules
  176. </text>
  177. <wd-icon name="arrow-right" color="#7D7D7D" size="24rpx" />
  178. </view>
  179. </view>
  180. <image src="/static/images/buy-flow.png" class="w-full" mode="widthFix" />
  181. </view>
  182. <view class="bg-white p-24rpx">
  183. <view
  184. class="mb-20rpx flex items-center before:h-45rpx before:w-8rpx before:rounded-4rpx before:bg-#FF3778 before:content-empty"
  185. >
  186. <text class="ml-10rpx text-32rpx">
  187. Ongoing Group
  188. </text>
  189. </view>
  190. <view class="flex flex-col gap-24rpx">
  191. <view v-for="i in 3" :key="i" class="flex items-center justify-between">
  192. <view class="flex items-center">
  193. <view>
  194. <!-- 头像组 最多五个 -->
  195. <view class="mr-16rpx flex items-center">
  196. <view
  197. v-for="(avatar, index) in avatarList.slice(0, 5)"
  198. :key="index"
  199. :style="{ marginLeft: index !== 0 ? '-20rpx' : '0', zIndex: 10 - index }"
  200. class="h-56rpx w-56rpx overflow-hidden border-2rpx border-white rounded-full border-solid"
  201. >
  202. <image :src="avatar" class="h-full w-full" mode="aspectFill" />
  203. </view>
  204. </view>
  205. </view>
  206. <view>
  207. <view class="text-28rpx font-bold">
  208. Need <text class="text-[var(--wot-color-theme)]">
  209. 5
  210. </text> More
  211. </view>
  212. </view>
  213. </view>
  214. <wd-button size="small">
  215. Join Group
  216. </wd-button>
  217. </view>
  218. </view>
  219. <view class="bg-white p-24rpx">
  220. <view
  221. class="mb-20rpx flex items-center before:h-45rpx before:w-8rpx before:rounded-4rpx before:bg-#FF3778 before:content-empty"
  222. >
  223. <text class="ml-10rpx text-32rpx">
  224. Details
  225. </text>
  226. </view>
  227. <view v-for="i in 3" :key="i">
  228. <image
  229. src="/static/images/avatar.jpg"
  230. mode="widthFix"
  231. class="w-full"
  232. />
  233. </view>
  234. </view>
  235. </view>
  236. <template #bottom>
  237. <view class="h-100rpx flex gap-32rpx bg-white bg-opacity-60 px-28rpx backdrop-blur-20">
  238. <view class="flex items-center justify-between gap-20rpx">
  239. <view class="flex flex-col items-center justify-center">
  240. <wd-icon color="#BDBDBD" name="home" size="40rpx" />
  241. <text class="text-18rpx text-#757575">
  242. Home
  243. </text>
  244. </view>
  245. <view class="flex flex-col items-center justify-center">
  246. <wd-icon color="#BDBDBD" name="heart-filled" size="40rpx" />
  247. <text class="text-18rpx text-#757575">
  248. Favorite
  249. </text>
  250. </view>
  251. </view>
  252. <view class="flex flex-1 items-center justify-end text-32rpx">
  253. <view class="relative">
  254. <view class="rounded-l-full bg-#2F2D31 px-34rpx py-18rpx text-white" @click="showSku = true">
  255. Open Group
  256. </view>
  257. <CustomTooltip
  258. v-model:visible="showTip"
  259. highlight-text1="$99.99"
  260. highlight-text2="$1.8"
  261. />
  262. </view>
  263. <view class="rounded-r-full bg-[var(--wot-color-theme)] px-34rpx py-18rpx text-white">
  264. Join Group
  265. </view>
  266. </view>
  267. </view>
  268. </template>
  269. </z-paging>
  270. <wd-action-sheet v-model="showSku" :z-index="9999">
  271. <view class="px-24rpx">
  272. <view class="mb-16rpx flex items-center gap-24rpx border-b-1 border-b-color-#E1E1E1 border-b-solid py-24rpx">
  273. <image
  274. src="/static/images/avatar.jpg"
  275. class="h-160rpx w-160rpx shrink-0"
  276. />
  277. <view class="flex-1">
  278. <view class="line-clamp-2 mb-32rpx text-28rpx">
  279. SUCGLES for iPhone 14 Plus Case with MagSafe [Ultra Strong Magnetic]
  280. </view>
  281. <view class="flex items-baseline">
  282. <view class="text-#FF0010">
  283. <text class="text-28rpx">
  284. </text>
  285. <text class="text-48rpx">
  286. 1000
  287. </text>
  288. </view>
  289. <view class="ml-20rpx text-28rpx text-#787878 line-through">
  290. ৳1999
  291. </view>
  292. </view>
  293. </view>
  294. </view>
  295. <view class="mb-24rpx border-b-1 border-b-color-#E1E1E1 border-b-solid pb-40rpx">
  296. <view class="mb-12rpx text-32rpx">
  297. Color
  298. </view>
  299. <view class="grid grid-cols-4 gap-20rpx">
  300. <view v-for="i in 5" :key="i" class="box-border flex flex-col border-1 border-transparent border-dashed bg-#F5F5F7 text-center" :style="{ borderColor: formData.colorSelect === i ? 'var(--wot-color-theme)' : '' }">
  301. <view class="h-160rpx w-full">
  302. <image
  303. src="/static/images/avatar.jpg"
  304. class="h-full w-full"
  305. mode="aspectFit"
  306. />
  307. </view>
  308. <view class="text-22rpx text-#757575">
  309. Black
  310. </view>
  311. </view>
  312. </view>
  313. </view>
  314. <view class="mb-100rpx flex items-center justify-between text-32rpx">
  315. <view>Quantity</view>
  316. <wd-input-number v-model="formData.num" />
  317. </view>
  318. <view class="py-24rpx">
  319. <wd-button block>
  320. Join Group
  321. </wd-button>
  322. </view>
  323. </view>
  324. </wd-action-sheet>
  325. </template>
  326. <style lang="scss" scoped>
  327. :deep() {
  328. .wd-navbar__title {
  329. margin: 0;
  330. max-width: 100%;
  331. }
  332. }
  333. </style>