index.vue 7.2 KB

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