classfiy.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. <script setup lang="ts">
  2. import type { LoadMoreState } from 'wot-design-uni/components/wd-loadmore/types'
  3. import selectSku from '../../components/select-sku/index.vue'
  4. import { StaticUrl } from '@/config'
  5. import router from '@/router'
  6. const props = defineProps<{ categoryList: Api.xsbCategories[], hotText: Api.xsbSearchTerm[] }>()
  7. const { statusBarHeight, MenuButtonHeight } = storeToRefs(useSysStore())
  8. const { topNavActive, leftActive, SelectShopInfo } = storeToRefs(useSysXsbStore())
  9. const { userInfo, token } = storeToRefs(useUserStore())
  10. const classfiylist = computed(() => props.categoryList)
  11. const sortClassBtn = ref(1)
  12. const show = ref(false)
  13. const cartList = ref<Api.xsbCategoriesCartList[]>([])
  14. const cartIds = computed(() => cartList.value.filter(it => it.isDelete !== '1' && it.shopSkuStocks !== '0').map(it => it.id))
  15. const showball = ref(false)
  16. const _this = getCurrentInstance()
  17. const selectGoods = ref(false)
  18. // 多规格商品skuid
  19. const selectSkuId = ref(0)
  20. const SelectGoodsNum = ref(1)
  21. const goodsInTo = ref()
  22. const goodsInfo = ref<Api.xsbCategoryProductList | Api.xsbProductDetail | undefined>()
  23. definePage({
  24. name: 'xsb-classfiy',
  25. islogin: false,
  26. style: {
  27. navigationStyle: 'custom',
  28. navigationBarTitleText: '星闪豹分类',
  29. disableScroll: true,
  30. },
  31. })
  32. const isTopLoading = ref(false)
  33. const cartPopup = ref(false)
  34. const basllObj = ref({
  35. left: 0,
  36. top: 0,
  37. x: -402,
  38. y: 773,
  39. })
  40. const x = computed(() => `${basllObj.value.x}px`)
  41. const y = computed(() => `${basllObj.value.y}px`)
  42. const left = computed(() => `${basllObj.value.left}px`)
  43. const top = computed(() => `${basllObj.value.top}px`)
  44. const productList = ref<Api.xsbCategoryProductList[]>([])
  45. const topScrollView = ref()
  46. const scrollTop = ref<number | undefined>(0)
  47. const goodsLoading = ref<LoadMoreState>()
  48. const navHeight = computed(() => {
  49. return (`${Number(MenuButtonHeight.value) + Number(statusBarHeight.value)}px`)
  50. })
  51. const totalProduct = ref<Api.shoppingCartOrderConfirm>()
  52. function handleTopNavChange(item: Api.xsbCategoriesChildren) {
  53. topNavActive.value = item.code
  54. if (!item.children)
  55. return
  56. goodsLoading.value = 'loading'
  57. leftActive.value = item.children[0].code
  58. show.value = false
  59. topScrollView.value = null
  60. nextTick(() => {
  61. topScrollView.value = item.code
  62. })
  63. getProductList()
  64. }
  65. const categories = computed(() => {
  66. return classfiylist.value.find(it => it.code === topNavActive.value)?.children || []
  67. })
  68. const categoriesId = computed(() => {
  69. return categories.value.find(it => it.code === leftActive.value)?.id
  70. })
  71. async function getCartCategorList() {
  72. return new Promise((resolve, reject) => {
  73. Apis.xsb.myShoppingCartCategory({
  74. data: {
  75. businessType: 'XSB',
  76. channelId: unref(userInfo).channelId,
  77. shopId: unref(SelectShopInfo).shopId,
  78. },
  79. }).then((res) => {
  80. cartList.value = res.data
  81. if (cartList.value.length) {
  82. getGoodsPrice()
  83. }
  84. resolve(res)
  85. }).catch((err) => {
  86. reject(err)
  87. })
  88. })
  89. }
  90. function handleChange({ value }: { value: string }) {
  91. leftActive.value = value
  92. getProductList()
  93. }
  94. function handleLeftChange(item: Api.xsbCategories) {
  95. goodsLoading.value = 'loading'
  96. handleChange({ value: item.code })
  97. }
  98. async function getProductList() {
  99. const res = await Apis.xsb.getCategoryProductList({
  100. data: {
  101. categoryId: Number(categoriesId.value),
  102. shopId: Number(SelectShopInfo.value?.shopId) || 1,
  103. channelId: unref(userInfo).channelId || 1,
  104. },
  105. })
  106. productList.value = res.data
  107. if (!res.data.length) {
  108. scrollTop.value = undefined
  109. nextTick(() => {
  110. scrollTop.value = 0
  111. })
  112. }
  113. if (!isTopLoading.value) {
  114. scrollTop.value = undefined
  115. nextTick(() => {
  116. scrollTop.value = 0
  117. })
  118. }
  119. else {
  120. goodsInTo.value = null
  121. nextTick(() => {
  122. goodsInTo.value = res.data.length > 4 ? res.data[res.data.length - 4].prodId : null
  123. })
  124. }
  125. goodsLoading.value = 'finished'
  126. isTopLoading.value = false
  127. setProductNum()
  128. }
  129. function handlScrollBottom() {
  130. goodsLoading.value = 'loading'
  131. const index = categories?.value.findIndex(it => it.code === leftActive.value)
  132. console.log(index, '-================')
  133. if (index + 1 === categories.value.length) {
  134. goodsLoading.value = 'finished'
  135. return
  136. }
  137. if (index !== -1) {
  138. handleChange({ value: categories.value[index + 1].code })
  139. }
  140. }
  141. function handleSrollTop() {
  142. isTopLoading.value = true
  143. const index = categories?.value.findIndex(it => it.code === leftActive.value)
  144. if (index !== -1) {
  145. if (index === 0) {
  146. nextTick(() => isTopLoading.value = false)
  147. }
  148. else {
  149. handleChange({ value: categories.value[index - 1].code })
  150. }
  151. }
  152. }
  153. async function handleAddCart(event: WechatMiniprogram.TouchEvent, item: Api.xsbCategoryProductList) {
  154. await useUserStore().checkLogin()
  155. if (item.skuList.length > 1) {
  156. goodsInfo.value = item
  157. selectGoods.value = true
  158. return
  159. }
  160. if (showball.value)
  161. return
  162. basllObj.value.left = event.detail.x
  163. basllObj.value.top = event.detail.y
  164. showball.value = true
  165. setTimeout(() => {
  166. showball.value = false
  167. }, 500)
  168. await useSmqjhCartStore().addCart(item.skuList[0].skuId, 1, Number(item.shopId), 'XSB')
  169. await getCartCategorList()
  170. setProductNum()
  171. }
  172. async function handleSubCart(event: WechatMiniprogram.TouchEvent, item: Api.xsbCategoryProductList) {
  173. if (item.num === 1) {
  174. useGlobalMessage().confirm({
  175. msg: '是否删除该商品?',
  176. success: async () => {
  177. await useSmqjhCartStore().addCart(item.skuList[0].skuId, -1, Number(item.shopId), 'XSB')
  178. await getCartCategorList()
  179. setProductNum()
  180. },
  181. })
  182. }
  183. else {
  184. if (showball.value)
  185. return
  186. basllObj.value.left = event.detail.x
  187. basllObj.value.top = event.detail.y
  188. showball.value = true
  189. setTimeout(() => {
  190. showball.value = false
  191. }, 500)
  192. await useSmqjhCartStore().addCart(item.skuList[0].skuId, -1, Number(item.shopId), 'XSB')
  193. await getCartCategorList()
  194. setProductNum()
  195. }
  196. }
  197. onMounted(async () => {
  198. if (!topNavActive.value || !leftActive.value) {
  199. topNavActive.value = props.categoryList && props.categoryList[0].code
  200. leftActive.value = props.categoryList[0].children && props.categoryList[0].children[0].code
  201. }
  202. if (leftActive.value) {
  203. handleChange({ value: leftActive.value })
  204. }
  205. if (topNavActive.value) {
  206. topScrollView.value = null
  207. nextTick(() => {
  208. topScrollView.value = topNavActive.value
  209. })
  210. }
  211. getCartBox()
  212. if (token.value) {
  213. // goodsLoading.value = 'loading'
  214. await getCartCategorList()
  215. }
  216. })
  217. function getCartBox() {
  218. const query = uni.createSelectorQuery().in(_this)
  219. query.select('.cart-box').boundingClientRect()
  220. query.exec((res) => {
  221. basllObj.value.y = res[0].top
  222. uni.getSystemInfo().then((info) => {
  223. basllObj.value.x = -(info.screenWidth - res[0].left - 15)
  224. console.log(basllObj.value.x, basllObj.value.y)
  225. })
  226. })
  227. }
  228. function handleGo(item: Api.xsbCategoryProductList) {
  229. if (!item.prodId) {
  230. useGlobalToast().show('后端数据异常!')
  231. return
  232. }
  233. router.push({ name: 'xsb-goods', params: { id: String(item.prodId) } })
  234. }
  235. async function getGoodsPrice() {
  236. if (cartIds.value.length) {
  237. const res = await useSmqjhCartStore().getCartAddGoodsPrice(cartIds.value.join(','))
  238. totalProduct.value = res
  239. }
  240. }
  241. async function handleSub(item: Api.xsbCategoriesCartList) {
  242. if (item.num === 1) {
  243. useGlobalMessage().confirm({
  244. msg: '是否删除该商品?',
  245. success: async () => {
  246. cartPopup.value = false
  247. await useSmqjhCartStore().addCart(item.skuId, -1, item.shopId, 'XSB')
  248. await getCartCategorList()
  249. setProductNum()
  250. totalProduct.value = undefined
  251. },
  252. })
  253. }
  254. else {
  255. await useSmqjhCartStore().addCart(item.skuId, -1, item.shopId, 'XSB')
  256. getGoodsPrice()
  257. await getCartCategorList()
  258. setProductNum()
  259. }
  260. }
  261. async function handleAdd(item: Api.xsbCategoriesCartList) {
  262. await useSmqjhCartStore().addCart(item.skuId, 1, item.shopId, 'XSB')
  263. getGoodsPrice()
  264. await getCartCategorList()
  265. setProductNum()
  266. }
  267. onUnmounted(() => {
  268. console.log('组件卸载')
  269. topNavActive.value = ''
  270. leftActive.value = ''
  271. })
  272. async function handleDelCartGoods(item: Api.xsbCategoriesCartList) {
  273. const msg = item.isDelete ? '商品已被商家删除,是否确认删除该门店下的商品?' : '门店商品库存不足,是否删除该门店下的商品?'
  274. useGlobalMessage().confirm({
  275. title: '提示',
  276. msg,
  277. success: async () => {
  278. uni.showLoading({ mask: true })
  279. try {
  280. await Apis.common.deleteShoppingCart({
  281. pathParams: {
  282. ids: String(item.id),
  283. },
  284. })
  285. await getCartCategorList()
  286. uni.hideLoading()
  287. }
  288. catch {
  289. uni.hideLoading()
  290. }
  291. },
  292. })
  293. }
  294. function setProductNum() {
  295. if (!cartList.value.length) {
  296. productList.value = productList.value.map((goods) => {
  297. goods.num = undefined
  298. return goods
  299. })
  300. return
  301. }
  302. cartList.value.forEach((it) => {
  303. productList.value = productList.value.map((goods) => {
  304. if (goods.skuList.length && goods.skuList[0].skuId === it.skuId) {
  305. goods.num = it.num
  306. }
  307. return goods
  308. })
  309. })
  310. }
  311. async function handleSkuAddCart() {
  312. await useSmqjhCartStore().addCart(unref(selectSkuId), unref(SelectGoodsNum), Number(goodsInfo.value?.shopId), 'XSB')
  313. getGoodsPrice()
  314. await getCartCategorList()
  315. }
  316. function handlePay() {
  317. if (!totalProduct.value) {
  318. useGlobalToast().show('请选择商品')
  319. return
  320. }
  321. const shopSkuStock = totalProduct.value.skuList.filter(it => it.num > Number(it.shopSkuStocks))
  322. if (shopSkuStock.length) {
  323. useGlobalToast().show({ msg: `${shopSkuStock[0].skuName}库存不足` })
  324. return
  325. }
  326. router.push({ name: 'xsb-confirmOrder', params: { data: JSON.stringify(totalProduct.value) } })
  327. }
  328. </script>
  329. <template>
  330. <view class="page-xsb">
  331. <wd-navbar
  332. title="" custom-style="background-color:#F4FFD1" :bordered="false" :z-index="99" safe-area-inset-top
  333. fixed
  334. >
  335. <template #left>
  336. <view class="flex items-center" @click="router.push({ name: 'xsb-search' })">
  337. <view
  338. class="h60rpx w-474rpx flex items-center justify-between border-2rpx border-[var(--them-color)] rounded-40rpx border-solid bg-white pr6rpx"
  339. >
  340. <view class="flex items-center pb14rpx pl24rpx pt16rpx">
  341. <wd-icon name="search" size="14" color="#ccc" />
  342. <view class="search ml12rpx h-full w-full overflow-hidden">
  343. <wd-notice-bar
  344. :text="hotText.map((it) => it.searchName)" custom-class="notice-bar" color="#ccc"
  345. background-color="#fff" direction="vertical"
  346. />
  347. </view>
  348. </view>
  349. <view class="flex items-center pr28rpx">
  350. <wd-divider vertical />
  351. <view class="ml6rpx text-28rpx text-[var(--them-color)] font-semibold">
  352. 搜索
  353. </view>
  354. </view>
  355. </view>
  356. </view>
  357. </template>
  358. </wd-navbar>
  359. <view
  360. class="h162rpx flex items-center justify-between bg-#F4FFD1 pl24rpx"
  361. :style="{ paddingTop: `${(Number(statusBarHeight) || 44) + MenuButtonHeight + 12}px` }"
  362. >
  363. <scroll-view
  364. :scroll-into-view-offset="-150" scroll-x enable-passive scroll-with-animation
  365. class="scrollx w-90% flex-shrink-0 whitespace-nowrap" :scroll-into-view="`id${topScrollView}`"
  366. >
  367. <view class="flex items-end pb10rpx">
  368. <view
  369. v-for="item in classfiylist" :id="`id${item.code}`" :key="item.code"
  370. class="mr24rpx flex flex-col items-center justify-center" @click="handleTopNavChange(item)"
  371. >
  372. <view class="relative">
  373. <view class="box-border" :class="[topNavActive == item.code ? 'overflow-hidden border-solid border-[var(--them-color)] border-2rpx rounded-26rpx h84rpx w-84rpx' : 'h72rpx w-72rpx']">
  374. <image
  375. :src="item.icon"
  376. class="h-full w-full"
  377. />
  378. </view>
  379. <view v-if="!item.children" class="absolute left-0 top-0 h-full w-full flex items-center justify-center rounded-26rpx bg-[rgba(0,0,0,0.6)] text-16rpx text-white">
  380. 敬请期待
  381. </view>
  382. </view>
  383. <view
  384. class="mt16rpx text-22rpx"
  385. :class="[topNavActive == item.code ? 'bg-[var(--them-color)] rounded-18rpx px-8rpx py2rpx text-white text-24rpx' : '']"
  386. >
  387. {{ item.name }}
  388. </view>
  389. </view>
  390. </view>
  391. </scroll-view>
  392. <view
  393. class="right-nav box-border h144rpx w64rpx flex flex-shrink-0 flex-col items-center justify-center px20rpx text-24rpx font-semibold"
  394. @click="show = true"
  395. >
  396. 展开
  397. <image :src="`${StaticUrl}/xia.png`" class="mt20rpx h20rpx w20rpx" />
  398. </view>
  399. <wd-popup v-model="show" position="top" custom-style="border-radius:32rpx;">
  400. <view
  401. class="box-border bg-#F4FFD1 p24rpx"
  402. :style="{ paddingTop: `${(Number(statusBarHeight) || 44) + MenuButtonHeight + 12}px` }"
  403. >
  404. <view class="mb24rpx mt24rpx text-28rpx font-semibold">
  405. 全部一级分类
  406. </view>
  407. <view class="h400rpx overflow-y-scroll">
  408. <view class="grid grid-cols-5 box-border gap-x-24rpx gap-y-24rpx">
  409. <view
  410. v-for="item in classfiylist" :key="item.code"
  411. class="box-border h150rpx w114rpx flex flex-col items-center justify-center"
  412. @click="handleTopNavChange(item)"
  413. >
  414. <image
  415. :src="item.icon"
  416. :class="[topNavActive == item.code ? 'overflow-hidden border-solid border-[var(--them-color)] border-2rpx rounded-26rpx h88rpx w-88rpx' : 'h76rpx w-76rpx']"
  417. />
  418. <view
  419. class="mt16rpx whitespace-nowrap text-nowrap text-22rpx"
  420. :class="[topNavActive == item.code ? 'bg-[var(--them-color)] rounded-18rpx px-8rpx py2rpx text-white text-24rpx' : '']"
  421. >
  422. {{ item.name }}
  423. </view>
  424. </view>
  425. </view>
  426. </view>
  427. <view class="mt24rpx w-full flex items-center justify-center" @click="show = false">
  428. <view class="mr8rpx text-24rpx">
  429. 点击收起
  430. </view>
  431. <wd-icon name="arrow-down" size="18px" />
  432. </view>
  433. </view>
  434. </wd-popup>
  435. </view>
  436. <view class="wraper">
  437. <scroll-view class="w200rpx" :scroll-into-view-offset="-150" enable-passive scroll-with-animation scroll-y :scroll-into-view="`id${leftActive}`">
  438. <view v-for="item in categories" :id="`id${item.code}`" :key="item.code" :class="[item.code == leftActive ? 'bg-white' : '']" class="relative h100rpx flex items-center justify-center whitespace-nowrap text-28rpx" @click="handleLeftChange(item)">
  439. {{ item.name }}
  440. <view v-if="item.code == leftActive" class="absolute left-0 top-20rpx h60rpx w8rpx rounded-4rpx bg-[var(--them-color)]" />
  441. </view>
  442. </scroll-view>
  443. <view class="content">
  444. <view class="p20rpx">
  445. <image :src="`${StaticUrl}/class.png`" class="h144rpx w-full" @click="useGlobalToast().show('敬请期待 !')" />
  446. <view class="my20rpx flex items-center justify-end rounded-16rpx bg-#F6F6F6 px20rpx py8rpx">
  447. <view class="mr40rpx text-24rpx">
  448. 销量
  449. </view>
  450. <wd-sort-button v-model="sortClassBtn" :line="false" title="价格" />
  451. </view>
  452. </view>
  453. <view class="relative">
  454. <scroll-view
  455. :lower-threshold="100"
  456. :refresher-triggered="isTopLoading" :scroll-top="scrollTop"
  457. :style="{ height: `calc(100vh - ${navHeight} - 700rpx)` }" enable-passive scroll-y scroll-anchoring refresher-enabled :throttle="false"
  458. :scroll-into-view="`class${goodsInTo}`"
  459. @refresherrefresh="handleSrollTop"
  460. @scrolltolower="handlScrollBottom"
  461. >
  462. <view v-if="productList.length" class="p20rpx">
  463. <view v-for="item in productList" :id="`class${item.prodId}`" :key="item.id" class="relative">
  464. <view class="flex" @click="handleGo(item)">
  465. <view class="mr20rpx h172rpx w172rpx flex-shrink-0 overflow-hidden rounded-16rpx bg-#F6F6F6">
  466. <image :src="item.pic" lazy-load class="h-full w-full" />
  467. </view>
  468. <view class="flex-1">
  469. <view class="text-left text-28rpx font-semibold">
  470. <!-- <view v-for="i in 2" :key="i" class="mr5px inline-block">
  471. <wd-tag type="primary">
  472. 新品{{ i }}
  473. </wd-tag>
  474. </view> -->
  475. {{ item.prodName }}
  476. </view>
  477. <view class="text-22rpx text-#AAAAAA">
  478. <view class="mt10rpx flex items-center">
  479. <view>{{ item.spec }}</view>
  480. </view>
  481. <view class="mt6rpx">
  482. 已售 {{ item.soldNum }}+
  483. </view>
  484. </view>
  485. <view class="flex items-center justify-between">
  486. <view class="text-#FF4D3A font-semibold">
  487. <text class="text-24rpx">
  488. </text> <text class="text-36rpx">
  489. {{ item.channelProdPrice }}
  490. </text>
  491. </view>
  492. <view v-if="!item.num">
  493. <view v-if="item.spuStock" @click.stop="handleAddCart($event, item)">
  494. <image :src="`${StaticUrl}/cart-yes.png`" class="h52rpx w52rpx" />
  495. </view>
  496. <view v-else>
  497. <image :src="`${StaticUrl}/cart-no.png`" class="h52rpx w52rpx" />
  498. </view>
  499. </view>
  500. <view v-else>
  501. <view class="flex items-center">
  502. <image
  503. :src="` ${StaticUrl}/sub-cart.png`"
  504. class="h44rpx w44rpx"
  505. @click.stop="handleSubCart($event, item)"
  506. />
  507. <view class="box-border h44rpx w84rpx flex items-center justify-center border border-#F0F0F0 border-solid text-24rpx text-#AAAAAA">
  508. {{ item.num }}
  509. </view>
  510. <image
  511. :src="` ${StaticUrl}/add-cart.png`"
  512. class="h44rpx w44rpx"
  513. @click.stop="handleAddCart($event, item)"
  514. />
  515. </view>
  516. </view>
  517. </view>
  518. </view>
  519. </view>
  520. <view class="line">
  521. <wd-divider color="#F0F0F0" />
  522. </view>
  523. <view v-if="!item.spuStock" class="absolute left-0 top-0 z-1 h-full w-full flex items-center bg-[rgba(255,255,255,.6)]">
  524. <view class="h172rpx w172rpx flex items-center justify-center">
  525. <view class="h36rpx w112rpx flex items-center justify-center rounded-16rpx bg-[rgba(0,0,0,.6)] text-28rpx text-white">
  526. 已售罄
  527. </view>
  528. </view>
  529. </view>
  530. </view>
  531. </view>
  532. <wd-status-tip v-else image="content" tip="暂无内容" />
  533. <view v-if="goodsLoading == 'finished' || isTopLoading" class="h-30vh" />
  534. </scroll-view>
  535. <view v-if="goodsLoading == 'loading' || isTopLoading" class="absolute left-0 top-0 z-10 h-full w-full flex items-center justify-center bg-white">
  536. <wd-loading color="#9ED605" :size="20" />
  537. </view>
  538. </view>
  539. </view>
  540. </view>
  541. <view
  542. class="fixedShadow fixed bottom-60rpx left-0 z-100 box-border w-full flex items-center justify-between rounded-t-16rpx bg-white px24rpx pb60rpx pt10rpx"
  543. >
  544. <view class="ios w-full flex items-center justify-between">
  545. <view class="flex items-center" @click="cartPopup = true">
  546. <image :src="`${StaticUrl}/cart-lanzi.png`" class="cart-box h100rpx w100rpx" />
  547. </view>
  548. <view class="flex items-center">
  549. <view class="flex items-center font-semibold">
  550. <view class="text-22rpx text-#222">
  551. 总计:
  552. </view>
  553. <view class="flex items-baseline text-24rpx text-#FF4A39">
  554. <text class="text-36rpx">
  555. {{ totalProduct?.price || '0.00' }}
  556. </text>
  557. </view>
  558. </view>
  559. <view class="ml20rpx w160rpx">
  560. <wd-button block size="large" @click="handlePay">
  561. 结算
  562. </wd-button>
  563. </view>
  564. </view>
  565. </view>
  566. </view>
  567. <Zpopup v-model="cartPopup" :zindex="99">
  568. <view class="ios h800rpx overflow-y-scroll">
  569. <view class="p24rpx">
  570. <view
  571. v-for="item in cartList" :key="item.id" class="relative mt20rpx box-border flex items-center overflow-hidden rounded-16rpx bg-white p24rpx"
  572. >
  573. <view class="flex flex-1">
  574. <image
  575. :src="item.pic"
  576. class="h206rpx w200rpx flex-shrink-0"
  577. @click.stop="router.push({ name: 'xsb-goods', params: { id: String(item.prodId) } })"
  578. />
  579. <view class="ml20rpx flex-1">
  580. <view class="text-left text-28rpx font-semibold">
  581. <!-- <view v-for="i in 2" :key="i" class="mr5px inline-block">
  582. <wd-tag type="danger">
  583. 惊喜回馈
  584. </wd-tag>
  585. </view> -->
  586. {{ item.skuName }}
  587. </view>
  588. <view class="mt14rpx text-24rpx text-#AAAAAA">
  589. 规格:{{ item.spec }}
  590. </view>
  591. <view class="mt14rpx flex items-center justify-between">
  592. <view class="text-36rpx text-#FF4A39 font-semibold">
  593. ¥{{ item.price }}
  594. </view>
  595. <!-- <wd-input-number v-model="item.num" disable-input @change="handleChangeNum($event, item)" /> -->
  596. <view v-if="item.shopSkuStocks !== '0' && item.isDelete !== '1'" class="flex items-center">
  597. <image
  598. :src="` ${StaticUrl}/sub-cart.png`"
  599. class="h44rpx w44rpx"
  600. @click.stop="handleSub(item)"
  601. />
  602. <view class="box-border h44rpx w84rpx flex items-center justify-center border border-#F0F0F0 border-solid text-24rpx text-#AAAAAA">
  603. {{ item.num }}
  604. </view>
  605. <image
  606. :src="` ${StaticUrl}/add-cart.png`"
  607. class="h44rpx w44rpx"
  608. @click.stop="handleAdd(item)"
  609. />
  610. </view>
  611. </view>
  612. </view>
  613. </view>
  614. <view v-if="item.shopSkuStocks == '0' || item.isDelete == '1'" class="absolute left-0 top-0 z-1 h-full w-full bg-[rgba(255,255,255,.6)]">
  615. <view class="relative w-full flex items-center justify-center">
  616. <view class="rounded-16rpx bg-[rgba(0,0,0,.5)] p20rpx text-white">
  617. {{ item.shopSkuStocks == '0' ? '商品已售罄' : '商品已删除' }}
  618. </view>
  619. <view class="absolute bottom-20rpx right-20rpx">
  620. <wd-button @click="handleDelCartGoods(item)">
  621. 删除商品
  622. </wd-button>
  623. </view>
  624. </view>
  625. </view>
  626. </view>
  627. </view>
  628. <wd-status-tip v-if="!cartList.length" image="content" tip="暂无内容" />
  629. <view class="h320rpx" />
  630. </view>
  631. </Zpopup>
  632. <selectSku v-model:show="selectGoods" v-model:sku-id="selectSkuId" v-model:select-goods-num="SelectGoodsNum" :goods-info="goodsInfo!">
  633. <template #footer>
  634. <view class="box-border w-full flex items-center justify-between py20rpx">
  635. <view class="w-48%">
  636. <wd-button hairline plain block @click="selectGoods = false">
  637. 取消
  638. </wd-button>
  639. </view>
  640. <view class="w-48%">
  641. <wd-button block @click="handleSkuAddCart">
  642. 加入购物车
  643. </wd-button>
  644. </view>
  645. </view>
  646. </template>
  647. </selectSku>
  648. <view v-if="showball" class="ball">
  649. <image :src="`${StaticUrl}/cart-yes.png`" class="cart-img h52rpx w52rpx" />
  650. </view>
  651. </view>
  652. </template>
  653. <style scoped lang="scss">
  654. .right-nav {
  655. background: linear-gradient(180deg, #FAFFEC 0%, #F6FFDE 11%, #E7FFA5 100%);
  656. box-shadow: -10rpx 0rpx 12rpx 2rpx rgba(0, 0, 0, 0.07);
  657. }
  658. .fixedShadow{
  659. box-shadow: 0rpx -6rpx 12rpx 2rpx rgba(0,0,0,0.05);
  660. }
  661. .wraper {
  662. display: flex;
  663. height: calc(100vh - var(--window-top) - v-bind(navHeight) - 390rpx - var(--window-bottom));
  664. height: calc(100vh - var(--window-top) - constant(safe-area-inset-bottom) - v-bind(navHeight) - 390rpx - var(--window-bottom));
  665. height: calc(100vh - var(--window-top) - env(safe-area-inset-bottom) - v-bind(navHeight) - 390rpx - var(--window-bottom));
  666. }
  667. .content {
  668. flex: 1;
  669. background: #fff;
  670. }
  671. @keyframes moveX {
  672. to {
  673. transform: translateX(v-bind(x));
  674. }
  675. }
  676. @keyframes moveY {
  677. to {
  678. transform: translateY(v-bind(y));
  679. }
  680. }
  681. .ball {
  682. position: fixed;
  683. z-index: 80;
  684. left: v-bind(left);
  685. top: v-bind(top);
  686. animation: moveX .5s linear forwards;
  687. }
  688. .cart-img {
  689. animation: moveY .5s cubic-bezier(1,-1.26,1,1) forwards;
  690. }
  691. </style>