index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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 { createProductItemBuy, 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. import ButtonEvo from '@/components/button-evo.vue'
  22. const userStore = useUserStore()
  23. const router = useRouter()
  24. const { userInfo } = storeToRefs(userStore)
  25. const id = ref()
  26. const show = ref(false)
  27. const nums = ref(1)
  28. const type = ref<'add2Cart' | 'orderNow'>()
  29. const { data, run: setData } = useRequest(() => getProduct(id.value))
  30. const handleConfirm = async () => {
  31. if (type.value === 'orderNow') {
  32. const { data: res, code } = await requestToast(() =>
  33. productPlacing({
  34. isShoppingCart: 0,
  35. userId: userInfo.value.userId,
  36. list: [
  37. {
  38. productId: id.value,
  39. points: data.value.points,
  40. nums: nums.value,
  41. productName: data.value.prodcutName,
  42. orderImgUrl: data.value.productCoverImgUrl,
  43. vendorId: data.value.vendorId,
  44. },
  45. ],
  46. couponList: [],
  47. }),
  48. )
  49. if (code !== 0) return
  50. router.push(`/pages/home/mall/confirm-order/index?data=${JSON.stringify(res)}`)
  51. }
  52. if (type.value === 'add2Cart') {
  53. await requestToast(
  54. () =>
  55. createProductItemBuy({
  56. doList: [
  57. {
  58. userId: userInfo.value.userId,
  59. productId: data.value?.productId || '',
  60. points: data.value?.points,
  61. nums: nums.value,
  62. },
  63. ],
  64. }),
  65. { success: true, successTitle: '加入购物车成功' },
  66. )
  67. show.value = false
  68. }
  69. }
  70. onLoad(async (query: { id: string }) => {
  71. id.value = query.id
  72. await setData()
  73. })
  74. </script>
  75. <template>
  76. <view class="flex-grow flex flex-col">
  77. <div class="aspect-[1.34/1] relative">
  78. <div class="absolute aspect-[1.26/1] top-0 w-full">
  79. <wd-img width="100%" height="100%" :src="data?.productCoverImgUrl" />
  80. </div>
  81. </div>
  82. <div class="relative flex-1 bg-white p-4 flex flex-col gap-4 rounded-tl-2xl rounded-tr-2xl">
  83. <div class="flex items-center gap-1">
  84. <div class="text-[#ef4343] text-[26px] font-normal font-['D-DIN Exp'] leading-normal">
  85. <!-- 1000 -->
  86. {{ data?.points }}
  87. </div>
  88. <div class="text-black/60 text-base font-normal font-['PingFang_SC'] leading-[34px]">
  89. 积分
  90. </div>
  91. <div
  92. class="w-[66px] text-black/30 text-xs font-normal font-['PingFang_SC'] line-through leading-normal"
  93. >
  94. <!-- ¥60 -->
  95. ¥{{ data?.productPrice }}
  96. </div>
  97. <div class="flex-1"></div>
  98. <div class="text-[#999999] text-xs font-normal font-['PingFang_SC'] leading-[10.18px]">
  99. <!-- 已售5件 -->
  100. 已售{{ data?.exchangeCount || 0 }}件
  101. </div>
  102. </div>
  103. <div class="h-4 text-black text-xl font-normal font-['PingFang_SC'] leading-[10.18px]">
  104. <!-- 阿芙佳朵 -->
  105. {{ data?.prodcutName }}
  106. </div>
  107. <div class="h-0.25 bg-[#f6f6f6]"></div>
  108. <div class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-normal">
  109. 积分兑换说明:
  110. </div>
  111. <div
  112. class="w-[346px] h-[95px] text-black/40 text-xs font-normal font-['PingFang_SC'] leading-[23px]"
  113. >
  114. · 不限制兑换个数
  115. <br />
  116. · 兑换后不支持退换货,如有问题可联系官方客户
  117. <br />
  118. · 规格:件
  119. <br />
  120. · 配送方式:到店自取
  121. </div>
  122. <div class="mx--4 h-2.5 bg-neutral-100"></div>
  123. <wd-divider>
  124. <div
  125. class="text-center text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal"
  126. >
  127. 商品详情
  128. </div>
  129. </wd-divider>
  130. <wd-img width="100%" mode="widthFix" :src="data?.productDetailsImgUrl"></wd-img>
  131. </div>
  132. <BottomAppBar fixed placeholder>
  133. <div class="h-[63px] bg-white backdrop-blur-[20px] flex items-center justify-between gap-2">
  134. <div class="flex-1">
  135. <ButtonEvo
  136. block
  137. color="white"
  138. location="right"
  139. @click="(show = true), (type = 'add2Cart')"
  140. >
  141. <span class="text-black/80">加入购物车</span>
  142. </ButtonEvo>
  143. </div>
  144. <!-- <div @click="(show = true), (type = 'add2Cart')">
  145. <InvertedTrapezoidButton>
  146. <div
  147. class="w-20 h-[22px] text-black text-base font-normal font-['PingFang_SC'] leading-tight"
  148. >
  149. 加入购物车
  150. </div>
  151. </InvertedTrapezoidButton>
  152. </div> -->
  153. <div class="flex-1">
  154. <!-- <TrapeziumButton size="large">
  155. <div class="text-white text-base font-normal font-['PingFang_SC'] leading-tight">
  156. <div class="text-white text-base font-normal font-['PingFang_SC'] leading-tight">
  157. 立即兑换
  158. </div>
  159. </div>
  160. </TrapeziumButton> -->
  161. <ButtonEvo block size="lg" @click="(show = true), (type = 'orderNow')">
  162. 立即兑换
  163. </ButtonEvo>
  164. </div>
  165. </div>
  166. </BottomAppBar>
  167. <wd-action-sheet v-model="show">
  168. <view class="px-7 py-11">
  169. <div class="flex gap-3 mb-13.5">
  170. <div class="w-[110px] h-[110px] bg-[#f6f6f6] rounded-2xl">
  171. <wd-img width="100%" height="100%" :src="data?.productCoverImgUrl"></wd-img>
  172. </div>
  173. <div class="flex flex-col justify-between flex-1">
  174. <div class="text-black/40 text-base font-normal font-['PingFang_SC'] leading-normal">
  175. {{ data?.prodcutName }}
  176. </div>
  177. <div class="flex items-center">
  178. <div class="text-[#ef4343] text-[22px] font-normal font-['D-DIN Exp'] leading-normal">
  179. {{ data?.points }}
  180. </div>
  181. <div class="text-black/40 text-sm font-normal font-['PingFang_SC'] leading-[34px]">
  182. 积分
  183. </div>
  184. <div class="flex-1"></div>
  185. <!-- <wd-input-number v-model="a" /> -->
  186. <wd-input-number v-model="nums" />
  187. </div>
  188. </div>
  189. </div>
  190. <wd-button block :round="false" @click="handleConfirm">确认</wd-button>
  191. </view>
  192. </wd-action-sheet>
  193. </view>
  194. </template>
  195. <style scoped lang="scss"></style>