index.vue 4.9 KB

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