diff --git a/MiniProgram/rzyc-weapp-ylt-main/rzyc.code-workspace b/MiniProgram/rzyc-weapp-ylt-main/rzyc.code-workspace index 6bf1fc2..ab87d0e 100644 --- a/MiniProgram/rzyc-weapp-ylt-main/rzyc.code-workspace +++ b/MiniProgram/rzyc-weapp-ylt-main/rzyc.code-workspace @@ -21,6 +21,9 @@ }, "[typescript]": { "editor.defaultFormatter": "vscode.typescript-language-features" + }, + "[scss]": { + "editor.defaultFormatter": "vscode.css-language-features" } } } diff --git a/MiniProgram/rzyc-weapp-ylt-main/src/app.tsx b/MiniProgram/rzyc-weapp-ylt-main/src/app.tsx index 8a2f9f0..5f8ede6 100644 --- a/MiniProgram/rzyc-weapp-ylt-main/src/app.tsx +++ b/MiniProgram/rzyc-weapp-ylt-main/src/app.tsx @@ -111,6 +111,7 @@ class App extends Component { 'pages/labor-union/labor-union', 'pages/labor-union-login/labor-union-login', 'pages/test/test', + 'pages/select-free-plate/select-free-plate', ], subPackages: [ { diff --git a/MiniProgram/rzyc-weapp-ylt-main/src/pages/charging/charging.tsx b/MiniProgram/rzyc-weapp-ylt-main/src/pages/charging/charging.tsx index de13d11..993e6fa 100644 --- a/MiniProgram/rzyc-weapp-ylt-main/src/pages/charging/charging.tsx +++ b/MiniProgram/rzyc-weapp-ylt-main/src/pages/charging/charging.tsx @@ -16,8 +16,9 @@ import { QueryEquipmentStatusRes, stopCharge, getDefaultCar, + isThirdPartyStation, } from '@/services/charging'; -import { showModal } from '@/utils/wechat-ui'; +import { showModal, showModalOnlyWithConfirmBtn } from '@/utils/wechat-ui'; import classNames from 'classnames'; import { contact, @@ -66,9 +67,8 @@ export const Charging: Taro.FC = () => { setRealTimeInfo(res); if (res.orderState !== 2) { Taro.redirectTo({ - url: `/pages/order-detail/order-detail?isFromCharging=${true}&orderNo=${ - router.params.orderNo - }`, + url: `/pages/order-detail/order-detail?isFromCharging=${true}&orderNo=${router.params.orderNo + }`, }); } } @@ -119,11 +119,27 @@ export const Charging: Taro.FC = () => { orderNo: router.params.orderNo, }); if (stopRes) { - Taro.redirectTo({ - url: `/pages/order-detail/order-detail?isFromCharging=${true}&orderNo=${ - router.params.orderNo - }`, + //是否为合作道闸车场,如果是有免费停车时长,跳转到选车界面 + const freeTimeRes = await isThirdPartyStation({ + order_no: router.params.orderNo, }); + + if (freeTimeRes.success) { + const freeRes = await showModalOnlyWithConfirmBtn( + '提示', + '请输入车辆信息领取免费停车时长!' + ); + if (freeRes.confirm) { + Taro.redirectTo({ + url: `/pages/select-free-plate/select-free-plate?order_no=${router.params.orderNo}`, + }); + } + } else { + Taro.redirectTo({ + url: `/pages/order-detail/order-detail?isFromCharging=${true}&orderNo=${router.params.orderNo}`, + }); + } + } } }; diff --git a/MiniProgram/rzyc-weapp-ylt-main/src/pages/index/components/FilterView/FilterView.tsx b/MiniProgram/rzyc-weapp-ylt-main/src/pages/index/components/FilterView/FilterView.tsx index 66086e8..0e4be30 100644 --- a/MiniProgram/rzyc-weapp-ylt-main/src/pages/index/components/FilterView/FilterView.tsx +++ b/MiniProgram/rzyc-weapp-ylt-main/src/pages/index/components/FilterView/FilterView.tsx @@ -169,7 +169,7 @@ export const FilterView: Taro.FC = ({ className="filter__search" hoverClass="btn-hover" onClick={() => onSearch(stationName)}> - 搜索 + 搜索1 diff --git a/MiniProgram/rzyc-weapp-ylt-main/src/pages/index/index.tsx b/MiniProgram/rzyc-weapp-ylt-main/src/pages/index/index.tsx index f3e5f3d..f57424d 100644 --- a/MiniProgram/rzyc-weapp-ylt-main/src/pages/index/index.tsx +++ b/MiniProgram/rzyc-weapp-ylt-main/src/pages/index/index.tsx @@ -59,11 +59,11 @@ export default function Index() { } }; - const handleHuanghai = async () => { - // const res = await huangHaiTest(); + const handleTest = async () => { + // const res = await huangHaiTest(); // console.log(res.data[0].columns.dictValue); - Taro.navigateTo({ url: `/pages/test/test` }); + Taro.redirectTo({ url: `/pages/select-free-plate/select-free-plate?order_no=123456` }); // Taro.navigateTo({ // url: `/pages/labor-union/labor-union`, @@ -197,7 +197,7 @@ export default function Index() { onScrollToLower={handleScrollToLower}> {currentTabElement} */} - {/* */} + {currentTabElement} { + const router = useRouter(); + const [isShowInputModal, setIsShowInputModal] = useState(false); + const [connectorSn, setConnectorSn] = useState(''); + const [selectedCarId, setSelectedCarId] = useState(0); + const [carList, setCarList] = useState([]); + + const validateCarPlate = (plate) => { + const pattern = /^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$/ + return pattern.test(plate); + }; + + const getUserCarList = async () => { + const res = await getUserCar(); + if (res) { + setCarList(res); + } + }; + + useDidShow(() => { + getUserCarList(); + }); + + const handleCloseModal = () => { + setIsShowInputModal(false); + setConnectorSn(''); + }; + + const handleModalSave = () => { + if (connectorSn.length == 0) { + showFailToast('请输入车牌号!'); + return; + } else { + if (validateCarPlate(connectorSn)) { + handleCloseModal(); + syncChargePilePay({ + order_no: router.params.order_no, + charge_plate_no: connectorSn + }); + Taro.redirectTo({ + url: `/pages/order-detail/order-detail?isFromCharging=${true}&orderNo=${router.params.order_no}`, + }); + } else { + showFailToast('车牌号格式不正确!'); + setConnectorSn(''); + return; + } + + } + }; + + const handleSave = () => { + + if (selectedCarId == 0) { + showFailToast('请选择车辆或手工输入车牌号!'); + return; + } else { + syncChargePilePay({ + order_no: router.params.order_no, + charge_plate_no: connectorSn + }); + Taro.redirectTo({ + url: `/pages/order-detail/order-detail?isFromCharging=${true}&orderNo=${router.params.order_no}`, + }); + } + + }; + + const handleInputCode = () => { + setIsShowInputModal(true); + }; + + const selectCar = (item?: GetUserCarRes) => { + setSelectedCarId(item.id); + setConnectorSn(item.plateNo.toString()) + }; + + return ( + + + {carList.length === 0 ? ( + 暂时没有爱车,请手工输入车牌号 + ) : ( + carList.map((item) => { + return ( + selectCar(item)}> + + + + + {item.plateNo} + {item.brandName ? ( + + {item.brandName} + {item.modelName} + + ) : ( + 新能源汽车 + )} + + + {selectedCarId == item.id ? ( + 已选中 + ) : ( + 未选中 + )} + + + {item.productDate && ( + + )} + {item.productDate && ( + {item.productDate} + )} + {item.carMileage && ( + + 续航里程 {item.carMileage}公里 + + )} + + + + ); + }) + )} + + + + + 手工输入车牌号 + + + 确 定 + + + + + + + 手工输入车牌号 + setConnectorSn(e.detail.value)}> + + + 取消 + + + 确定 + + + + + + ); +}; + +SelectFreePlate.config = { + navigationBarTitleText: '选择爱车', +}; diff --git a/MiniProgram/rzyc-weapp-ylt-main/src/services/charging.ts b/MiniProgram/rzyc-weapp-ylt-main/src/services/charging.ts index 5b378b5..9b9a367 100644 --- a/MiniProgram/rzyc-weapp-ylt-main/src/services/charging.ts +++ b/MiniProgram/rzyc-weapp-ylt-main/src/services/charging.ts @@ -52,6 +52,18 @@ export const stopCharge = async (params: StopChargeReq) => { return res; }; + +export type IsThirdPartyStationReq = { + order_no: string; +}; +export const isThirdPartyStation = async (params: IsThirdPartyStationReq) => { + const res = await RzRequest.postNew( + '/ZhuQue/Ylt/isThirdPartyStation', + params + ); + return res; +}; + export const getDefaultCar = async () => { const res = await RzRequest.post( '/userapi/userCar/getDefaultCar' diff --git a/MiniProgram/rzyc-weapp-ylt-main/src/services/my-car.ts b/MiniProgram/rzyc-weapp-ylt-main/src/services/my-car.ts index 0402f97..ff34919 100644 --- a/MiniProgram/rzyc-weapp-ylt-main/src/services/my-car.ts +++ b/MiniProgram/rzyc-weapp-ylt-main/src/services/my-car.ts @@ -80,3 +80,16 @@ export const getUserCar = async () => { ); return res; }; + +export type SyncChargePilePayReq = { + order_no: string; + charge_plate_no: string; +}; +export const syncChargePilePay = async (params: SyncChargePilePayReq) => { + const res = await RzRequest.postNew( + '/ZhuQue/Ylt/SyncChargePilePay', + params + ); + return res; +}; + diff --git a/MiniProgram/rzyc-weapp-ylt-main/src/utils/request-enhance.ts b/MiniProgram/rzyc-weapp-ylt-main/src/utils/request-enhance.ts index 096b542..304fdf6 100644 --- a/MiniProgram/rzyc-weapp-ylt-main/src/utils/request-enhance.ts +++ b/MiniProgram/rzyc-weapp-ylt-main/src/utils/request-enhance.ts @@ -8,7 +8,8 @@ import { getGlobalData, setGlobalData } from './global-data'; // export const BASE_URL = 'https://ylt.ikbvip.com'; //本地 -export const BASE_URL = 'http://10.10.21.20:7001'; +//export const BASE_URL = 'http://10.10.21.20:7001'; +export const BASE_URL = 'http://10.10.14.77:7001'; // export const BASE_URL = 'https://wechatapps.test-ylt.ikbvip.com/';