提交 f515c921 作者: 龚洪江

功能:加盟入驻

上级 5ad605b3
import config from './config';
let loginTimeout: NodeJS.Timeout | undefined;
......@@ -10,7 +9,12 @@ let loginTimeout: NodeJS.Timeout | undefined;
* @param options 额外参数
* @returns Promise<Response>
*/
export default function request(url: string, method: String = 'get', data?: any, options: any & { hideError?: boolean, headers?: { token?: string } } = {}): Promise<Response<any>> {
export default function request(
url: string,
method: String = 'get',
data?: any,
options: any & { hideError?: boolean; headers?: { token?: string } } = {},
): Promise<Response<any>> {
let token = localStorage.getItem('token') || '';
switch (method.toLowerCase()) {
......@@ -19,7 +23,7 @@ export default function request(url: string, method: String = 'get', data?: any,
if (data) {
Object.keys(data).forEach((key) => {
params.append(key, data[key]);
})
});
url += '?' + params;
}
......@@ -33,16 +37,16 @@ export default function request(url: string, method: String = 'get', data?: any,
},
body: JSON.stringify(data),
...options,
}
};
break;
}
if(options.headers){
if (options.headers) {
options.headers.token = token;
}else{
} else {
options.headers = {
token
}
token,
};
}
/**
......@@ -57,65 +61,65 @@ export default function request(url: string, method: String = 'get', data?: any,
/**
* 未登录消息展示,1.5秒内限制只展示一次
* @returns
* @returns
*/
function loginErrorMsg(){
console.log('loginTimeout', loginTimeout)
if(loginTimeout){
function loginErrorMsg() {
console.log('loginTimeout', loginTimeout);
if (loginTimeout) {
return;
}
loginTimeout = setTimeout(() => {
errMsg('请先登录');
loginTimeout = undefined;
}, 1500)
}, 1500);
}
return fetch(config.baseUrl + url, options)
.then((r) => {
try {
return r.json()
return r.json();
} catch (e) {
console.error(e);
}
return {
code: '-1',
message: '请求失败',
result: null
}
result: null,
};
})
.then((data) => {
if (data.errors) {
//全局消息提示
errMsg('请求出错')
errMsg('请求出错');
if (Array.isArray(data.errors)) {
data.errors.forEach((item: any) => {
if (item.defaultMessage) {
errMsg(item.defaultMessage)
errMsg(item.defaultMessage);
}
})
});
}
return {
code: '-1',
message: '请求失败',
result: null
}
result: null,
};
}
if (data.code !== '200') {
//未登录判断
if(data.code === '5008' || data.code === '2014'){
if (data.code === '5008' || data.code === '2014') {
loginErrorMsg();
window.logout();
}else{
} else {
errMsg(data.message || '请求出错');
}
}
return data;
})
.catch(error => {
.catch((error) => {
if (error.name === 'AbortError') {
console.log('请求已中断');
console.log(error);
......@@ -125,14 +129,14 @@ export default function request(url: string, method: String = 'get', data?: any,
return {
code: '-1',
message: '请求失败',
result: null
}
result: null,
};
});
}
//准备响应结构
export interface Response<T> {
code: string,
message: string,
result?: T | null
}
\ No newline at end of file
code: string;
message: string;
result?: T | null;
}
......@@ -14,8 +14,8 @@ const items: TabsProps['items'] = [
label: ` 首页 `,
},
{
key: '/jobServices',
label: `作业服务`,
key: '/mall',
label: `产品商城`,
},
{
key: '/equipmentLeasing',
......@@ -26,8 +26,8 @@ const items: TabsProps['items'] = [
label: `飞手培训`,
},
{
key: '/mall',
label: `产品商城`,
key: '/jobServices',
label: `作业服务`,
},
{
key: '/projectInfo',
......
import { Col, Modal, Row } from 'antd';
import Image from 'next/image';
import styles from './index.module.scss';
import img from './assets/img.png';
import { useContext, useEffect, useState } from 'react';
import api, { ListTagResp } from './api';
import { useRouter } from 'next/router';
......@@ -37,7 +36,7 @@ export default function JoinModal(props: Props) {
const onClickTag = (item: ListTagResp) => {
if (userInfo!.companyAuthStatus) {
router.replace('/JoinPolicy?tagId=' + item.id);
router.replace({ pathname: '/JoinPolicy', query: { tagId: item.id } });
props.onCancel && props.onCancel();
} else {
router.push('/certification');
......
import React, { Suspense } from 'react';
import React from 'react';
import { Layout, Space } from 'antd';
import NavHeader from '~/components/NavHeader';
import FooterView from '~/components/footer';
......
import { headers } from 'next/dist/client/components/headers';
import request, { Response } from '~/api/request';
export default {
uploadFile: (data: FormData): Promise<Response<string>> =>
request('/pms/upload/breakpoint', 'post', data, { headers: {}, body: data }),
};
.uploader-view{
.ant-upload-wrapper .ant-upload-list .ant-upload-list-item-container{
//width: 200px !important;
}
}
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { message, Upload, UploadProps } from 'antd';
// import { UploadFile } from "antd/es/upload/interface";
import './index.scss';
import uploadApi from './api';
interface PropsType {
listType?: 'text' | 'picture' | 'picture-card'; // 上传列表的内建样式
fileSize?: number; // 文件大小
fileType?: string[]; // 上传文件类型
fileUpload: boolean; // 是否上传到服务器(返回文件流还是返回上传后的地址)
fileLength?: number; // 最大上传文件数量
children: React.ReactNode; // 上传按钮
onChange?: (fileList: any[]) => void; // 上传文件改变时的状态
onRemove?: (fileList: any[]) => void;
onChange?: (
fileList: {
id: number;
name: string;
uid: number;
url: string;
}[],
) => void; // 上传文件改变时的状态
defaultFileList?: any[]; // 默认文件列表
}
export const Uploader: React.FC<PropsType> = (props) => {
Uploader.defaultProps = {
listType: 'text',
listType: 'picture-card',
fileSize: 2,
fileLength: 1,
fileType: ['image/png', 'image/jpeg', 'image/jpg', 'image/gif', 'image/bmp'],
fileType: ['image/png', 'image/jpeg', 'image/jpg', 'image/gif'],
onChange: () => {},
onRemove: () => {},
defaultFileList: [],
};
const { fileType, children, listType, fileSize, fileLength, onChange, onRemove } = props;
const {
fileType = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif', 'image/bmp'],
children,
listType,
fileSize,
fileUpload,
fileLength,
onChange,
defaultFileList,
} = props;
const [fileList, setFileList] = useState<any[]>([]);
// 上传文件配置
const uploadProps: UploadProps = {
listType,
fileList,
beforeUpload: (res) => {
console.log('上传文件-->', res);
const isType = fileType?.includes(res.type);
const isSize = res.size / 1024 / 1024 < (fileSize || 2);
const isLength = fileList.length < (fileLength || 1);
if (!isType) {
message.error('请上传正确的格式!').then();
return isType;
message.error('上传文件格式错误!').then();
}
if (!isSize) {
message.error('文件最大2M,请压缩后上传!').then();
return isSize;
message.error(`文件最大${props.fileSize}M,请压缩后上传!`).then();
}
if (!isLength) {
message.error(`最多上传${fileLength || 1}个文件`).then();
}
return isType && isSize && isLength;
},
customRequest: (res) => {
if (fileList.length >= (fileLength || 1)) {
message.error(`最多上传${fileLength || 1}个文件`).then();
return;
if (fileUpload) {
setFileList([
...fileList,
{
id: new Date().getTime(),
uid: new Date().getTime(),
name: (res.file as any).name,
type: (res.file as any).type,
url: (res.file as any).url,
status: 'uploading',
},
]);
// 上传到服务器
const formData = new FormData();
formData.append('uploadFile', res.file);
uploadApi.uploadFile(formData).then(({ result, code }) => {
if (code === '200') {
setFileList([
...fileList,
{
id: new Date().getTime(),
uid: new Date().getTime(),
name: (res.file as any).name || '',
url: result,
type: (res.file as any).type,
status: 'done',
},
]);
onChange?.([
...fileList,
{
id: new Date().getTime(),
uid: new Date().getTime(),
name: (res.file as any).name || '',
url: result,
type: (res.file as any).type,
status: 'done',
},
]);
}
});
} else {
setFileList([...fileList, res.file]);
onChange?.([...fileList, res.file]);
}
setFileList([...fileList, res.file]);
onChange?.([...fileList, res.file]);
},
onRemove: (res) => {
const newFileList = fileList.filter((item) => item.uid !== res.uid);
setFileList(newFileList);
onRemove?.(newFileList);
onChange?.(newFileList);
},
// onPreview: { onPreview },
};
useEffect(() => {
// 如果有默认文件列表
if (defaultFileList?.length) {
setFileList(defaultFileList);
} else {
setFileList([]);
}
}, [defaultFileList]);
return (
<div className='uploader-view'>
<Upload {...uploadProps} style={{ width: '100%' }}>
<>{fileList.length < (fileLength || 1) && children}</>
{children}
</Upload>
</div>
);
......
......@@ -27,7 +27,6 @@ const UserProvider = ({ children }: Props) => {
useEffect(() => {
try {
setUserInfo(JSON.parse(window.localStorage.getItem('userInfo') || '') || undefined);
window.setUserInfo = setUserInfo;
window.setNeedLogin = setNeedLogin;
window.logout = logout;
......
......@@ -27,8 +27,8 @@ const nextConfig = {
return [
{
source: '/local/:path*',
destination: 'https://www.iuav.shop/:path*',
// destination: 'https://test.iuav.shop/:path*',
// destination: 'https://www.iuav.shop/:path*',
destination: 'https://test.iuav.shop/:path*',
},
];
},
......
......@@ -4,8 +4,8 @@ export interface CooperationApplyParams {
applyName: string;
applyPhone: string;
remark?: string;
userAccountId: number;
cooperationTagId: number;
attachmentList?: { type: number; url: string }[];
}
export interface GetTagIdResp {
......@@ -14,6 +14,7 @@ export interface GetTagIdResp {
tagImg: string;
tagDescription: string;
createTime: string;
tagRequire: string;
}
export default {
......
.banner {
width: 100vw;
height: 200px;
background: #f25834;
position: absolute;
left: 50%;
top: 0;
transform: translate(-50%, 0);
.headerLine{
height: 8px;
background: linear-gradient(90deg, #F5B351 0%, #FF552D 100%);
}
.font1 {
font-size: 20px;
font-family: MicrosoftYaHeiUI-Bold, MicrosoftYaHeiUI;
font-weight: bold;
color: #000000;
line-height: 25px;
}
.font2 {
font-size: 18px;
font-family: MicrosoftYaHei;
color: #333333;
line-height: 32px;
font-size: 14px;
color: #1A1B1C;
line-height: 19px;
letter-spacing: 1px;
}
.infoContent{
padding: 29px 0 0 50px;
box-sizing: border-box;
.tip{
.tipTitle{
font-size: 14px;
font-weight: bold;
color: #000000;
line-height: 18px;
margin-bottom: 17px;
}
}
.formWrap{
margin-top: 35px;
.formTitle{
font-size: 14px;
font-weight: bold;
color: #000000;
line-height: 18px;
margin-bottom: 17px;
}
}
.uploadTip{
font-size: 12px;
color: #858687;
line-height: 18px;
margin-bottom: 12px;
}
.uploadOperate{
}
}
.submitOperate{
text-align: center;
margin-top: 69px;
button{
width: 200px;
height: 40px;
border-radius: 6px;
background: linear-gradient(90deg, #FF552D 0%, #FF812D 100%);
font-size: 16px;
color: #FEFFFE;
}
}
......@@ -4,107 +4,149 @@ import { useEffect, useState } from 'react';
import LayoutView from '~/components/layout';
import api from './api';
import styles from './index.module.scss';
import { phoneNumber } from '~/lib/validateUtils';
import { Uploader } from '~/components/uploader';
import JoinModal from '~/components/NavHeader/joinModal';
export default function JoinPolicy() {
const [form] = Form.useForm();
const router = useRouter();
const [content, setContent] = useState(''); //福利内容
const tagId = Number(router.query.tagId);
const [tagId, setTagId] = useState<number>(-1);
useEffect(() => {
if (tagId) {
if (router.query.tagId) {
setTagId(Number(router.query.tagId));
api
.getTagById({
id: tagId,
id: Number(router.query.tagId),
})
.then((res) => {
setContent(res.result?.tagDescription.replaceAll('\n', '<br/>') || '');
setContent(res.result?.tagRequire.replaceAll('\n', '<br/>') || '');
});
}
}, []);
}, [router.query.tagId]);
//提交
const onFinish = (values: any) => {
console.log(values);
api
.cooperationApply({
...values,
cooperationTagId: tagId,
})
.then((res) => {
console.log('提交结果', res);
if (res.code === '200') {
window.messageApi.success('提交成功');
setTimeout(() => {
router.push('/');
}, 1500);
}
});
const submitApply = () => {
form.validateFields().then((valid) => {
api
.cooperationApply({
...valid,
cooperationTagId: tagId,
})
.then((res) => {
if (res.code === '200') {
window.messageApi.success('提交成功');
form.resetFields();
setTimeout(() => {
router.push('/');
}, 1500);
}
});
});
};
//上传变更
const uploadChange = (value: any) => {
let attachmentList = value.map((v: any) => ({
type: v.type.includes('image') ? 0 : 1,
url: v.url,
}));
form.setFieldValue('attachmentList', attachmentList);
};
return (
<LayoutView>
<div className={styles.banner}></div>
<div
className='page'
style={{
background: '#fff',
position: 'relative',
zIndex: 1,
marginTop: 60,
marginTop: 20,
paddingBottom: 63,
}}
>
<div
className={styles.font1}
style={{ textAlign: 'center', paddingTop: 40, paddingBottom: 30 }}
>
加盟入驻福利
<div className={styles.headerLine}></div>
<div className={styles.font1} style={{ textAlign: 'center', marginTop: '22px' }}>
加盟入驻
</div>
<div
className={styles.font2}
style={{ paddingLeft: 50, paddingRight: 50 }}
dangerouslySetInnerHTML={{ __html: content }}
></div>
<Divider />
<div className={styles.font1} style={{ textAlign: 'center', marginBottom: 28 }}>
申请加盟入驻
</div>
<Row justify={'center'}>
<Col style={{ width: 400 }}>
<Form labelAlign='left' labelCol={{ span: 5 }} onFinish={onFinish}>
<Form.Item label='姓名' name='applyName' rules={[{ required: true }]}>
<Input placeholder='请输入姓名'></Input>
</Form.Item>
<Form.Item
label='联系方式'
name='applyPhone'
rules={[
{ required: true },
{
pattern: /^1\d{10}$/,
message: '很输入11位手机号',
},
]}
>
<Input placeholder='请输入手机号' maxLength={11} onInput={phoneNumber}></Input>
</Form.Item>
<Form.Item name='remark'>
<Input.TextArea placeholder='其它信息'></Input.TextArea>
</Form.Item>
<Row justify={'center'}>
<Button
type='primary'
htmlType='submit'
style={{ marginTop: 11, width: 200 }}
size='large'
<div className={styles.infoContent}>
<div className={styles.tip}>
<div className={styles.tipTitle}>需准备上传资料</div>
<div className={styles.font2} dangerouslySetInnerHTML={{ __html: content }}></div>
</div>
<div className={styles.formWrap}>
<div className={styles.formTitle}>填写资料</div>
<div className={styles.form}>
<Form labelCol={{ span: 2 }} wrapperCol={{ span: 10 }} labelAlign='left' form={form}>
<Form.Item
label='联系人'
name='applyName'
rules={[{ required: true, message: '请输入联系人' }]}
>
<Input placeholder='请输入联系人' maxLength={30} />
</Form.Item>
<Form.Item
label='联系方式'
name='applyPhone'
rules={[
{ required: true, message: '请输入联系方式' },
{ pattern: /^1\d{10}$/, message: '请输入正确的手机号码' },
]}
>
提交申请
</Button>
</Row>
</Form>
</Col>
</Row>
<Input placeholder='请输入联系方式' />
</Form.Item>
<Row>
<Col span={2}>
<div>上传资料:</div>
</Col>
<Col span={10}>
<div className={styles.uploadTip}>
<div>1. 图片格式为JPG、JPEG、BMP、GIF、PNG</div>
<div>2. 文档格式为word、PDF、excel</div>
<div> 3. 文件大小不超过10M</div>
</div>
<div className={styles.uploadOperate}>
<Form.Item name='attachmentList'>
<Uploader
fileUpload
listType='text'
fileLength={3}
fileSize={10}
onChange={uploadChange}
fileType={[
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'pplication/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.ms-excel',
'application/pdf',
'application/msword',
'image/png',
'image/jpeg',
'image/jpg',
'image/gif',
'image/bmp',
]}
>
<Button>上传文件</Button>
</Uploader>
</Form.Item>
</div>
</Col>
</Row>
<Form.Item label='备注(选填)' name='remark'>
<Input placeholder='请输入备注' maxLength={60} />
</Form.Item>
</Form>
</div>
</div>
</div>
<div className={styles.submitOperate}>
<Button type='primary' onClick={submitApply}>
提交申请
</Button>
</div>
</div>
</LayoutView>
);
}
JoinPolicy.getInitialProps = async () => {
return {};
};
import { Pagination } from 'antd';
import { Pagination, Image as AntdImage } from 'antd';
import Image from 'next/image';
import { useRouter } from 'next/router';
import { useContext, useEffect, useRef, useState } from 'react';
......@@ -57,7 +57,7 @@ export default function EquipmentLeasing(props: Props) {
const rightDom = (item: { id: number; bannerImg: string }) => {
return (
<div key={item.id} className='right-box-item right-item'>
<Image src={item.bannerImg} alt='error' fill />
<AntdImage src={item.bannerImg} width={180} preview={false} />
</div>
);
};
......
......@@ -67,11 +67,6 @@ export const Box = styled.div`
}
.right-item {
width: 180px;
height: 347px;
background: #d8d8d8;
border-radius: 6px;
overflow: hidden;
position: relative;
}
.pagination-page {
text-align: right;
......
......@@ -9,6 +9,7 @@ import {
Select,
Space,
message,
Image as AntdImage,
} from 'antd';
import type { CheckboxValueType } from 'antd/es/checkbox/Group';
import Image from 'next/image';
......@@ -94,7 +95,7 @@ export default function FlyingHandService() {
const rightDom = (item: string) => {
return (
<div className='right-box-item right-item' key={item}>
<Image src={item} alt='error' fill />
<AntdImage src={item} width={260} preview={false} />
</div>
);
};
......
......@@ -128,11 +128,6 @@ export const Box = styled.div`
}
.right-item {
width: 260px;
height: 500px;
background: #ffffff;
border-radius: 6px;
overflow: hidden;
position: relative;
}
.pagination-page {
text-align: right;
......
......@@ -5,10 +5,7 @@ export interface PublishParams {
lon?: number; //经度
description: string; //描述
userId: number; //用户id
mediaVO: {
//发布图片
picture: Array<string>;
};
mediaVO: { type: number; url: string }[];
}
export default {
......
......@@ -96,17 +96,13 @@ export default function PublishMessage(props: Props) {
.publish({
lat: position?.position?.lat, //纬度
lon: position?.position?.lng, //经度
title: '', //标题
description: values.description, //描述
userId: userInfo.id, //用户id
mediaVO: {
//发布图片
//@ts-ignore
picture: fileList.filter((item) => item.url).map((item) => item.url),
},
mediaVO: fileList
.filter((item) => item.url)
.map((item) => ({ type: 0, url: item.url as string })),
})
.then((res) => {
console.log('提交结果', res);
setShowLoad(false);
if (res.code === '200') {
window.messageApi.success('发布成功');
......
import React, { useEffect, useState, useRef } from 'react';
import { Box } from './styled';
import { Pagination } from 'antd';
import { Pagination, Image } from 'antd';
import Layout from '~/components/layout';
import ContentBox from '~/components/contentBox';
import { useRouter } from 'next/router';
import Filter, { FilterResult, AdapterResult } from '~/components/filter';
import api, { Job } from './api';
import commonApi from '~/api';
import Image from 'next/image';
// 此函数在构建时被调用
export async function getServerSideProps() {
return {
......@@ -53,7 +52,7 @@ export default function JobServices() {
const rightDom = (item: string) => {
return (
<div className='right-box-item advertisement' key={item}>
<Image src={item} alt='error' width={260} height={500} />
<Image src={item} width={260} preview={false} />
</div>
);
};
......
......@@ -86,12 +86,6 @@ export const Box = styled.div`
}
}
}
.advertisement {
width: 260px;
height: 420px;
background: #ffffff;
border-radius: 6px;
}
.pagination-page {
text-align: right;
}
......
......@@ -151,7 +151,7 @@ export default function Mall(props: Props) {
className={styles.ad}
src={item.bannerImg}
width={189}
height={364}
// height={364}
preview={false}
fallback={errImg}
></Image>
......
import { RightOutlined } from '@ant-design/icons';
import { Button, Col, Empty, Pagination, Row, Spin } from 'antd';
import { Col, Empty, Pagination, Row, Spin } from 'antd';
import styles from './index.module.scss';
import Image from 'next/image';
import { useState, useEffect, useContext } from 'react';
......@@ -96,13 +95,13 @@ export default function News(props: Props) {
{Moment().format('yyyy-MM-DD')} · {item.newsAuthor}
</div>
</div>
<Button
type='primary'
style={{ width: 120, height: 40, flexShrink: 0 }}
onClick={onGetInfo}
>
获取产品资料
</Button>
{/*<Button*/}
{/* type='primary'*/}
{/* style={{ width: 120, height: 40, flexShrink: 0 }}*/}
{/* onClick={onGetInfo}*/}
{/*>*/}
{/* 获取产品资料*/}
{/*</Button>*/}
</div>
);
})}
......
.bannerWrap{
height: 100px;
position: relative;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论