index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <route lang="json5">
  2. {
  3. style: {
  4. navigationBarTitleText: '品质商城',
  5. navigationBarBackgroundColor: '#fff',
  6. },
  7. }
  8. </route>
  9. <script setup lang="ts">
  10. import TiltedButton from '@/components/tilted-button.vue'
  11. import Product from '../components/product.vue'
  12. import { shoppingBag } from '@designer-hub/assets/src/assets/svgs/index'
  13. import InvertedTrapezoidButton from '@/components/inverted-trapezoid-button.vue'
  14. import TrapeziumButton from '@/components/trapezium-button.vue'
  15. import { useRouter } from '../../../../core/utils/router'
  16. import { getProduct, productPlacing } from '../../../../core/libs/requests'
  17. import { requestToast } from '../../../../core/utils/common'
  18. import { useUserStore } from '../../../../store'
  19. import { storeToRefs } from 'pinia'
  20. import BottomAppBar from '@/components/bottom-app-bar.vue'
  21. const userStore = useUserStore()
  22. const router = useRouter()
  23. const { userInfo } = storeToRefs(userStore)
  24. const id = ref()
  25. const show = ref(false)
  26. const a = ref(1)
  27. const type = ref<'add2Cart' | 'orderNow'>()
  28. const { data, run: setData } = useRequest(() => getProduct(id.value))
  29. const handleConfirm = async () => {
  30. if (type.value === 'orderNow') {
  31. const { data: res } = await requestToast(() =>
  32. productPlacing({
  33. isShoppingCart: 0,
  34. userId: userInfo.value.userId,
  35. list: [{ productId: id.value, points: data.value.needPoints, nums: 1 }],
  36. couponList: [],
  37. }),
  38. )
  39. router.push(`/pages/home/mall/confirm-order/index?data=${JSON.stringify(res)}`)
  40. }
  41. }
  42. onLoad(async (query: { id: string }) => {
  43. id.value = query.id
  44. await setData()
  45. })
  46. </script>
  47. <template>
  48. <view class="flex-grow flex flex-col">
  49. <div class="aspect-[1.34/1] relative">
  50. <div class="absolute aspect-[1.26/1] top-0 w-full">
  51. <wd-img width="100%" height="100%" :src="data?.productCoverImgUrl" />
  52. </div>
  53. </div>
  54. <div class="relative flex-1 bg-white p-4 flex flex-col gap-4 rounded-tl-2xl rounded-tr-2xl">
  55. <div class="flex items-center gap-1">
  56. <div class="text-[#ef4343] text-[26px] font-normal font-['D-DIN Exp'] leading-normal">
  57. <!-- 1000 -->
  58. {{ data?.points }}
  59. </div>
  60. <div class="text-black/60 text-base font-normal font-['PingFang_SC'] leading-[34px]">
  61. 积分
  62. </div>
  63. <div
  64. class="w-[66px] text-black/30 text-xs font-normal font-['PingFang_SC'] line-through leading-normal"
  65. >
  66. <!-- ¥60 -->
  67. ¥{{ data?.productPrice }}
  68. </div>
  69. <div class="flex-1"></div>
  70. <div class="text-[#999999] text-xs font-normal font-['PingFang_SC'] leading-[10.18px]">
  71. <!-- 已售5件 -->
  72. 已售{{ data?.exchangeCount || 0 }}件
  73. </div>
  74. </div>
  75. <div
  76. class="w-[90px] h-4 text-black text-xl font-normal font-['PingFang_SC'] leading-[10.18px]"
  77. >
  78. <!-- 阿芙佳朵 -->
  79. {{ data?.prodcutName }}
  80. </div>
  81. <div class="h-0.25 bg-[#f6f6f6]"></div>
  82. <div class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-normal">
  83. 积分兑换说明:
  84. </div>
  85. <div
  86. class="w-[346px] h-[95px] text-black/40 text-xs font-normal font-['PingFang_SC'] leading-[23px]"
  87. >
  88. · 不限制兑换个数
  89. <br />
  90. · 兑换后不支持退换货,如有问题可联系官方客户
  91. <br />
  92. · 规格:件
  93. <br />
  94. · 配送方式:到店自取
  95. </div>
  96. <div class="mx--4 h-2.5 bg-neutral-100"></div>
  97. <wd-divider>
  98. <div
  99. class="text-center text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal"
  100. >
  101. 商品详情
  102. </div>
  103. </wd-divider>
  104. <wd-img width="100%" mode="widthFix" :src="data?.productDetailsImgUrl"></wd-img>
  105. </div>
  106. <BottomAppBar fixed placeholder>
  107. <div class="h-[63px] bg-white backdrop-blur-[20px] flex px-3.5 items-center justify-between">
  108. <div @click="(show = true), (type = 'add2Cart')">
  109. <InvertedTrapezoidButton>
  110. <div
  111. class="w-20 h-[22px] text-black text-base font-normal font-['PingFang_SC'] leading-tight"
  112. >
  113. 加入购物车
  114. </div>
  115. </InvertedTrapezoidButton>
  116. </div>
  117. <div class="" @click="(show = true), (type = 'orderNow')">
  118. <TrapeziumButton size="large">
  119. <div
  120. class="w-[49px] h-[22px] text-white text-base font-normal font-['PingFang_SC'] leading-tight"
  121. >
  122. <div
  123. class="w-[65px] h-[22px] text-white text-base font-normal font-['PingFang_SC'] leading-tight"
  124. >
  125. 立即兑换
  126. </div>
  127. </div>
  128. </TrapeziumButton>
  129. </div>
  130. </div>
  131. </BottomAppBar>
  132. <wd-action-sheet v-model="show">
  133. <view class="px-7 py-11">
  134. <div class="flex gap-3 mb-13.5">
  135. <div class="w-[110px] h-[110px] bg-[#f6f6f6] rounded-2xl">
  136. <wd-img width="100%" height="100%" :src="data?.productCoverImgUrl"></wd-img>
  137. </div>
  138. <div class="flex flex-col justify-between flex-1">
  139. <div class="text-black/40 text-base font-normal font-['PingFang_SC'] leading-normal">
  140. {{ data?.prodcutName }}
  141. </div>
  142. <div class="flex items-center">
  143. <div class="text-[#ef4343] text-[22px] font-normal font-['D-DIN Exp'] leading-normal">
  144. {{ data?.needPoints }}
  145. </div>
  146. <div class="text-black/40 text-sm font-normal font-['PingFang_SC'] leading-[34px]">
  147. 积分
  148. </div>
  149. <div class="flex-1"></div>
  150. <wd-input-number v-model="a" />
  151. </div>
  152. </div>
  153. </div>
  154. <wd-button block :round="false" @click="handleConfirm">确认</wd-button>
  155. </view>
  156. </wd-action-sheet>
  157. </view>
  158. </template>
  159. <style scoped lang="scss"></style>