提交 1abc4386 作者: ZhangLingKun

功能:租赁问题修复

上级 bc12b1a3
流水线 #8077 已通过 于阶段
in 5 分 34 秒
......@@ -40,3 +40,24 @@ export type QueryCurriculumInfoListType = InterListFunction<
updateTime: string;
}
>;
// 课程详情
export type CourseDetailType = InterFunction<
{ id: string },
{
id: number;
oneCourseId: number;
twoCourseId: number;
curriculumName: string;
curriculumDesc: string;
surfaceUrl: string;
videoUrl: string;
courseAttribute: number;
requireAmout: number;
requireIntegral: number;
isHot: number;
detailContent: null;
createTime: string;
updateTime: string;
buy: boolean;
}
>;
import {
CourseDetailType,
QueryCurriculumInfoListType,
SelectCurriculumClassifyType,
} from '@/api/interface/course';
......@@ -10,6 +11,10 @@ export class CourseAPI {
request.get('/release/curriculum/selectCurriculumClassify', { params });
// 课程列表
static getCourseVideoList: QueryCurriculumInfoListType = (data) =>
request.post('/release/curriculum/queryCurriculumInfoList', data);
static getCourseVideoList: QueryCurriculumInfoListType = (params) =>
request.post('/release/curriculum/queryCurriculumInfoList', params);
// 课程详情
static getCourseDetail: CourseDetailType = (params) =>
request.get('/release/curriculum/curriculumDetails', { params });
}
......@@ -65,7 +65,11 @@ const BreadcrumbView: React.FC = () => {
},
{ name: '执照培训', path: 'train' },
{ name: '飞手约单', path: 'flyer' },
{ name: '执照培训', path: 'course' },
{
name: '执照培训',
path: 'course',
children: [{ name: '课程详情', path: 'detail' }],
},
];
// 转换路由
const getCurrentRouter = () => {
......
......@@ -79,12 +79,14 @@ const CategorySelectView: React.FC<{
// 组件挂载
useEffect(() => {
if (!list?.length) return;
const main = router?.query?.main;
const second = router?.query?.second;
// 一级分类id
const mainID = Number(router?.query?.main);
// 二级分类id
const secondID = Number(router?.query?.second);
// 如果路由里面有一级分类id,则初始化一级分类
if (mainID) {
if (mainID && main) {
const index = list?.findIndex((i) => i?.value === mainID) || 0;
setCurrentIndex(index);
onMain?.(list[index]?.value);
......@@ -92,7 +94,7 @@ const CategorySelectView: React.FC<{
onSecond?.(list[index]?.children?.map((i) => i?.value) || []);
}
// 如果路由里面有二级分类id,则初始化二级分类
if (secondID) {
if (secondID && second) {
const children = list?.find((i) => i?.value === mainID)?.children;
const index = children?.findIndex((i) => i?.value === secondID) || 0;
setSecondIndex([index]);
......
import React from 'react';
import { useRouter } from 'next/router';
import styled from 'styled-components';
import { InterListType } from '@/api/interface';
import { QueryCurriculumInfoListType } from '@/api/interface/course';
......@@ -13,12 +14,18 @@ const courseAttributeList: { label: string; value: number; color: string }[] = [
];
const CourseListItem: React.FC<{ detail: DetailType }> = ({ detail }) => {
// 路由钩子
const router = useRouter();
// 获取当前课程属性
const getCourseAttribute = () => {
return courseAttributeList.find((i) => i.value === detail?.courseAttribute);
};
// 跳转商品详情
const handleDetail = () => {
router.push(`/course/detail/${detail?.id}`).then();
};
return (
<CourseListItemWrap>
<CourseListItemWrap onClick={handleDetail}>
<div className="mb-2 h-32 w-full">
<img
className="h-full w-full object-cover"
......
......@@ -20,6 +20,7 @@ const MapContainer: FC<{
lat: any;
name: string;
}) => {
// console.log('执行到此处 ===>', AmapRef);
if (!AmapRef) return;
const icons = new AmapRef.Icon({
size: new AmapRef.Size(60, 60), // 图标尺寸
......@@ -37,10 +38,15 @@ const MapContainer: FC<{
};
// 设置地图点事件
const handleMarkerSet = () => {
const markers = list.map((i) => addMarkerEntry(i));
map?.add(markers);
// 自适应显示多个点位
map?.setFitView();
try {
const markers = list.map((i) => addMarkerEntry(i));
map?.add(markers);
// 自适应显示多个点位
map?.setFitView();
} catch (e) {
// eslint-disable-next-line no-console
// console.log('地图加载失败 ===>', e, AmapRef);
}
};
// 组件挂载
useEffect(() => {
......@@ -50,45 +56,55 @@ const MapContainer: FC<{
key: '87b424e68754efc3ba9d11ae07475091', // 申请好的Web端开发者Key,首次调用 load 时必填
version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: [], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
}).then((AMap) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
AmapRef = AMap;
// setAmapRef(AMap);
// eslint-disable-next-line react-hooks/exhaustive-deps
map = new AMap.Map('container', {
// 设置地图容器id
viewMode: '3D', // 是否为3D地图模式
zoom: 10, // 初始化地图级别
center: center || [119.96043, 30.04885], // 初始化地图中心点位置
});
// 用户定位
map.plugin('AMap.Geolocation', () => {
const geolocation = new AMap.Geolocation({
enableHighAccuracy: true, // 是否使用高精度定位,默认:true
timeout: 10000, // 超过10秒后停止定位,默认:5s
position: 'RB', // 定位按钮的停靠位置
offset: [10, 55], // 定位按钮与设置的停靠位置的偏移量,默认:[10, 20]
zoomToAccuracy: true, // 定位成功后是否自动调整地图视野到定位点
})
.then((AMap) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
AmapRef = AMap;
// setAmapRef(AMap);
// eslint-disable-next-line react-hooks/exhaustive-deps
map = new AMap.Map('container', {
// 设置地图容器id
viewMode: '3D', // 是否为3D地图模式
zoom: 10, // 初始化地图级别
center: center || [119.96043, 30.04885], // 初始化地图中心点位置
});
// 用户定位
map.plugin('AMap.Geolocation', () => {
const geolocation = new AMap.Geolocation({
enableHighAccuracy: true, // 是否使用高精度定位,默认:true
timeout: 10000, // 超过10秒后停止定位,默认:5s
position: 'RB', // 定位按钮的停靠位置
offset: [10, 55], // 定位按钮与设置的停靠位置的偏移量,默认:[10, 20]
zoomToAccuracy: true, // 定位成功后是否自动调整地图视野到定位点
});
map.addControl(geolocation);
// geolocation.getCurrentPosition((status: string, result: any) => {
// console.log(result);
// if (status == 'complete') {
// onComplete(result);
// } else {
// onError(result);
// }
// });
});
map.addControl(geolocation);
// geolocation.getCurrentPosition((status: string, result: any) => {
// console.log(result);
// if (status == 'complete') {
// onComplete(result);
// } else {
// onError(result);
// }
// });
// 如果列表没有数据则停止执行
if (!list.length) return;
// 设置地图点
handleMarkerSet();
})
.catch((e) => {
// eslint-disable-next-line no-console
console.log('地图加载失败 ===>', e);
});
// 如果列表没有数据则停止执行
if (!list.length) return;
// 设置地图点
handleMarkerSet();
});
});
}
return () => {
map?.destroy();
try {
map?.destroy();
} catch (e) {
// eslint-disable-next-line no-console
console.log('地图销毁失败 ===>', e);
}
};
}, [list, center]);
return (
......
......@@ -14,16 +14,6 @@ import HomeTitleView from '@/components/home-comp/home-title';
import { HomeWrap } from '@/pages/home/styled';
const HomeView = () => {
// 路由钩子
// const router = useRouter();
// 消息提醒
// const handleClick = async () => {
// await message.success('你好');
// };
// 跳转测试
// const handleNavigate = async () => {
// await router.push('/mall');
// };
return (
<HomeWrap>
{/* 主页搜索 */}
......
import React, { useEffect, useState } from 'react';
import { EnvironmentOutlined } from '@ant-design/icons';
import { message } from 'antd';
import Big from 'big.js';
import dayjs from 'dayjs';
import { useRouter } from 'next/router';
import { useDispatch, useSelector } from 'react-redux';
......@@ -57,43 +56,43 @@ const RentHeadView: React.FC<{ detail: DetailType }> = ({ detail }) => {
};
// 获取当前最便宜的规格,然后选中
const getLowerSpec = () => {
const item = detail?.priceStock
?.sort((a, b) => a.salePrice - b.salePrice)
?.at(0)?.productSpec;
const arr = Object.entries(JSON.parse(item || '{}'))?.map((i) => {
const index = detail?.specAttrList?.findIndex((k) => k.specName === i[0]);
return {
row: index,
index: detail?.specAttrList?.[index]?.specValuesList?.findIndex(
(k) => k.specName === i[1],
),
};
});
setSelectSpecList(arr || []);
// const item = detail?.priceStock
// ?.sort((a, b) => a.salePrice - b.salePrice)
// ?.at(0)?.productSpec;
// const arr = Object.entries(JSON.parse(item || '{}'))?.map((i) => {
// const index = detail?.specAttrList?.findIndex((k) => k.specName === i[0]);
// return {
// row: index,
// index: detail?.specAttrList?.[index]?.specValuesList?.findIndex(
// (k) => k.specName === i[1],
// ),
// };
// });
// setSelectSpecList(arr || []);
};
// 获取规格中最低的价格
const getLowerPrice = () => {
return detail?.priceStock?.sort((a, b) => a.salePrice - b.salePrice)?.at(0)
?.salePrice;
// return detail?.priceStock?.sort((a, b) => a.salePrice - b.salePrice)?.at(0)
// ?.salePrice;
};
// 获取当前规格的价格
const getSpecPrice = () => {
let price = 0;
if (selectSpecList?.length !== detail?.specAttrList?.length) {
price = getLowerPrice() || 0;
} else {
const item = selectSpecList?.map((i) => {
const row = detail?.specAttrList?.[i.row];
const index = row?.specValuesList?.[i.index];
return [row?.specName, index?.specName];
});
price =
detail?.priceStock?.find(
(i) => i.productSpec === JSON.stringify(Object.fromEntries(item)),
)?.salePrice || 0;
}
const money = Big(price).mul(Big(productNum)).toNumber().toLocaleString();
return money.endsWith('.00') ? money : `${money}.00`;
// let price = 0;
// if (selectSpecList?.length !== detail?.specAttrList?.length) {
// price = getLowerPrice() || 0;
// } else {
// const item = selectSpecList?.map((i) => {
// const row = detail?.specAttrList?.[i.row];
// const index = row?.specValuesList?.[i.index];
// return [row?.specName, index?.specName];
// });
// price =
// detail?.priceStock?.find(
// (i) => i.productSpec === JSON.stringify(Object.fromEntries(item)),
// )?.salePrice || 0;
// }
// const money = Big(price).mul(Big(productNum)).toNumber().toLocaleString();
// return money.endsWith('.00') ? money : `${money}.00`;
};
// 获取选中规格列表的补充数据
const getSelectPriceStock = () => {
......@@ -159,18 +158,18 @@ const RentHeadView: React.FC<{ detail: DetailType }> = ({ detail }) => {
</div>
<div className="product-content">
<div className="content-title">{detail?.tradeName}</div>
<div className="content-desc">{detail?.description}</div>
{/* <div className="content-desc">{detail?.deviceModeName}</div> */}
<div className="content-price flex-start">
<div className="price-label">价格</div>
<div className="price-money">
{detail?.priceShow ? (
<>
<span className="label">¥</span>
<span className="num">{getSpecPrice()}</span>
</>
) : (
<span className="label">咨询报价</span>
)}
{/* {detail?.priceShow ? ( */}
{/* <> */}
{/* <span className="label">¥</span> */}
{/* <span className="num">{getSpecPrice()}</span> */}
{/* </> */}
{/* ) : ( */}
{/* <span className="label">咨询报价</span> */}
{/* )} */}
</div>
</div>
<div className="content-item flex-start align-start">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论