线上超市修改
This commit is contained in:
1 parent
4540d547bb
commit
f7cce3e5bc
4 files changed
+53
-45
No files matched your search
@@ -48,7 +48,6 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue"
|
||||
import { onShow } from "@dcloudio/uni-app"
|
||||
import { router } from "@@/index"
|
||||
import { usePayStore } from "@/sheep/stores/pay"
|
||||
|
||||
const payData = ref<{ id?: string; name?: string; customPrice?: number }>({})
|
||||
@@ -61,6 +60,5 @@ onShow(() => {
|
||||
const goBack = () => {
|
||||
const url: string = window.location.href.split("h5")[0] + "h5/?launchParam=coopMerchant#/pages/tabbar/order"
|
||||
window.location.replace(url)
|
||||
// router.jump(url, {}, 2)
|
||||
}
|
||||
</script>
|
||||
@@ -26,9 +26,9 @@
|
||||
<view class="text-32 ws-nowrap text-ellipsis overflow-hidden">{{ state.goodsDetail.productName }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="second-text-30 c-red!">
|
||||
促销 ¥{{ hooks.useMoney(state.selectedSku.promotionPrice) || hooks.useMoney(state.selectedSku.retailPrice) || 0 }}
|
||||
促销 ¥ {{ state.selectedSku.promotionPrice.toFixed(2) || state.selectedSku.retailPrice.toFixed(2) || 0 }}
|
||||
</view>
|
||||
<view class="m-l-20rpx second-text-28 line-through">原价 ¥{{ hooks.useMoney(state.selectedSku.retailPrice) || 0 }}</view>
|
||||
<view class="m-l-20rpx second-text-28 line-through">原价 ¥ {{ state.selectedSku.retailPrice.toFixed(2) || 0 }}</view>
|
||||
</view>
|
||||
<view class="second-text-26">库存:{{ state.selectedSku.stock || 0 }}</view>
|
||||
<view class="second-text-26">
|
||||
@@ -57,13 +57,16 @@
|
||||
<!-- 购买数量 -->
|
||||
<view class="flex-col card p-y-20rpx p-x-30rpx mb-20rpx">
|
||||
<view class="prefix_title mb-15rpx">购买数量</view>
|
||||
<view class="flex-row items-center justify-end">
|
||||
<view class="flex-row-center size-40rpx rounded-full border-1px border-solid border-color-#0094ff" @tap.stop="handleNumRemove">
|
||||
<view class="iconfont icon-a--" />
|
||||
</view>
|
||||
<view class="sub-text-28 m-x-20rpx">{{ String(state.goodsCount).padStart(2, "0") }}</view>
|
||||
<view class="flex-row-center size-40rpx rounded-full bg-#0094ff" @tap.stop="handleNumAdd">
|
||||
<view class="font-size-40rpx color-white iconfont icon-a-" />
|
||||
<view class="flex items-center justify-between">
|
||||
<view class="second-text-28">限购:{{ state.goodsDetail.limitNum }}</view>
|
||||
<view class="flex">
|
||||
<view class="flex-row-center size-40rpx rounded-full border-1px border-solid border-color-#0094ff" @tap.stop="handleNumRemove">
|
||||
<view class="iconfont icon-a--" />
|
||||
</view>
|
||||
<view class="sub-text-28 m-x-20rpx">{{ String(state.goodsCount).padStart(2, "0") }}</view>
|
||||
<view class="flex-row-center size-40rpx rounded-full bg-#0094ff" @tap.stop="handleNumAdd">
|
||||
<view class="font-size-40rpx color-white iconfont icon-a-" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -82,12 +85,10 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { shopApi } from "@/sheep/api"
|
||||
import { filePath } from "@/sheep/utils/file"
|
||||
import { reactive, watch } from "vue"
|
||||
import { usePreviewImage } from "@/sheep/hooks/use-img"
|
||||
import { isEmpty } from "radash"
|
||||
import { hooks } from "@/sheep"
|
||||
|
||||
const emit = defineEmits(["update:modelValue", "onSkuAddToCart"])
|
||||
|
||||
@@ -116,12 +117,6 @@ watch(
|
||||
() => props.modelValue,
|
||||
async (newValue) => {
|
||||
if (newValue) {
|
||||
// 获取商品详情
|
||||
// const { data } = await shopApi.getSupermarketSpuDetail({ id: props.productData.id })
|
||||
// state.goodsDetail = data
|
||||
// if (data.skuList.length > 0) {
|
||||
// state.selectedSku = state.goodsDetail.skuList[0]
|
||||
// }
|
||||
state.goodsDetail = props.productData
|
||||
if (!isEmpty(state.goodsDetail)) {
|
||||
state.selectedSku = state.goodsDetail.skuList[0]
|
||||
@@ -141,6 +136,7 @@ const onSelectSku = (skuItem: any) => {
|
||||
|
||||
// 加数量
|
||||
const handleNumAdd = () => {
|
||||
if (state.goodsCount >= state.goodsDetail.limitNum) return
|
||||
if (state.goodsCount >= state.goodsDetail.stock) return uni.showToast({ title: "库存不足", icon: "none" })
|
||||
state.goodsCount += 1
|
||||
}
|
||||
|
||||
@@ -68,40 +68,52 @@ const doCart = async () => {
|
||||
<view class="p-15rpx">
|
||||
<view class="flex-col justify-between card p-y-20rpx p-x-30rpx">
|
||||
<view class="prefix_title mb-15rpx">商品</view>
|
||||
<view class="sub-text-32">{{ state.detail?.productName }}</view>
|
||||
<view class="flex-row items-center justify-between m-t-15rpx">
|
||||
<view class="second-text-26">限购:{{ state.detail?.limitNum || 0 }}</view>
|
||||
<view class="second-text-26">已售:{{ state.detail?.salesCount || 0 }}</view>
|
||||
<view class="px-3">{{ state.detail?.productName }}</view>
|
||||
<view class="flex-row items-center justify-between m-t-15rpx px-3">
|
||||
<view class="second-text-26">限购:{{ state.detail?.limitNum || 0 }}</view>
|
||||
<view class="second-text-26">已售:{{ state.detail?.salesCount || 0 }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="h-15rpx" />
|
||||
<view class="flex-col justify-between card p-y-20rpx p-x-30rpx">
|
||||
<view class="prefix_title mb-15rpx">包装</view>
|
||||
<view class="flex flex-wrap">
|
||||
<view class="w-1/3 flex justify-center p-1" v-for="(item, index) in state.detail?.skuList" :key="index">
|
||||
<view class="p-2 w-full bg-#eeeeee77 rounded-3 flex-col items-center">
|
||||
<view class="second-text-28">{{ item.spec + " / " + item.unit }}</view>
|
||||
<view class="second-text-28">库存:{{ item?.stock || 0 }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="second-text-28 c-red!">
|
||||
¥{{ hooks.useMoney(item.promotionPrice) || hooks.useMoney(item.retailPrice) || 0 }}
|
||||
</view>
|
||||
<view class="ml-4rpx second-text-28 line-through">¥{{ hooks.useMoney(item.retailPrice) || 0 }}</view>
|
||||
<view class="flex flex-wrap px-2">
|
||||
<view class="w-1/2 flex justify-center p-1" v-for="(item, index) in state.detail?.skuList" :key="index">
|
||||
<view class="p-2 w-full bg-#eeeeee77 rounded-2 flex-col second-text-28">
|
||||
<view class="flex justify-between mt-1">
|
||||
<text>单位:</text>
|
||||
<text>{{ item.spec + " / " + item.unit }}</text>
|
||||
</view>
|
||||
<view class="flex justify-between mt-1">
|
||||
<text>口味:</text>
|
||||
<text>{{ item?.attribute || "无" }}</text>
|
||||
</view>
|
||||
<view class="flex justify-between mt-1">
|
||||
<text>库存:</text>
|
||||
<text>{{ item?.stock || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex justify-between mt-1">
|
||||
<text>原价:</text>
|
||||
<text class="line-through">¥ {{ item.retailPrice.toFixed(2) || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex justify-between mt-1">
|
||||
<text>促销:</text>
|
||||
<text class="c-red!">¥ {{ item.promotionPrice.toFixed(2) || item.retailPrice.toFixed(2) || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="h-15rpx" />
|
||||
<!-- <view class="h-15rpx" />
|
||||
<view class="flex-col justify-between card p-y-20rpx p-x-30rpx">
|
||||
<view class="prefix_title mb-15rpx">评价</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="h-15rpx" />
|
||||
<view class="flex-col justify-between card p-y-20rpx p-x-30rpx">
|
||||
<view class="prefix_title mb-15rpx">详情</view>
|
||||
<view class="m-t-15rpx" v-html="state.detail?.description"></view>
|
||||
<view class="second-text-28 px-3" v-html="state.detail?.description"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<view class="w-full flex items-center">
|
||||
<tm-input
|
||||
class="flex-1"
|
||||
v-model="state.params.productName"
|
||||
v-model="state.params.keyword"
|
||||
type="text"
|
||||
:height="66"
|
||||
:minHeight="66"
|
||||
@@ -85,14 +85,12 @@
|
||||
<view class="sub-text-32 show-line">{{ item.productName }}</view>
|
||||
<view class="flex-row justify-between items-center">
|
||||
<view class="flex items-center">
|
||||
<view class="second-text-32 c-red!">
|
||||
¥{{ parseFloat(item.promotionPrice) != 0 ? hooks.useMoney(item.promotionPrice) : hooks.useMoney(item.retailPrice) }}
|
||||
</view>
|
||||
<view v-if="parseFloat(item.promotionPrice) != 0" class="ml-10rpx second-text-30 line-through">
|
||||
<view class="second-text-32 c-red!">¥ {{ storePrice(item.minPrice).toFixed(2) }}</view>
|
||||
<!-- <view v-if="parseFloat(item.promotionPrice) != 0" class="ml-10rpx second-text-30 line-through">
|
||||
¥{{ hooks.useMoney(item.retailPrice) || 0 }}
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="second-text-26">已售:{{ item.salesCount || 0 }}</view>
|
||||
<view class="second-text-26">已售:{{ item.salesCount || 0 }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -153,6 +151,7 @@ import { filePath } from "@@/utils/file"
|
||||
import { merchantApi, onlineShopApi } from "@@/api"
|
||||
import { hooks, router } from "@@/index"
|
||||
import { useCartStore } from "@/sheep/stores/cart"
|
||||
import { storePrice } from "@/sheep/utils/formatMoney"
|
||||
|
||||
const cartStore = useCartStore()
|
||||
|
||||
@@ -161,7 +160,7 @@ const state = reactive<any>({
|
||||
merchantId: "",
|
||||
categoryId: "",
|
||||
size: 10,
|
||||
productName: "",
|
||||
keyword: "",
|
||||
},
|
||||
|
||||
merchantList: [],
|
||||
@@ -179,7 +178,6 @@ onLoad(async () => {
|
||||
|
||||
await getAllMerchant()
|
||||
await getClassify()
|
||||
cartStore.saveShopMerchantId(state.curMerchant.id)
|
||||
await cartStore.getShopCart()
|
||||
})
|
||||
|
||||
@@ -196,6 +194,8 @@ const getAllMerchant = async () => {
|
||||
state.merchantList = data.records
|
||||
if (!isEmpty(state.merchantList)) {
|
||||
state.curMerchant = state.merchantList[0]
|
||||
state.params.merchantId = state.curMerchant.id
|
||||
cartStore.saveShopMerchantId(state.curMerchant.id)
|
||||
return
|
||||
}
|
||||
state.curMerchant = {}
|
||||
@@ -240,8 +240,10 @@ const changeShop = () => {
|
||||
const confirmRadioMerchant = async () => {
|
||||
state.curMerchant = state.merchantList.find((item: any) => item.id == state.curMerchantRadioId)
|
||||
state.showDrawer = false
|
||||
state.params.merchantId = state.curMerchant.id
|
||||
cartStore.saveShopMerchantId(state.curMerchant.id)
|
||||
await cartStore.getShopCart()
|
||||
pageRef.value && pageRef.value.reload(true)
|
||||
}
|
||||
|
||||
// 点击搜索
|
||||
|
||||
Reference in new issue
Block a user