index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <script setup lang="ts">
  2. import { StaticUrl } from '@/config'
  3. import router from '@/router'
  4. import selectAddressTemplate from '@/subPack-smqjh/components/selectAddress/index.vue?async'
  5. definePage({
  6. name: 'smqjh-cart',
  7. layout: 'tabbar',
  8. islogin: false,
  9. style: {
  10. navigationBarTitleText: '购物车',
  11. navigationStyle: 'custom',
  12. disableScroll: true,
  13. },
  14. })
  15. const { cartList, totalProduct } = storeToRefs(useSmqjhCartStore())
  16. const { smqjhSelectedAddress } = storeToRefs(useUserStore())
  17. const cartStore = useSmqjhCartStore()
  18. const priceDetailPopup = ref(false)
  19. const tab = ref(0)
  20. const selectAddress = ref(false)
  21. const navList = ref([
  22. { title: '全部', id: 1 },
  23. { title: '星闪豹', id: 2 },
  24. { title: '电影演出', id: 3 },
  25. // { title: '视频权益', id: 4 },
  26. // { title: '大牌点餐', id: 5 },
  27. { title: '加油', id: 6 },
  28. // { title: '酒店民宿', id: 7 },
  29. // { title: '代驾', id: 8 },
  30. ])
  31. watch(() => cartList.value, async () => {
  32. cartStore.getCartTotalPrice()
  33. }, {
  34. deep: true,
  35. })
  36. async function handleSelectAddress() {
  37. await useUserStore().checkLogin()
  38. selectAddress.value = true
  39. }
  40. </script>
  41. <template>
  42. <view class="pages">
  43. <wd-navbar
  44. title="" custom-style="background-color:transparent !important" :bordered="false" :z-index="99"
  45. safe-area-inset-top fixed
  46. >
  47. <template #left>
  48. <view class="ml-10rpx flex items-center" @click.stop="handleSelectAddress">
  49. <view class="mr-20rpx text-36rpx font-semibold">
  50. 购物车
  51. </view>
  52. <image :src="`${StaticUrl}/location-green.png`" class="h-33.8rpx w-29rpx" />
  53. <view class="ml-10rpx max-w-280rpx truncate text-32rpx text-[#222] font-semibold">
  54. {{ smqjhSelectedAddress?.city || '请选择地址' }}
  55. </view>
  56. </view>
  57. </template>
  58. </wd-navbar>
  59. <view class="xsb-linear h-406rpx" />
  60. <view class="-mt220rpx">
  61. <view class="flex items-center justify-between pb-16rpx">
  62. <view class="w-[85%]">
  63. <wd-tabs v-model="tab">
  64. <block v-for="tabs in navList" :key="tabs.id">
  65. <wd-tab :title="tabs.title" />
  66. </block>
  67. </wd-tabs>
  68. </view>
  69. <view class="guanli h-80rpx w-104rpx flex flex-shrink-0 items-center justify-center text-28rpx font-semibold">
  70. 管理
  71. </view>
  72. </view>
  73. <view v-if="cartList.length" class="mb20rpx flex items-center justify-end">
  74. <view class="text-24rpx text-[#AAAAAA]" @click="cartStore.cartDeleteGoods">
  75. <wd-icon name="delete" size="24rpx" /> 清空购物车
  76. </view>
  77. </view>
  78. <scroll-view scroll-y class="content box-border px-24rpx">
  79. <view v-for="shop in cartList" :key="shop.shopId" class="mb-24rpx rounded-16rpx bg-white px-24rpx pb-18rpx pt-28rpx">
  80. <wd-checkbox v-model="shop.AllShopGoods" size="large" @change="cartStore.cartStoreAllChecked($event, shop)">
  81. <view class="text-28rpx font-semibold">
  82. {{ shop.shopName }} <text class="text-24rpx text-#AAAAAA">
  83. 已选 {{ shop.allGoods.length }} 件<text v-if="shop.allGoods.length">
  84. ,总重量约为 {{ totalProduct?.totalWeight || 0 }} kg
  85. </text>
  86. </text>
  87. </view>
  88. </wd-checkbox>
  89. <view class="mt-20rpx h-2rpx w-full bg-[#F0F0F0]" />
  90. <wd-checkbox-group v-model="shop.allGoods" size="large" @change="cartStore.cartGoodsChecked($event, shop)">
  91. <view
  92. v-for="item in shop.skuList" :key="item.id" class="relative mt-20rpx flex items-center"
  93. >
  94. <view class="mr-20rpx h-32rpx w-32rpx">
  95. <wd-checkbox :model-value="item.id" />
  96. </view>
  97. <view class="flex flex-1">
  98. <image
  99. :src="item.pic"
  100. class="h-206rpx w-200rpx flex-shrink-0"
  101. @click.stop="router.push({ name: 'xsb-goods', params: { id: String(item.prodId) } })"
  102. />
  103. <view class="ml-20rpx flex-1">
  104. <view class="text-left text-28rpx font-semibold">
  105. <!-- <view v-for="i in 2" :key="i" class="mr5px inline-block">
  106. <wd-tag type="danger">
  107. 惊喜回馈
  108. </wd-tag>
  109. </view> -->
  110. {{ item.skuName }}
  111. </view>
  112. <view class="mt-14rpx text-24rpx text-[#AAAAAA]">
  113. 规格:{{ item.spec }}
  114. </view>
  115. <view class="mt-14rpx flex items-center justify-between">
  116. <view class="text-36rpx text-[#FF4A39] font-semibold">
  117. ¥{{ item.price }}
  118. </view>
  119. <!-- <wd-input-number v-model="item.num" disable-input @change="handleChangeNum($event, item)" /> -->
  120. <view class="flex items-center">
  121. <image
  122. :src="` ${StaticUrl}/sub-cart.png`"
  123. class="h-44rpx w-44rpx"
  124. @click.stop="cartStore.cartSubGoods(item)"
  125. />
  126. <view class="box-border h-44rpx w-84rpx flex items-center justify-center border border-[#F0F0F0] border-solid text-24rpx text-[#AAAAAA]">
  127. {{ item.num }}
  128. </view>
  129. <image
  130. :src="` ${StaticUrl}/add-cart.png`"
  131. class="h-44rpx w-44rpx"
  132. @click.stop="cartStore.cartAddGoods(item)"
  133. />
  134. </view>
  135. </view>
  136. </view>
  137. </view>
  138. <view v-if="item.shopSkuStocks == '0'" class="absolute left-0 top-0 z-1 h-full w-full flex items-center justify-center bg-[rgba(255,255,255,.6)]">
  139. <view class="rounded-16rpx bg-[rgba(0,0,0,.5)] p-20rpx text-white">
  140. 商品已售罄
  141. </view>
  142. </view>
  143. <view v-if="item.isDelete == '1'" class="absolute left-0 top-0 z-1 h-full w-full flex items-center justify-center bg-[rgba(255,255,255,.6)]">
  144. <view class="rounded-16rpx bg-[rgba(0,0,0,.5)] p-20rpx text-white">
  145. 商品已删除
  146. </view>
  147. </view>
  148. </view>
  149. </wd-checkbox-group>
  150. </view>
  151. <view v-if="!cartList.length" class="box-border w-full flex items-center justify-center">
  152. <view class="mt-220rpx flex flex-col items-center">
  153. <image :src="`${StaticUrl}/cart.png`" class="h-110rpx w-110rpx" />
  154. <view class="mb-20rpx mt-20rpx text-24rpx">
  155. 你还没有添加商品哦~
  156. </view>
  157. <wd-button plain @click=" useTabbar().setTabbarItemActive('smqjh-home'), router.pushTab({ name: 'smqjh-home' })">
  158. 去逛逛
  159. </wd-button>
  160. </view>
  161. </view>
  162. <view class="h-140rpx" />
  163. </scroll-view>
  164. </view>
  165. <view v-if="cartList.length" class="fixedShadow fixed bottom-60rpx left-0 z-99 box-border w-full flex items-center justify-between rounded-t-16rpx bg-white px-24rpx pb-60rpx pt-10rpx">
  166. <view class="ios w-full flex items-center justify-between">
  167. <view class="flex items-center">
  168. <view class="flex items-center">
  169. <image :src="`${StaticUrl}/cart-lanzi.png`" class="h-100rpx w-100rpx" />
  170. </view>
  171. <view class="ml-40rpx">
  172. <view class="flex items-center">
  173. <view class="font-semibold">
  174. ¥ {{ totalProduct?.amount || 0 }}
  175. </view>
  176. <view v-if="totalProduct?.coupon" class="ml-10rpx text-24rpx text-[#FF4A39]">
  177. 共减¥{{ totalProduct?.coupon }}
  178. </view>
  179. <view v-if="totalProduct?.amount" class="ml10rpx flex items-center text-24rpx text-gray" @click="priceDetailPopup = !priceDetailPopup">
  180. 明细 <view class="flex items-center" :class="[priceDetailPopup ? 'rotate-180' : '']">
  181. <wd-icon name="arrow-up" size="24rpx" color="#aaa" />
  182. </view>
  183. </view>
  184. </view>
  185. <view class="mt-10rpx text-24rpx text-gray">
  186. 配送费:¥{{ totalProduct?.transfee || 0 }}
  187. </view>
  188. </view>
  189. </view>
  190. <view class="flex items-center">
  191. <view class="ml-20rpx w-160rpx">
  192. <wd-button block size="large" @click="cartStore.cartOrderConfirm">
  193. 结算
  194. </wd-button>
  195. </view>
  196. </view>
  197. </view>
  198. </view>
  199. <!-- 价格明细弹窗 -->
  200. <Zpopup v-model="priceDetailPopup" :zindex="10" bg="#fff">
  201. <view class="ios box-border w-full px-40rpx pb-60rpx pt-36rpx">
  202. <view class="mb-40rpx text-center text-32rpx font-semibold">
  203. 价格明细
  204. </view>
  205. <view class="flex items-center justify-between py-20rpx">
  206. <view class="text-30rpx font-semibold">
  207. 商品合计
  208. </view>
  209. <view class="text-30rpx font-semibold">
  210. ¥{{ totalProduct?.amount }}
  211. </view>
  212. </view>
  213. <view class="flex items-center justify-between py-20rpx">
  214. <view class="text-28rpx text-[#333]">
  215. 商品总价
  216. </view>
  217. <view class="text-28rpx text-[#333]">
  218. ¥{{ totalProduct?.price }}
  219. </view>
  220. </view>
  221. <template v-if="totalProduct?.coupon">
  222. <view class="flex items-center justify-between py-20rpx">
  223. <view class="text-28rpx text-[#333]">
  224. 下单用券共减
  225. </view>
  226. <view class="text-28rpx text-[#FF4A39] font-semibold">
  227. -¥{{ totalProduct?.coupon }}
  228. </view>
  229. </view>
  230. <view v-if="totalProduct?.couponName" class="flex items-center justify-between pb-20rpx">
  231. <view class="text-24rpx text-[#AAAAAA]">
  232. {{ totalProduct?.couponName }}
  233. </view>
  234. <view class="text-24rpx text-[#AAAAAA]">
  235. -¥{{ totalProduct?.coupon }}
  236. </view>
  237. </view>
  238. </template>
  239. <view class="flex items-center justify-between py-20rpx">
  240. <view class="text-28rpx text-[#333]">
  241. 配送费
  242. </view>
  243. <view class="text-28rpx text-[#333]">
  244. ¥{{ totalProduct?.transfee }}
  245. </view>
  246. </view>
  247. </view>
  248. <view class="h-200rpx" />
  249. </Zpopup>
  250. <selectAddressTemplate v-model="selectAddress" />
  251. </view>
  252. </template>
  253. <style scoped lang="scss">
  254. .content {
  255. height: calc(100vh - var(--window-top) - 380rpx);
  256. height: calc(100vh - var(--window-top) - constant(safe-area-inset-bottom) - 380rpx);
  257. height: calc(100vh - var(--window-top) - env(safe-area-inset-bottom) - 380rpx);
  258. }
  259. .fixedShadow {
  260. box-shadow: 0rpx -6rpx 12rpx 2rpx rgba(0, 0, 0, 0.05);
  261. }
  262. .pages {
  263. :deep() {
  264. .wd-tabs {
  265. background: none !important;
  266. }
  267. .wd-tabs__nav {
  268. background: none !important;
  269. }
  270. .wd-tabs__nav-item-text{
  271. font-size: 28rpx !important;
  272. }
  273. }
  274. .guanli{
  275. box-shadow: -10rpx 0rpx 12rpx 2rpx rgba(0,0,0,0.07);
  276. }
  277. }
  278. </style>