feat:下单页面

This commit is contained in:
dzc committed 2025-01-09 09:21:52 +08:00
1 parent d5b4fcc18e
commit 4f75a10dbf
7 files changed
+95 -97

No files matched your search

+2 -2
View File
@@ -22,8 +22,8 @@ VITE_IMAGE_BASE_PATH = http://localhost:9999
# ******************** start 开发环境 start ********************
# VITE_APP_DEV_SERVICE =http://123.156.228.134:48080/app-api
# VITE_APP_DEV_SERVICE = https://stgl.pj.gov.cn/app-api
VITE_APP_DEV_SERVICE = http://192.168.101.29:9999 # 邓-本地
# VITE_APP_DEV_SERVICE = http://localhost:9999
# VITE_APP_DEV_SERVICE = http://192.168.101.29:9999 # 邓-本地
VITE_APP_DEV_SERVICE = http://localhost:9999
# ******************** end 开发环境 end ********************
# ******************** start 生产环境 start ********************
@@ -8,6 +8,8 @@ import { merchantApi } from "@@/api"
import ProductRow from './product-row.vue'
import ProductTotal from './product-total.vue'
import { filePath } from "@@/utils/file";
const emit = defineEmits(["update:modelValue", "submit", "doContainer", "add", "remove"])
export type Props = {
@@ -57,7 +59,7 @@ const getHeight = () => {
<template>
<tm-drawer z-index="100" v-model:show="props.modelValue" showFooter title="购物车" position="bottom" size="60%"
@close="doClose">
<product-row v-for="(v, i) in props.carList" mode="car" :key="v.id" v-model="v.productCount" :pic="v.productPic"
<product-row v-for="(v, i) in props.carList" mode="car" :key="v.id" v-model="v.productCount" :pic="filePath(v.productPic)"
:count="v.productCount" :name="v.name" :price="v.productPrice" :marketPrice="v.marketPrice"
:salesCount="v.salesCount" :stock="v.stock" @add="() => emit('add', v)" @remove="emit('remove', v)" />
<template #footer>
+13 -32
View File
@@ -50,12 +50,14 @@ const getShopCar = async () => {
const _pa = { merchantId: state.detailId };
const { data } = await foodApi.getShopCar(_pa);
state.carList = data ?? [];
asyncCarCount(state.shopList)
state.totPrice = state.carList
.map((v) => v.totalPrice)
.map((v) => Number(v.totalPrice))
.reduce((pre, next) => pre + next, 0);
state.totCount = state.carList
.map((v) => v.productCount)
.reduce((pre, next) => pre + next, 0);
};
const getClassify = async () => {
@@ -91,40 +93,26 @@ const getPorduct = async () => {
categoryId: target.id,
};
const { data } = await foodApi.product(_pa);
state.shopList = data;
state.shopList.forEach((i) => {
if (i && i.foodSPURespVOList && i.foodSPURespVOList.length) {
i.foodSPURespVOList.forEach((j) => {
j.productCount = 0;
j.productId = j.id;
});
}
data.forEach((i: any) => {
i.productCount = 0;
i.productId = i.id;
});
const shopList = [...state.shopList];
// if (state.carList && state.carList.length) {
// for (const i of shopList) {
// if (i && i.foodSPURespVOList && i.foodSPURespVOList.length) {
// for (const j of i.foodSPURespVOList) {
// for (const v of state.carList) {
// if (j.id == v.productId) {
// j.productCount = v.productCount;
// }
// }
// }
// }
// }
// }
asyncCarCount(data)
};
// 同步购买数量
const asyncCarCount = (shopList)=>{
if (state.carList && state.carList.length) {
for (const i of shopList) {
for (const v of state.carList) {
if (i.id == v.productId) {
i.productCount = v.productCount;
i.productCount = v.productCount;
}
}
}
}
state.shopList = shopList;
};
}
const doAdd = async (item: any) => {
chentProductCount(item);
@@ -331,13 +319,6 @@ const doFood = () => {
class="flex-1 p-b-20rpx"
>
<view v-for="(pV, pI) in state.shopList" :key="pI">
<!-- <view class="flex-row-center m-y-20rpx">
<view class="w-25rpx h-1px bg-#d2d2d2" />
<text class="p-x-15rpx second-text-28">
{{ cV.categoryName }}
</text>
<view class="w-25rpx h-1px bg-#d2d2d2" />
</view> -->
<view class="m-x-15rpx">
<product-row
:key="pV.id"
+3 -3
View File
@@ -42,7 +42,7 @@ onShow(() => {
})
const pageRef = ref<any>(null)
const pageHook = hooks.usePage(pageRef, foodApi.page, null, 'data.list')
const pageHook = hooks.usePage(pageRef, foodApi.page, null, 'data.records')
const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.pa);
}
@@ -60,13 +60,13 @@ const initDate = () => {
})
}
state.dateList = list
state.pa.day = state.dateList[0].dateTime
state.pa.startTime = state.dateList[0].dateTime
pageRef.value?.reload(false)
}
const doDateItem = (v: any, i: any) => {
state.currentDateIndex = i
state.pa.day = state.dateList[i].dateTime
state.pa.startTime = state.dateList[i].dateTime
pageRef.value.reload(true)
}
+65 -54
View File
@@ -1,76 +1,87 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { isEmpty } from 'radash'
import { isEmpty } from "radash";
import { hooks } from "@@/index"
import { productApi } from "@@/api"
import { hooks } from "@@/index";
import { productApi } from "@@/api";
import zSwiper from "@zebra-ui/swiper/components/z-swiper/z-swiper.vue"
import zSwiperItem from "@zebra-ui/swiper/components/z-swiper-item/z-swiper-item.vue"
import { filePath } from "@@/utils/file";
const data = {
}
import zSwiper from "@zebra-ui/swiper/components/z-swiper/z-swiper.vue";
import zSwiperItem from "@zebra-ui/swiper/components/z-swiper-item/z-swiper-item.vue";
const data = {};
const state = reactive<any>({
detailId: null,
detail: null,
})
detailId: null,
detail: null,
});
onLoad((options: any) => {
if (!isEmpty(options.id)) {
state.detailId = options.id
}
if (!isEmpty(options.id)) {
state.detailId = options.id;
}
});
onShow(() => {
getDetail()
})
getDetail();
});
const getDetail = async () => {
const _pa = { id: state.detailId }
const { data } = await productApi.get(_pa)
state.detail = data
}
const _pa = { id: state.detailId };
const { data } = await productApi.get(_pa);
state.detail = data;
};
</script>
<template>
<crud-layout title="订单详情" tabBarType="just-flot-back" bg="/static/page/blue-bg.png">
<z-swiper>
<z-swiper-item v-for="(v, i) in state.detail.sliderPicUrls" :key="i">
<image class="w-100vw" :src="v" mode="widthFix" />
</z-swiper-item>
</z-swiper>
<view class="p-x-15rpx">
<view class="flex-col justify-between card p-y-20rpx p-x-30rpx">
<view class="flex-row items-center justify-between">
<view class="flex-row items-center">
<view class="second-text-46 color-#f63a36!">¥{{ state.detail.price }}</view>
<view class="m-l-20rpx second-text-28 line-through">¥{{ state.detail.marketPrice }}</view>
</view>
<view class="second-text-26">已售{{ state.detail.salesCount }}</view>
</view>
<view class="flex-col m-t-15rpx">
<view class="sub-text-32">{{ state.detail.name }}</view>
<view class="m-t-15rpx second-text-26">{{ state.detail.introduction }}</view>
</view>
</view>
<view class="h-15rpx" />
<view class="flex-row items-center justify-between card p-y-20rpx p-x-30rpx">
<view class="prefix_title">评价</view>
</view>
<view class="h-15rpx" />
<view class="flex-col justify-between card p-y-20rpx p-x-30rpx">
<view class="prefix_title">详情</view>
<view class="m-t-15rpx" v-html="state.detail.description"></view>
</view>
<crud-layout
title="订单详情"
tabBarType="just-flot-back"
bg="/static/page/blue-bg.png"
>
<image
class="w-100vw"
:src="filePath(state.detail.picUrl)"
mode="widthFix"
/>
<view class="p-x-15rpx">
<view class="flex-col justify-between card p-y-20rpx p-x-30rpx">
<view class="flex-row items-center justify-between">
<view class="flex-row items-center">
<view class="second-text-46 color-#f63a36!"
>¥{{ state.detail.price }}</view
>
<view class="m-l-20rpx second-text-28 line-through"
>¥{{ state.detail.marketPrice }}</view
>
</view>
<view class="second-text-26">已售{{ state.detail.salesCount }}</view>
</view>
</crud-layout>
<view class="flex-col m-t-15rpx">
<view class="sub-text-32">{{ state.detail.name }}</view>
<view class="m-t-15rpx second-text-26">{{
state.detail.introduction
}}</view>
</view>
</view>
<view
v-if="false"
class="m-t-15rpx flex-row items-center justify-between card p-y-20rpx p-x-30rpx"
>
<view class="prefix_title">评价</view>
</view>
<view v-if="state.detail.description" class="m-t-15rpx flex-col justify-between card p-y-20rpx p-x-30rpx">
<view class="prefix_title">详情</view>
<view class="m-t-15rpx" v-html="state.detail.description"></view>
</view>
</view>
</crud-layout>
</template>
<style lang="scss" scoped>
:deep() {
.layout_main>scroll-view {
padding: 0 !important;
}
.layout_main > scroll-view {
padding: 0 !important;
}
}
</style>
</style>
+8 -4
View File
@@ -1,11 +1,15 @@
import request from "@/sheep/utils/request";
export default {
page: (params: any) =>
page: (data: any) =>
request({
url: `/canteen/canteenDailyMenu/ad/getCanteenList`,
method: "GET",
params,
url: `/canteen/canteenDailyMenu/app/page`,
method: "POST",
data,
params:{
pageNo: data.pageNo,
pagesize: data.pagesize
},
custom: {
showLoading: false,
},
+1 -1
View File
@@ -3,7 +3,7 @@ import request from "@/sheep/utils/request";
export default {
get: (params) => {
return request({
url: "/onlinefood/spu/get-detail",
url: "/canteen/canteenOnlineSpu/app/getCanteenSpuDetails",
method: "GET",
params,
});