index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. <scroll-view scroll-y class="content box-border px-24rpx">
  74. <view v-for="shop in cartList" :key="shop.shopId" class="mb-24rpx rounded-16rpx bg-white px-24rpx pb-18rpx pt-28rpx">
  75. <wd-checkbox v-model="shop.AllShopGoods" size="large" @change="cartStore.cartStoreAllChecked($event, shop)">
  76. <view class="text-28rpx font-semibold">
  77. {{ shop.shopName }}
  78. </view>
  79. </wd-checkbox>
  80. <view class="mt-20rpx h-2rpx w-full bg-[#F0F0F0]" />
  81. <wd-checkbox-group v-model="shop.allGoods" size="large" @change="cartStore.cartGoodsChecked($event, shop)">
  82. <view
  83. v-for="item in shop.skuList" :key="item.id" class="relative mt-20rpx flex items-center"
  84. >
  85. <view class="mr-20rpx h-32rpx w-32rpx">
  86. <wd-checkbox :model-value="item.id" />
  87. </view>
  88. <view class="flex flex-1">
  89. <image
  90. :src="item.pic"
  91. class="h-206rpx w-200rpx flex-shrink-0"
  92. @click.stop="router.push({ name: 'xsb-goods', params: { id: String(item.prodId) } })"
  93. />
  94. <view class="ml-20rpx flex-1">
  95. <view class="text-left text-28rpx font-semibold">
  96. <!-- <view v-for="i in 2" :key="i" class="mr5px inline-block">
  97. <wd-tag type="danger">
  98. 惊喜回馈
  99. </wd-tag>
  100. </view> -->
  101. {{ item.skuName }}
  102. </view>
  103. <view class="mt-14rpx text-24rpx text-[#AAAAAA]">
  104. 规格:{{ item.spec }}
  105. </view>
  106. <view class="mt-14rpx flex items-center justify-between">
  107. <view class="text-36rpx text-[#FF4A39] font-semibold">
  108. ¥{{ item.price }}
  109. </view>
  110. <!-- <wd-input-number v-model="item.num" disable-input @change="handleChangeNum($event, item)" /> -->
  111. <view class="flex items-center">
  112. <image
  113. :src="` ${StaticUrl}/sub-cart.png`"
  114. class="h-44rpx w-44rpx"
  115. @click.stop="cartStore.cartSubGoods(item)"
  116. />
  117. <view class="box-border h-44rpx w-84rpx flex items-center justify-center border border-[#F0F0F0] border-solid text-24rpx text-[#AAAAAA]">
  118. {{ item.num }}
  119. </view>
  120. <image
  121. :src="` ${StaticUrl}/add-cart.png`"
  122. class="h-44rpx w-44rpx"
  123. @click.stop="cartStore.cartAddGoods(item)"
  124. />
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. <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)]">
  130. <view class="rounded-16rpx bg-[rgba(0,0,0,.5)] p-20rpx text-white">
  131. 商品已售罄
  132. </view>
  133. </view>
  134. <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)]">
  135. <view class="rounded-16rpx bg-[rgba(0,0,0,.5)] p-20rpx text-white">
  136. 商品已删除
  137. </view>
  138. </view>
  139. </view>
  140. </wd-checkbox-group>
  141. </view>
  142. <view v-if="!cartList.length" class="box-border w-full flex items-center justify-center">
  143. <view class="mt-220rpx flex flex-col items-center">
  144. <image :src="`${StaticUrl}/cart.png`" class="h-110rpx w-110rpx" />
  145. <view class="mb-20rpx mt-20rpx text-24rpx">
  146. 你还没有添加商品哦~
  147. </view>
  148. <wd-button plain @click=" useTabbar().setTabbarItemActive('smqjh-home'), router.pushTab({ name: 'smqjh-home' })">
  149. 去逛逛
  150. </wd-button>
  151. </view>
  152. </view>
  153. <view class="h-140rpx" />
  154. </scroll-view>
  155. </view>
  156. <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">
  157. <view class="ios w-full flex items-center justify-between">
  158. <view class="flex items-center">
  159. <view class="flex items-center">
  160. <image :src="`${StaticUrl}/cart-lanzi.png`" class="h-100rpx w-100rpx" />
  161. </view>
  162. <view class="ml-40rpx">
  163. <view class="flex items-center">
  164. <view class="font-semibold">
  165. ¥ {{ totalProduct?.amount || 0 }}
  166. </view>
  167. <view v-if="totalProduct?.coupon" class="ml-10rpx text-24rpx text-[#FF4A39]">
  168. 共减¥{{ totalProduct?.coupon }}
  169. </view>
  170. <view v-if="totalProduct?.amount" class="ml-10rpx text-24rpx text-gray" @click="priceDetailPopup = true">
  171. 明细 <wd-icon name="arrow-up" size="24rpx" color="#aaa" />
  172. </view>
  173. </view>
  174. <view class="mt-10rpx text-24rpx text-gray">
  175. 配送费:¥{{ totalProduct?.transfee || 0 }}
  176. </view>
  177. </view>
  178. </view>
  179. <view class="flex items-center">
  180. <view class="ml-20rpx w-160rpx">
  181. <wd-button block size="large" @click="cartStore.cartOrderConfirm">
  182. 结算
  183. </wd-button>
  184. </view>
  185. </view>
  186. </view>
  187. </view>
  188. <!-- 价格明细弹窗 -->
  189. <Zpopup v-model="priceDetailPopup" :zindex="10" bg="#fff">
  190. <view class="ios box-border w-full px-40rpx pb-60rpx pt-36rpx">
  191. <view class="mb-40rpx text-center text-32rpx font-semibold">
  192. 价格明细
  193. </view>
  194. <view class="flex items-center justify-between py-20rpx">
  195. <view class="text-30rpx font-semibold">
  196. 商品合计
  197. </view>
  198. <view class="text-30rpx font-semibold">
  199. ¥{{ totalProduct?.amount }}
  200. </view>
  201. </view>
  202. <view class="flex items-center justify-between py-20rpx">
  203. <view class="text-28rpx text-[#333]">
  204. 商品总价
  205. </view>
  206. <view class="text-28rpx text-[#333]">
  207. ¥{{ totalProduct?.price }}
  208. </view>
  209. </view>
  210. <template v-if="totalProduct?.coupon">
  211. <view class="flex items-center justify-between py-20rpx">
  212. <view class="text-28rpx text-[#333]">
  213. 下单用券共减
  214. </view>
  215. <view class="text-28rpx text-[#FF4A39] font-semibold">
  216. -¥{{ totalProduct?.coupon }}
  217. </view>
  218. </view>
  219. <view v-if="totalProduct?.couponName" class="flex items-center justify-between pb-20rpx">
  220. <view class="text-24rpx text-[#AAAAAA]">
  221. {{ totalProduct?.couponName }}
  222. </view>
  223. <view class="text-24rpx text-[#AAAAAA]">
  224. -¥{{ totalProduct?.coupon }}
  225. </view>
  226. </view>
  227. </template>
  228. <view class="flex items-center justify-between py-20rpx">
  229. <view class="text-28rpx text-[#333]">
  230. 配送费
  231. </view>
  232. <view class="text-28rpx text-[#333]">
  233. ¥{{ totalProduct?.transfee }}
  234. </view>
  235. </view>
  236. </view>
  237. <view class="h-200rpx" />
  238. </Zpopup>
  239. <selectAddressTemplate v-model="selectAddress" />
  240. </view>
  241. </template>
  242. <style scoped lang="scss">
  243. .content {
  244. height: calc(100vh - var(--window-top) - 380rpx);
  245. height: calc(100vh - var(--window-top) - constant(safe-area-inset-bottom) - 380rpx);
  246. height: calc(100vh - var(--window-top) - env(safe-area-inset-bottom) - 380rpx);
  247. }
  248. .fixedShadow {
  249. box-shadow: 0rpx -6rpx 12rpx 2rpx rgba(0, 0, 0, 0.05);
  250. }
  251. .pages {
  252. :deep() {
  253. .wd-tabs {
  254. background: none !important;
  255. }
  256. .wd-tabs__nav {
  257. background: none !important;
  258. }
  259. .wd-tabs__nav-item-text{
  260. font-size: 28rpx !important;
  261. }
  262. }
  263. .guanli{
  264. box-shadow: -10rpx 0rpx 12rpx 2rpx rgba(0,0,0,0.07);
  265. }
  266. }
  267. </style>