提交 1abc4386 作者: ZhangLingKun

功能:租赁问题修复

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