From ef77d23cec1f4e91f243774c64126911304b3adc Mon Sep 17 00:00:00 2001 From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com> Date: Fri, 20 Dec 2024 16:38:30 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E8=A1=A8=E5=8D=95=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 24 +--- src/pages/demand-release/index.vue | 128 ++++++++++++++---- .../components/details-model.vue | 4 +- src/pages/goods-list/index.vue | 7 +- src/pages/index/index.vue | 37 +++-- src/pages/lease-demand/index.vue | 27 ++-- src/pages/order/index.vue | 123 ++++++++++++++--- src/services/index/index.js | 9 ++ 8 files changed, 270 insertions(+), 89 deletions(-) diff --git a/src/App.vue b/src/App.vue index ba992b8..5ff0b26 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,30 +1,10 @@ diff --git a/src/pages/goods-details/components/details-model.vue b/src/pages/goods-details/components/details-model.vue index a80f0ce..59dc7c8 100644 --- a/src/pages/goods-details/components/details-model.vue +++ b/src/pages/goods-details/components/details-model.vue @@ -66,7 +66,7 @@ type="danger" text="立即租用" @click="onRentNow" - :disabled="deviceInfo.isBookCar == 0 || userCompanyId == deviceInfo.companyId" + :disabled="userCompanyId == deviceInfo.companyId" /> @@ -111,6 +111,7 @@ const getDeviceDetailsData = async () => { } // 获取预约车数量 const getBookCarDetailsData = async () => { + cartCount.value = 0 const { data: res } = await getBookCarDetailsAPI() if (res.length > 0) { res.forEach((e) => { @@ -136,6 +137,7 @@ const onAddCart = () => { if (res.code === 200) { showSuccessToast('加入成功') getDeviceDetailsData() + getBookCarDetailsData() } }) .catch(() => {}) diff --git a/src/pages/goods-list/index.vue b/src/pages/goods-list/index.vue index c1a31d5..4423cbc 100644 --- a/src/pages/goods-list/index.vue +++ b/src/pages/goods-list/index.vue @@ -1,7 +1,8 @@ @@ -117,20 +136,24 @@ import { computed, ref } from 'vue' import { onLoad } from '@dcloudio/uni-app' import { useMemberStore } from '@/stores/index.js' import { getDeviceDetailsAPI } from '@/services/goods/index.js' +import { getAddressListAPI, submitBookCarAPI } from '@/services/cart/index.js' import moment from 'moment' const memberStore = useMemberStore() const checked = ref(['1']) const orderList = ref([]) const showBottom = ref(false) -const minDate = new Date(2024, 0, 1) +const showBottomAddress = ref(false) +const minDate = new Date(moment().format('YYYY'), moment().format('MM') - 1, moment().format('DD')) +const maxDate = new Date(moment().format('YYYY') * 1 + 100, 12, 31) const timeType = ref(0) const leaseTime = ref() -const startTime = ref() -const endTime = ref() +const address = ref('') +const chosenAddressId = ref() +const addressList = ref([]) const onClickLeft = () => { uni.navigateBack() } -const onSubmitOrder = () => { +const onSubmitOrder = async () => { orderList.value.forEach((e) => { if (e.days < 1) { showFailToast('请选择租期') @@ -140,7 +163,39 @@ const onSubmitOrder = () => { showFailToast('请先阅读公司协议') return } + + if (address.value.length == 0) { + showFailToast('请选择收货地址') + return + } }) + + const orderInfo = orderList.value[0] + const submitInfo = { + maId: orderInfo.maId, + id: orderInfo.id, + rentBeginTime: orderInfo.rentBeginTime + ' ' + '00:00:00', + rentEndTime: orderInfo.rentEndTime + ' ' + '00:00:00', + manageType: orderInfo.manageType, + days: orderInfo.days, + num: orderInfo.num, + costs: orderInfo.num * orderInfo.days * orderInfo.dayLeasePrice, + } + + const submitParams = { + cost: submitInfo.costs, + address: address.value, + detailsList: [submitInfo], + } + const res = await submitBookCarAPI([submitParams]) + if (res.code === 200) { + showSuccessToast('提交成功') + setTimeout(() => { + uni.navigateTo({ + url: '/pages/goods-list/index', + }) + }, 500) + } } const onViewProtocol = () => {} const onSelectTime = (type) => { @@ -149,11 +204,20 @@ const onSelectTime = (type) => { } const onConfirm = () => { if (timeType.value === 1) { - startTime.value = leaseTime.value.join('-') + orderList.value[0].rentBeginTime = leaseTime.value.join('-') } else { - endTime.value = leaseTime.value.join('-') - orderList.value[0].days = moment(endTime.value).diff(startTime.value, 'day') + if (moment(leaseTime.value.join('-')).isBefore(moment(orderList.value[0].rentBeginTime))) { + showFailToast('租赁结束日期不能小于租赁开始日期') + return + } else { + orderList.value[0].rentEndTime = leaseTime.value.join('-') + orderList.value[0].days = moment(leaseTime.value.join('-')).diff( + orderList.value[0].rentBeginTime, + 'day', + ) + } } + leaseTime.value = [] showBottom.value = false } const onCancel = () => { @@ -177,8 +241,32 @@ const totalPrice = computed(() => { return item?.num * item?.dayLeasePrice * item?.days * 100 }) +// 获取地址 +const getAddressListData = async () => { + const { rows: res } = await getAddressListAPI() + addressList.value = res.map((e, index) => { + return { + id: index, + name: '', + tel: '', + address: `${e.provinceName}${e.cityName}${e.areaName}${e.address}`, + isDefault: false, + } + }) +} + +// 选择地址 +const onClickLink = () => { + showBottomAddress.value = true +} +const onClickAddress = (res) => { + address.value = res.address + showBottomAddress.value = false +} + onLoad((options) => { getDeviceDetailsData(options.id) + getAddressListData() }) @@ -247,7 +335,7 @@ onLoad((options) => { font-size: 12px; view { - padding: 1px 0 1px 10px; + padding: 2px 0 2px 10px; font-size: 12px; color: #6f6f6f; @@ -267,4 +355,7 @@ onLoad((options) => { font-size: 13px; color: #1989fa; } +:deep(.van-address-item__edit) { + display: none; +} diff --git a/src/services/index/index.js b/src/services/index/index.js index 06c7026..5f4fd61 100644 --- a/src/services/index/index.js +++ b/src/services/index/index.js @@ -10,3 +10,12 @@ export const getDeviceListAPI = (data) => { data, }) } +/** + * 首页 获取订单数量 + */ +export const getOrderStatusCountAPI = (data) => { + return http({ + method: 'GET', + url: '/material-mall/order/getOrderStatusCount', + }) +}