index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 { deleteProductItemBuy, getProductItemBuy } from '../../../../core/libs/requests'
  16. import PageHelper from '@/components/page-helper.vue'
  17. import BottomAppBar from '@/components/bottom-app-bar.vue'
  18. import { useUserStore } from '../../../../store'
  19. import { storeToRefs } from 'pinia'
  20. import { requestToast } from '../../../../core/utils/common'
  21. import type { ComponentExposed } from 'vue-component-type-helpers'
  22. const pageHelperRef = ref<ComponentExposed<typeof PageHelper>>()
  23. const userStore = useUserStore()
  24. const { userInfo } = storeToRefs(userStore)
  25. const a = ref(1)
  26. const handleDelete = async (product: any) => {
  27. await requestToast(
  28. () =>
  29. deleteProductItemBuy({
  30. doList: [
  31. {
  32. productId: product.productId,
  33. userId: userInfo.value.userId,
  34. id: product.id,
  35. deleted: true,
  36. },
  37. ],
  38. }),
  39. {
  40. successTitle: '删除成功',
  41. success: true,
  42. },
  43. )
  44. await pageHelperRef.value?.refresh()
  45. }
  46. </script>
  47. <template>
  48. <view class="flex-grow flex flex-col gap-14 bg-white px-3.5 py-6">
  49. <PageHelper
  50. ref="pageHelperRef"
  51. :request="getProductItemBuy"
  52. :query="{ userId: userInfo.userId }"
  53. class="flex-grow flex flex-col"
  54. >
  55. <template #default="{ source }">
  56. <div class="flex-grow flex flex-col gap-8">
  57. <template v-for="(it, i) in source.list" :key="i">
  58. <wd-swipe-action>
  59. <div class="flex gap-3">
  60. <div class="flex items-center">
  61. <div class="w-4 h-4 rounded-full border border-black/60 border-solid"></div>
  62. </div>
  63. <div class="w-[110px] h-[110px] bg-[#f6f6f6] rounded-2xl">
  64. <wd-img width="100%" height="100%" :src="it.productCoverImgUrl"></wd-img>
  65. </div>
  66. <div class="flex flex-col justify-between flex-1">
  67. <div
  68. class="text-black/40 text-base font-normal font-['PingFang_SC'] leading-normal"
  69. >
  70. {{ it.prodcutName }}
  71. </div>
  72. <div class="flex items-center">
  73. <div
  74. class="text-[#ef4343] text-[22px] font-normal font-['D-DIN Exp'] leading-normal"
  75. >
  76. {{ it.points }}
  77. </div>
  78. <div
  79. class="text-black/40 text-sm font-normal font-['PingFang_SC'] leading-[34px]"
  80. >
  81. 积分
  82. </div>
  83. <div class="flex-1"></div>
  84. <wd-input-number v-model="it.nums" />
  85. </div>
  86. </div>
  87. </div>
  88. <template #right>
  89. <view class="h-full">
  90. <view
  91. class="inline-block h-full bg-[#ef4343] text-white flex items-center px-5"
  92. @click="handleDelete(it)"
  93. >
  94. 删除
  95. </view>
  96. </view>
  97. </template>
  98. </wd-swipe-action>
  99. </template>
  100. </div>
  101. </template>
  102. </PageHelper>
  103. <BottomAppBar fixed border>
  104. <div class="h-[63px] bg-white backdrop-blur-[20px] flex px-3.5 items-center justify-between">
  105. <div class="flex items-end gap-1.25">
  106. <div class="text-[#ef4343] text-2xl font-normal font-['D-DIN_Exp'] leading-6">0</div>
  107. <div class="text-black text-base font-normal font-['PingFang_SC'] leading-5">积分</div>
  108. </div>
  109. <div class="">
  110. <TiltedButton size="large">
  111. <div
  112. class="w-[49px] h-[22px] text-white text-base font-normal font-['PingFang_SC'] leading-tight"
  113. >
  114. <div
  115. class="w-[65px] h-[22px] text-white text-base font-normal font-['PingFang_SC'] leading-tight"
  116. >
  117. 去结算
  118. </div>
  119. </div>
  120. </TiltedButton>
  121. </div>
  122. </div>
  123. </BottomAppBar>
  124. </view>
  125. </template>
  126. <style scoped lang="scss"></style>