提交 a4157264 作者: 翁进城

Merge branch 'master' into feature/chuck

import config from './config'; import config from './config';
let loginTimeout: NodeJS.Timeout | undefined;
/** /**
* 请求封装 * 请求封装
* @param url 请求url * @param url 请求url
...@@ -43,12 +45,31 @@ export default function request(url: string, method: String = 'get', data?: any, ...@@ -43,12 +45,31 @@ export default function request(url: string, method: String = 'get', data?: any,
} }
} }
/**
* 错误消息
* @param msg
*/
function errMsg(msg: string) { function errMsg(msg: string) {
if (!options.hideError) { if (!options.hideError) {
window.messageApi.error(msg); window.messageApi.error(msg);
} }
} }
/**
* 未登录消息展示,1.5秒内限制只展示一次
* @returns
*/
function loginErrorMsg(){
console.log('loginTimeout', loginTimeout)
if(loginTimeout){
return;
}
loginTimeout = setTimeout(() => {
errMsg('请先登录');
loginTimeout = undefined;
}, 1500)
}
return fetch(config.baseUrl + url, options) return fetch(config.baseUrl + url, options)
.then((r) => { .then((r) => {
try { try {
...@@ -85,7 +106,8 @@ export default function request(url: string, method: String = 'get', data?: any, ...@@ -85,7 +106,8 @@ export default function request(url: string, method: String = 'get', data?: any,
if (data.code !== '200') { if (data.code !== '200') {
//未登录判断 //未登录判断
if(data.code === '5008'){ if(data.code === '5008'){
errMsg('请先登录'); loginErrorMsg();
window.logout();
}else{ }else{
errMsg(data.message || '请求出错'); errMsg(data.message || '请求出错');
} }
......
...@@ -47,7 +47,7 @@ export default function RegionItem(props: Props) { ...@@ -47,7 +47,7 @@ export default function RegionItem(props: Props) {
}; };
})} })}
/> />
<Select {/* <Select
value={selectCity} value={selectCity}
bordered={false} bordered={false}
popupMatchSelectWidth={false} popupMatchSelectWidth={false}
...@@ -60,7 +60,7 @@ export default function RegionItem(props: Props) { ...@@ -60,7 +60,7 @@ export default function RegionItem(props: Props) {
label: item.name, label: item.name,
}; };
})} })}
/> /> */}
</Space> </Space>
</div> </div>
</div> </div>
......
...@@ -35,6 +35,10 @@ const UserProvider = ({ children }: Props) => { ...@@ -35,6 +35,10 @@ const UserProvider = ({ children }: Props) => {
setUserInfo( setUserInfo(
JSON.parse(window.localStorage.getItem("userInfo") || "") || undefined JSON.parse(window.localStorage.getItem("userInfo") || "") || undefined
); );
window.setUserInfo = setUserInfo;
window.setNeedLogin = setNeedLogin;
window.logout = logout;
} catch (e) {} } catch (e) {}
}, []); }, []);
......
...@@ -4,6 +4,7 @@ import { useEffect, useState } from "react"; ...@@ -4,6 +4,7 @@ import { useEffect, useState } from "react";
import LayoutView from "~/components/layout"; import LayoutView from "~/components/layout";
import api from "./api"; import api from "./api";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import { phoneNumber } from "~/lib/validateUtils";
export default function JoinPolicy() { export default function JoinPolicy() {
const router = useRouter(); const router = useRouter();
...@@ -92,7 +93,11 @@ export default function JoinPolicy() { ...@@ -92,7 +93,11 @@ export default function JoinPolicy() {
}, },
]} ]}
> >
<Input placeholder="请输入手机号" maxLength={11}></Input> <Input
placeholder="请输入手机号"
maxLength={11}
onInput={phoneNumber}
></Input>
</Form.Item> </Form.Item>
<Form.Item name="remark"> <Form.Item name="remark">
<Input.TextArea placeholder="其它信息"></Input.TextArea> <Input.TextArea placeholder="其它信息"></Input.TextArea>
......
...@@ -91,7 +91,11 @@ export default function Certification() { ...@@ -91,7 +91,11 @@ export default function Certification() {
}); });
} }
setTimeout(() => { setTimeout(() => {
if (Router.query.type == 'back'){
Router.back();
}else{
Router.push("/"); Router.push("/");
}
}, 1000); }, 1000);
} }
}); });
......
...@@ -83,7 +83,7 @@ export default function Mall(props: Props) { ...@@ -83,7 +83,7 @@ export default function Mall(props: Props) {
<Layout> <Layout>
<div className="page" style={{ paddingTop: "18px" }}> <div className="page" style={{ paddingTop: "18px" }}>
<Filter <Filter
types={["类目", "地域", "品牌", "部件", "型号", "成色"]} types={["类目", "地域", "品牌", "部件",/* "型号", "成色" */]}
showResultItem showResultItem
onChange={onFilterChange} onChange={onFilterChange}
></Filter> ></Filter>
......
...@@ -101,7 +101,7 @@ export default function Bids(props: Props) { ...@@ -101,7 +101,7 @@ export default function Bids(props: Props) {
<Button type="primary" className={styles.btn}> <Button type="primary" className={styles.btn}>
<div className={styles.text1}>{item.tenderPrice}</div> <div className={styles.text1}>{item.tenderPrice}</div>
<div className={styles.text2} onClick={() => onApply(item)}> <div className={styles.text2} onClick={() => onApply(item)}>
申请合作 商务合作
</div> </div>
</Button> </Button>
)} )}
......
...@@ -86,7 +86,7 @@ export default function Cases(props: Props) { ...@@ -86,7 +86,7 @@ export default function Cases(props: Props) {
Router.push("/projectInfo/caseArticle/" + item.id) Router.push("/projectInfo/caseArticle/" + item.id)
} }
> >
申请合作 联系品牌厂家
</Button> </Button>
</div> </div>
); );
......
...@@ -2,10 +2,11 @@ import { RightOutlined } from "@ant-design/icons"; ...@@ -2,10 +2,11 @@ import { RightOutlined } from "@ant-design/icons";
import { Button, Col, Empty, Pagination, Row, Spin } from "antd"; import { Button, Col, Empty, Pagination, Row, Spin } from "antd";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import Image from "next/image"; import Image from "next/image";
import { useState, useEffect } from "react"; import { useState, useEffect, useContext } from "react";
import api, { Item } from "./api"; import api, { Item } from "./api";
import { useRouter } from "next/router"; import Router from "next/router";
import Moment from "moment"; import Moment from "moment";
import { UserContext } from "~/lib/userProvider";
type Props = { type Props = {
params?: { params?: {
...@@ -25,7 +26,7 @@ export default function News(props: Props) { ...@@ -25,7 +26,7 @@ export default function News(props: Props) {
}); });
const [count, setCount] = useState(0); const [count, setCount] = useState(0);
const [abort, setAbort] = useState<AbortController | null>(null); const [abort, setAbort] = useState<AbortController | null>(null);
const router = useRouter(); const { userInfo, setNeedLogin } = useContext(UserContext);
useEffect(() => { useEffect(() => {
//中断前一次请求 //中断前一次请求
...@@ -62,6 +63,19 @@ export default function News(props: Props) { ...@@ -62,6 +63,19 @@ export default function News(props: Props) {
}); });
}; };
//获取产品信息事件
const onGetInfo = () => {
if(userInfo){
if(userInfo.companyAuthStatus){
}else{
Router.push("/certification?type=back");
}
}else{
setNeedLogin(true);
}
}
return ( return (
<Spin spinning={loading} delay={500}> <Spin spinning={loading} delay={500}>
<Row justify="space-between" style={{ height: 606 }}> <Row justify="space-between" style={{ height: 606 }}>
...@@ -86,11 +100,9 @@ export default function News(props: Props) { ...@@ -86,11 +100,9 @@ export default function News(props: Props) {
<Button <Button
type="primary" type="primary"
style={{ width: 120, height: 40, flexShrink: 0 }} style={{ width: 120, height: 40, flexShrink: 0 }}
onClick={() => onClick={onGetInfo}
router.push("/projectInfo/newsArticle/" + item.id)
}
> >
申请合作 获取产品资料
</Button> </Button>
</div> </div>
); );
......
...@@ -23,7 +23,7 @@ export interface Params { ...@@ -23,7 +23,7 @@ export interface Params {
} }
const items = (params: any) => const items = (params: any) =>
["项目需求", "招投标项目", "业务案例", "行业新闻"].map((value) => { [/* "项目需求", */ "招投标项目", "项目案例", "行业新闻"].map((value) => {
let children: JSX.Element | string = <></>; let children: JSX.Element | string = <></>;
switch (value) { switch (value) {
...@@ -35,7 +35,7 @@ const items = (params: any) => ...@@ -35,7 +35,7 @@ const items = (params: any) =>
children = <Bids params={params}></Bids>; children = <Bids params={params}></Bids>;
break; break;
case "业务案例": case "项目案例":
children = <Cases params={params}></Cases>; children = <Cases params={params}></Cases>;
break; break;
...@@ -120,7 +120,7 @@ export default function ProjectInfo() { ...@@ -120,7 +120,7 @@ export default function ProjectInfo() {
fieldNames={{ fieldNames={{
label: "name", label: "name",
value: "id", value: "id",
children: "childInfo", // children: "childInfo",
}} }}
changeOnSelect changeOnSelect
/> />
......
...@@ -5,6 +5,9 @@ declare global { ...@@ -5,6 +5,9 @@ declare global {
messageApi: MessageInstance; //全局消息提示api messageApi: MessageInstance; //全局消息提示api
WxLogin: any; //微信登录对象 WxLogin: any; //微信登录对象
_AMapSecurityConfig: { securityJsCode: string }; //高德地图api密钥配置 _AMapSecurityConfig: { securityJsCode: string }; //高德地图api密钥配置
AMap:any AMap: any;
setUserInfo: Dispatch<SetStateAction<UserInfoResp | null | undefined>>; //设置userInfo
setNeedLogin: Dispatch<SetStateAction<Boolean>>; //需要登录操作
logout: () => void; //退出登录
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论