Commit 1b926cde authored by GuanHua's avatar GuanHua

fix: 修改获取店铺信息接口

parent bd6c9875
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
.img_list { .img_list {
display: flex; display: flex;
flex-wrap: wrap;
} }
.shop_url { .shop_url {
...@@ -120,4 +120,4 @@ ...@@ -120,4 +120,4 @@
} }
} }
} }
} }
\ No newline at end of file
...@@ -328,7 +328,7 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -328,7 +328,7 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
label={<RequireItem label="公司简介" isRequire={true} />} label={<RequireItem label="公司简介" isRequire={true} />}
rules={[{ required: true, message: "请输入公司简介" }]} rules={[{ required: true, message: "请输入公司简介" }]}
> >
<Input.TextArea allowClear rows={5} className={styles.form_item} placeholder="请输入公司简介" maxLength={200} /> <Input.TextArea rows={5} className={styles.form_item} placeholder="请输入公司简介" maxLength={200} />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
labelAlign="left" labelAlign="left"
...@@ -346,15 +346,15 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -346,15 +346,15 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
</div> </div>
)) ))
} }
<UploadImage
imgUrl={""}
large={true}
fileMaxSize={100}
size="600x400"
onChange={(url) => handleAddworkshopPics(url)}
/>
</div> </div>
<UploadImage
imgUrl={""}
large={true}
fileMaxSize={100}
size="600x400"
onChange={(url) => handleAddworkshopPics(url)}
/>
</div> </div>
</Form.Item> </Form.Item>
<Form.Item <Form.Item
...@@ -373,15 +373,15 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -373,15 +373,15 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
</div> </div>
)) ))
} }
<UploadImage
imgUrl={""}
large={true}
fileMaxSize={100}
size="106x107"
onChange={(url) => handleAddhonorPics(url)}
/>
</div> </div>
<UploadImage
imgUrl={""}
large={true}
fileMaxSize={100}
size="106x107"
onChange={(url) => handleAddhonorPics(url)}
/>
</div> </div>
</Form.Item> </Form.Item>
<Form.Item <Form.Item
......
...@@ -25,7 +25,7 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => { ...@@ -25,7 +25,7 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => {
const { search } = history.location.query const { search } = history.location.query
useEffect(() => { useEffect(() => {
if (!!search) { if (search) {
setSearchValue(search) setSearchValue(search)
} else { } else {
setSearchValue("") setSearchValue("")
...@@ -48,13 +48,12 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => { ...@@ -48,13 +48,12 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => {
const applyFroVip = () => { const applyFroVip = () => {
if (shopInfo) { if (shopInfo) {
let param = { const param = {
memberId: shopInfo.memberId, memberId: shopInfo.memberId,
roleId: shopInfo.roleId roleId: shopInfo.roleId
} }
setApplyLoading(true) setApplyLoading(true)
PublicApi.postMemberAbilityMallSubApply(param).then((res) => { PublicApi.postMemberAbilityMallSubApply(param).then((res) => {
if (res.code === 1000) { }
setApplyLoading(false) setApplyLoading(false)
}).catch(() => { }).catch(() => {
setApplyLoading(false) setApplyLoading(false)
...@@ -63,8 +62,8 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => { ...@@ -63,8 +62,8 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => {
} }
const handleCollect = () => { const handleCollect = () => {
let status = !collectState const status = !collectState
let param = { const param = {
shopId: shopInfo.id, shopId: shopInfo.id,
status status
} }
...@@ -101,7 +100,7 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => { ...@@ -101,7 +100,7 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => {
</div> </div>
<div className={styles.shop_header_info_content}> <div className={styles.shop_header_info_content}>
<div className={styles.shop_header_info_content_name}> <div className={styles.shop_header_info_content_name}>
<span>{shopInfo?.company}</span> <span>{shopInfo?.memberName}</span>
<CaretDownOutlined className={styles.shop_header_info_content_icon} /> <CaretDownOutlined className={styles.shop_header_info_content_icon} />
</div> </div>
<div className={styles.shop_header_info_content_about}> <div className={styles.shop_header_info_content_about}>
...@@ -112,7 +111,7 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => { ...@@ -112,7 +111,7 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => {
</div> </div>
<div className={styles.shop_header_info_content_about_item}> <div className={styles.shop_header_info_content_about_item}>
<i className={styles.icon}><img src={credit_icon} /></i> <i className={styles.icon}><img src={credit_icon} /></i>
<span>{200}</span> <span>{shopInfo?.creditPoint || 0}</span>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -67,7 +67,7 @@ const TopBar: React.FC<TopBarPropsType> = (props) => { ...@@ -67,7 +67,7 @@ const TopBar: React.FC<TopBarPropsType> = (props) => {
{ {
userInfo ? ( userInfo ? (
<li className={cx(styles.topbar_menu_item, styles.username)}> <li className={cx(styles.topbar_menu_item, styles.username)}>
<span className={styles.username}>{userInfo?.name}</span> <Link className={styles.username} to="/memberCenter/home">{userInfo?.name}</Link>
<CaretDownOutlined className={styles.arrow_icon} /> <CaretDownOutlined className={styles.arrow_icon} />
<div className={styles.userInfo_card_split}></div> <div className={styles.userInfo_card_split}></div>
<div className={styles.userInfo_card}> <div className={styles.userInfo_card}>
...@@ -134,4 +134,4 @@ const TopBar: React.FC<TopBarPropsType> = (props) => { ...@@ -134,4 +134,4 @@ const TopBar: React.FC<TopBarPropsType> = (props) => {
) )
} }
export default inject('UserStore')(observer(TopBar)) export default inject('UserStore')(observer(TopBar))
\ No newline at end of file
...@@ -85,11 +85,11 @@ const LXChannelLayout: React.FC<LXChannelLayoutPropsType> = (props) => { ...@@ -85,11 +85,11 @@ const LXChannelLayout: React.FC<LXChannelLayoutPropsType> = (props) => {
<Fragment> <Fragment>
<Helmet> <Helmet>
{ {
shopInfo ? <title>{shopInfo.company}</title> : null shopInfo ? <title>{shopInfo.memberName}</title> : null
} }
</Helmet> </Helmet>
<div className={styles.lxmall_page}> <div className={styles.lxmall_page}>
<TopBar langComponent={<SelectLang />} name={shopInfo?.company} type={LAYOUT_TYPE.channel} shopUrlParam={channelId} /> <TopBar langComponent={<SelectLang />} name={shopInfo?.memberName} type={LAYOUT_TYPE.channel} shopUrlParam={channelId} />
<div className={styles.content}> <div className={styles.content}>
{ {
!menuRouter?.hideHeader && ( !menuRouter?.hideHeader && (
......
...@@ -85,11 +85,11 @@ const LXIChannelLayout: React.FC<LXIChannelLayoutPropsType> = (props) => { ...@@ -85,11 +85,11 @@ const LXIChannelLayout: React.FC<LXIChannelLayoutPropsType> = (props) => {
<Fragment> <Fragment>
<Helmet> <Helmet>
{ {
shopInfo ? <title>{shopInfo.company}</title> : null shopInfo ? <title>{shopInfo.memberName}</title> : null
} }
</Helmet> </Helmet>
<div className={styles.lxmall_page}> <div className={styles.lxmall_page}>
<TopBar langComponent={<SelectLang />} name={shopInfo?.company} type={LAYOUT_TYPE.ichannel} shopUrlParam={channelId} /> <TopBar langComponent={<SelectLang />} name={shopInfo?.memberName} type={LAYOUT_TYPE.ichannel} shopUrlParam={channelId} />
<div className={styles.content}> <div className={styles.content}>
{ {
!menuRouter?.hideHeader && ( !menuRouter?.hideHeader && (
......
...@@ -64,10 +64,17 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -64,10 +64,17 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => {
const fetchShopInfo = (memberId, roleId, storeId) => { const fetchShopInfo = (memberId, roleId, storeId) => {
const param: any = { const param: any = {
memberId, memberId,
roleId,
storeId
} }
PublicApi.getTemplateShopFindShop(param).then(res => { let getShopInfoFn = null
if(storeId) {
param.storeId = storeId
getShopInfoFn = PublicApi.getTemplateWebMemberShopWebMemberShopMain
} else if(roleId) {
param.roleId = roleId
getShopInfoFn = PublicApi.getTemplateWebMemberShopWebFindByMemberIdAndRoleId
}
console.log(param, "param")
getShopInfoFn && getShopInfoFn(param).then(res => {
if (res.code === 1000) { if (res.code === 1000) {
setShopInfo(res.data) setShopInfo(res.data)
} }
...@@ -107,7 +114,7 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -107,7 +114,7 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => {
<ShopHeader logo={mallInfo.logoUrl} shopId={query.shopId} shopUrlParam={shopId} shopInfo={shopInfo} updateShopInfo={() => handleUpdate()} /> <ShopHeader logo={mallInfo.logoUrl} shopId={query.shopId} shopUrlParam={shopId} shopInfo={shopInfo} updateShopInfo={() => handleUpdate()} />
<MainNav menuData={menuData} pathname={location.pathname} type={LAYOUT_TYPE.shop} shopId={query.shopId} shopUrlParam={shopId} /> <MainNav menuData={menuData} pathname={location.pathname} type={LAYOUT_TYPE.shop} shopId={query.shopId} shopUrlParam={shopId} />
{ {
!loading ? shopInfo ? shopInfo.status === 1 ? children && React.Children.map(children, (child: any) => { !loading ? shopInfo ? children && React.Children.map(children, (child: any) => {
return React.cloneElement(child, return React.cloneElement(child,
{ {
layoutType: LAYOUT_TYPE.shop, layoutType: LAYOUT_TYPE.shop,
...@@ -118,7 +125,7 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -118,7 +125,7 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => {
updateShopInfo: () => handleUpdate() updateShopInfo: () => handleUpdate()
}, },
); );
}) : <SearchShopResult search={shopInfo.company} /> : <SearchShopResult /> : null }) : <SearchShopResult search={shopInfo.company} /> : <SearchShopResult />
} }
</div> </div>
<Footer /> <Footer />
......
.shop_info { .shop_info {
background-color: #ffffff; background-color: #ffffff;
padding: 32px 24px; padding: 32px 24px;
border-radius: 8px; border-radius: 8px;
.add_template_form { .add_template_form {
:global { :global {
.ant-form-item-label>label::after { .ant-form-item-label>label::after {
display: none; display: none;
} }
} }
} }
.form_item { .form_item {
width: 572px; width: 572px;
resize: none; resize: none;
} }
.form_item_wrap { .form_item_wrap {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
align-items: center; align-items: center;
.size_require { .size_require {
color: #C0C4CC; color: #C0C4CC;
} }
} }
.img_list { .img_list {
display: flex; display: flex;
flex-wrap: wrap;
} }
.shop_url { .shop_url {
width: 572px; width: 572px;
color: #909399; color: #909399;
margin-top: 16px; margin-top: 16px;
font-size: 12px; font-size: 12px;
display: flex; display: flex;
&>label { &>label {
flex: 1; flex: 1;
width: 0; width: 0;
display: block; display: block;
color: #303133; color: #303133;
margin-left: 8px; margin-left: 8px;
margin-right: 15px; margin-right: 15px;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.copy_icon { .copy_icon {
cursor: pointer; cursor: pointer;
} }
} }
.upload_btn { .upload_btn {
position: relative; position: relative;
width: 104px; width: 104px;
height: 104px; height: 104px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
color: #909399; color: #909399;
flex-direction: column; flex-direction: column;
background: rgba(250, 251, 252, 1); background: rgba(250, 251, 252, 1);
border-radius: 2px; border-radius: 2px;
border: 1px dashed rgba(223, 225, 230, 1); border: 1px dashed rgba(223, 225, 230, 1);
cursor: pointer; cursor: pointer;
margin-right: 24px; margin-right: 24px;
overflow: hidden; overflow: hidden;
margin-bottom: 12px; margin-bottom: 12px;
&.upload { &.upload {
border: 1px solid rgba(223, 225, 230, 1); border: 1px solid rgba(223, 225, 230, 1);
background: #ffffff; background: #ffffff;
} }
.upload_img { .upload_img {
height: 100%; height: 100%;
width: 100%; width: 100%;
display: block; display: block;
margin: 0 auto; margin: 0 auto;
background-size: auto 100%; background-size: auto 100%;
background-position: center center; background-position: center center;
background-repeat: no-repeat; background-repeat: no-repeat;
} }
&>img { &>img {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
&.large { &.large {
width: 175px; width: 175px;
height: 120px; height: 120px;
} }
&>p { &>p {
margin-top: 12px; margin-top: 12px;
} }
.delete_btn { .delete_btn {
position: absolute; position: absolute;
width: 24px; width: 24px;
height: 24px; height: 24px;
border-radius: 4px; border-radius: 4px;
background: rgba(0, 0, 0, 0.45); background: rgba(0, 0, 0, 0.45);
top: 8px; top: 8px;
right: 8px; right: 8px;
color: #ffffff; color: #ffffff;
text-align: center; text-align: center;
line-height: 24px; line-height: 24px;
&:hover { &:hover {
cursor: pointer; cursor: pointer;
opacity: .8; opacity: .8;
} }
} }
} }
} }
\ No newline at end of file
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import { PageHeaderWrapper } from '@ant-design/pro-layout' import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { Form, Input, Button, Tooltip, Select, message } from 'antd' import { Form, Input, Button, Tooltip, Select, message } from 'antd'
import { Prompt } from 'umi' import { Prompt } from 'umi'
import { inject } from 'mobx-react' import { inject } from 'mobx-react'
import { QuestionCircleOutlined, DeleteOutlined, CopyOutlined } from '@ant-design/icons' import { QuestionCircleOutlined, DeleteOutlined, CopyOutlined } from '@ant-design/icons'
import CitySelect from '@/components/CitySelect' import CitySelect from '@/components/CitySelect'
import RequireItem from '@/components/RequireItem' import RequireItem from '@/components/RequireItem'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import UploadImage from '@/components/UploadImage' import UploadImage from '@/components/UploadImage'
import { GetTemplateShopFindShopResponse } from '@/services/TemplateApi' import { GetTemplateShopFindShopResponse } from '@/services/TemplateApi'
import copy from 'copy-to-clipboard' import copy from 'copy-to-clipboard'
import cx from 'classnames' import cx from 'classnames'
import styles from './index.less' import styles from './index.less'
import { getAuth } from '@/utils/auth' import { getAuth } from '@/utils/auth'
import { isEmpty } from '@formily/antd/esm/shared' import { isEmpty } from '@formily/antd/esm/shared'
interface ShopInfoPropsType { interface ShopInfoPropsType {
SiteStore: { SiteStore: {
siteUrl: string; siteUrl: string;
siteId: number; siteId: number;
} }
} }
const defaultCityData = { index: 0, provinceCode: 0, province: '', cityCode: 0, city: '' } const defaultCityData = { index: 0, provinceCode: 0, province: '', cityCode: 0, city: '' }
const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
const { siteUrl, siteId } = props.SiteStore const { siteUrl, siteId } = props.SiteStore
const [formIsHalfFilledOut, setFormIsHalfFilledOut] = useState(false) const [formIsHalfFilledOut, setFormIsHalfFilledOut] = useState(false)
const [form] = Form.useForm() const [form] = Form.useForm()
const [allMallList, setAllMallList] = useState([]) const [allMallList, setAllMallList] = useState([])
const [storeUrl, setStoreUrl] = useState<string>('') const [storeUrl, setStoreUrl] = useState<string>('')
const [selectCityData, setSelectCityData] = useState<any>([defaultCityData]) const [selectCityData, setSelectCityData] = useState<any>([defaultCityData])
const [workshopPics, setWorkshopPics] = useState([]) // 厂房照片 const [workshopPics, setWorkshopPics] = useState([]) // 厂房照片
const [honorPics, setHonorPics] = useState([]) // 资质荣誉 const [honorPics, setHonorPics] = useState([]) // 资质荣誉
const [logo, setLogo] = useState<string>("") const [logo, setLogo] = useState<string>("")
const [shopInfo, setShopInfo] = useState<GetTemplateShopFindShopResponse>() const [shopInfo, setShopInfo] = useState<GetTemplateShopFindShopResponse>()
const [shopId, setShopId] = useState<number>() const [shopId, setShopId] = useState<number>()
useEffect(() => { useEffect(() => {
fetchShopInfo() fetchShopInfo()
fetchAllShop() fetchAllShop()
}, []) }, [])
// 根据站点获取商城信息 // 根据站点获取商城信息
const fetchAllShop = () => { const fetchAllShop = () => {
const param: any = { const param: any = {
siteId, siteId,
type: 1 type: 1
} }
PublicApi.getManageShopFindShopsBySiteId(param).then(res => { PublicApi.getManageShopFindShopsBySiteId(param).then(res => {
if (res.code === 1000) { if (res.code === 1000) {
setAllMallList(res.data) setAllMallList(res.data)
} }
}) })
} }
/** /**
* 获取店铺信息 * 获取店铺信息
*/ */
const fetchShopInfo = () => { const fetchShopInfo = () => {
const { memberId, memberRoleId } = getAuth() || {} const { memberId, memberRoleId } = getAuth() || {}
const param: any = { const param: any = {
memberId, memberId,
roleId: memberRoleId roleId: memberRoleId
} }
PublicApi.getTemplateShopFindShop(param).then(res => { PublicApi.getTemplateWebMemberShopWebFindCurrMemberShop(param).then(res => {
const data = res.data const data = res.data
if (res.code === 1000) { if (res.code === 1000) {
setShopInfo(data) setShopInfo(data)
setSelectCityData(initMemberShopArea(data.memberShopAreas)) setSelectCityData(initMemberShopArea(data.memberShopAreas))
setLogo(data.logo) setLogo(data.logo)
setShopId(data.shopId) setShopId(data.shopId)
setWorkshopPics(data.workshopPics || []) setWorkshopPics(data.workshopPics || [])
setHonorPics(data.honorPics || []) setHonorPics(data.honorPics || [])
if (data.shopId && data.memberId) { if (data.shopId && data.memberId) {
setStoreUrl(data.storeUrl || "") setStoreUrl(data.storeUrl || "")
} }
form.setFieldsValue({ form.setFieldsValue({
describe: data.describe, describe: data.describe,
customerUrl: data.customerUrl, customerUrl: data.customerUrl,
logo: data.logo, logo: data.logo,
memberShopAreas: initMemberShopArea(data.memberShopAreas), memberShopAreas: initMemberShopArea(data.memberShopAreas),
workshopPics: data.workshopPics || [], workshopPics: data.workshopPics || [],
honorPics: data.honorPics || [] honorPics: data.honorPics || []
}) })
} }
}) })
} }
const initMemberShopArea = (data) => { const initMemberShopArea = (data) => {
if (!isEmpty(data)) { if (!isEmpty(data)) {
return data.map((item, index) => { return data.map((item, index) => {
item.index = index item.index = index
return item return item
}) })
} else { } else {
return [defaultCityData] return [defaultCityData]
} }
} }
const handleAddNewCitySelect = (item: any) => { const handleAddNewCitySelect = (item: any) => {
const temp = [...selectCityData] const temp = [...selectCityData]
temp.push(item) temp.push(item)
setSelectCityData(temp) setSelectCityData(temp)
form.setFieldsValue({ form.setFieldsValue({
memberShopAreas: temp memberShopAreas: temp
}) })
} }
const handleReduceCitySelect = (index: number) => { const handleReduceCitySelect = (index: number) => {
let temp = JSON.parse(JSON.stringify(selectCityData)) let temp = JSON.parse(JSON.stringify(selectCityData))
temp = temp.filter((item: any) => item.index !== index) temp = temp.filter((item: any) => item.index !== index)
setSelectCityData(temp) setSelectCityData(temp)
form.setFieldsValue({ form.setFieldsValue({
memberShopAreas: temp memberShopAreas: temp
}) })
} }
const handleCityChange = (data: any) => { const handleCityChange = (data: any) => {
setSelectCityData(data) setSelectCityData(data)
form.setFieldsValue({ form.setFieldsValue({
memberShopAreas: data memberShopAreas: data
}) })
} }
const handleDeleteWorkShopImgItem = (itemInfo: any) => { const handleDeleteWorkShopImgItem = (itemInfo: any) => {
let result = [...workshopPics] let result = [...workshopPics]
result = result.filter(item => item !== itemInfo) result = result.filter(item => item !== itemInfo)
setWorkshopPics(result) setWorkshopPics(result)
form.setFieldsValue({ form.setFieldsValue({
workshopPics: result workshopPics: result
}) })
} }
const handleDeleteHonorPicsItem = (itemInfo: any) => { const handleDeleteHonorPicsItem = (itemInfo: any) => {
let result = [...honorPics] let result = [...honorPics]
result = result.filter(item => item !== itemInfo) result = result.filter(item => item !== itemInfo)
setHonorPics(result) setHonorPics(result)
form.setFieldsValue({ form.setFieldsValue({
honorPics: result honorPics: result
}) })
} }
const handleSave = (e: any) => { const handleSave = (e: any) => {
e.preventDefault() e.preventDefault()
form.validateFields().then((value: any) => { form.validateFields().then((value: any) => {
if (!checkMemberShopAreas(value.memberShopAreas)) { if (!checkMemberShopAreas(value.memberShopAreas)) {
return return
} }
if (!shopId) { if (!shopId) {
message.error("店铺链接不能为空") message.error("店铺链接不能为空")
return return
} }
value.storeUrl = storeUrl || `${siteUrl}/shop` value.storeUrl = storeUrl || `${siteUrl}/shop`
value.shopId = shopId value.shopId = shopId
PublicApi.postTemplateShopSaveShop(value).then(res => { PublicApi.postTemplateWebMemberShopWebSaveCurrMemberShop(value).then(res => {
if (res.code === 1000) { if (res.code === 1000) {
fetchShopInfo() fetchShopInfo()
setFormIsHalfFilledOut(false) setFormIsHalfFilledOut(false)
} }
}) })
}) })
} }
const checkMemberShopAreas = (shopAreas) => { const checkMemberShopAreas = (shopAreas) => {
if (isEmpty(shopAreas)) { if (isEmpty(shopAreas)) {
message.destroy() message.destroy()
message.error('请选择归属地市') message.error('请选择归属地市')
return false return false
} }
return shopAreas.every(item => { return shopAreas.every(item => {
if (!item.provinceCode) { if (!item.provinceCode) {
message.destroy() message.destroy()
message.error('请选择归属地市') message.error('请选择归属地市')
return false return false
} else { } else {
return true return true
} }
}) })
} }
const handleCopyLinke = (link: string) => { const handleCopyLinke = (link: string) => {
if (copy(link)) { if (copy(link)) {
message.success('复制成功!') message.success('复制成功!')
} }
} }
/** /**
* 添加厂房照片 * 添加厂房照片
* @param url * @param url
*/ */
const handleAddworkshopPics = (url: string) => { const handleAddworkshopPics = (url: string) => {
setWorkshopPics([...workshopPics, url]) setWorkshopPics([...workshopPics, url])
form.setFieldsValue({ form.setFieldsValue({
workshopPics: [...workshopPics, url] workshopPics: [...workshopPics, url]
}) })
} }
/** /**
* 添加荣誉图片 * 添加荣誉图片
* @param url * @param url
*/ */
const handleAddhonorPics = (url: string) => { const handleAddhonorPics = (url: string) => {
setHonorPics([...honorPics, url]) setHonorPics([...honorPics, url])
form.setFieldsValue({ form.setFieldsValue({
honorPics: [...honorPics, url] honorPics: [...honorPics, url]
}) })
} }
const handleMallSelectChange = (mallId: number) => { const handleMallSelectChange = (mallId: number) => {
// let selectItem = allMallList.filter(item => item.id === mallId) // let selectItem = allMallList.filter(item => item.id === mallId)
setShopId(mallId) setShopId(mallId)
if (!shopInfo) { if (!shopInfo) {
return null return null
} }
if (shopInfo.shopId && shopInfo.memberId) { if (shopInfo.shopId && shopInfo.memberId) {
const resUrl = getMallItemAndSetUrl(mallId) const resUrl = getMallItemAndSetUrl(mallId)
setStoreUrl(resUrl) setStoreUrl(resUrl)
} else { } else {
setStoreUrl(null) setStoreUrl(null)
} }
} }
const getMallItemAndSetUrl = (mallId) => { const getMallItemAndSetUrl = (mallId) => {
let result = "" let result = ""
const mallItem = allMallList.filter(item => item.id === mallId)[0] const mallItem = allMallList.filter(item => item.id === mallId)[0]
if (!mallItem) { if (!mallItem) {
return "" return ""
} }
if (mallItem.environment === 1) { if (mallItem.environment === 1) {
let newSiteUrl = siteUrl let newSiteUrl = siteUrl
if (newSiteUrl.indexOf('http') < 0) { if (newSiteUrl.indexOf('http') < 0) {
newSiteUrl = `http://` + newSiteUrl newSiteUrl = `http://` + newSiteUrl
} }
switch (mallItem.type) { switch (mallItem.type) {
case 1: case 1:
result = `${newSiteUrl}/shop?shopId=${btoa(JSON.stringify({ shopId: shopInfo.id, memberId: shopInfo.memberId, roleId: shopInfo.roleId }))}` result = `${newSiteUrl}/shop?shopId=${btoa(JSON.stringify({ shopId: shopInfo.id, memberId: shopInfo.memberId, roleId: shopInfo.roleId }))}`
break break
case 2: case 2:
result = `${newSiteUrl}/shop/pointsMall?shopId=${btoa(JSON.stringify({ shopId: shopInfo.id, memberId: shopInfo.memberId, roleId: shopInfo.roleId }))}` result = `${newSiteUrl}/shop/pointsMall?shopId=${btoa(JSON.stringify({ shopId: shopInfo.id, memberId: shopInfo.memberId, roleId: shopInfo.roleId }))}`
break break
default: default:
result = "" result = ""
break break
} }
} else { } else {
result = "" result = ""
} }
return result return result
} }
const handleFormValueChange = () => { const handleFormValueChange = () => {
setFormIsHalfFilledOut(true) setFormIsHalfFilledOut(true)
} }
const getSelectMallStoreUrl = () => { const getSelectMallStoreUrl = () => {
if (!shopInfo) { if (!shopInfo) {
return null return null
} }
if (shopId && shopInfo.shopId && shopInfo.memberId) { if (shopId && shopInfo.shopId && shopInfo.memberId) {
const resUrl = getMallItemAndSetUrl(shopId) const resUrl = getMallItemAndSetUrl(shopId)
return resUrl ? ( return resUrl ? (
<div className={styles.shop_url}> <div className={styles.shop_url}>
<span>当前店铺链接:</span> <span>当前店铺链接:</span>
<label>{resUrl}</label> <label>{resUrl}</label>
<CopyOutlined className={styles.copy_icon} onClick={() => handleCopyLinke(resUrl)} /> <CopyOutlined className={styles.copy_icon} onClick={() => handleCopyLinke(resUrl)} />
</div> </div>
) : null ) : null
} }
return null return null
} }
return ( return (
<PageHeaderWrapper> <PageHeaderWrapper>
<Prompt when={formIsHalfFilledOut} message="您还有未保存的内容,是否确定要离开?" /> <Prompt when={formIsHalfFilledOut} message="您还有未保存的内容,是否确定要离开?" />
<div className={styles.shop_info}> <div className={styles.shop_info}>
<Form <Form
form={form} form={form}
className={styles.add_template_form} className={styles.add_template_form}
hideRequiredMark={true} hideRequiredMark={true}
onValuesChange={handleFormValueChange} onValuesChange={handleFormValueChange}
> >
<Form.Item <Form.Item
labelAlign="left" labelAlign="left"
name="memberShopAreas" name="memberShopAreas"
label={<RequireItem label="归属地市" isRequire={true} />} label={<RequireItem label="归属地市" isRequire={true} />}
rules={[{ required: true, message: "请选择归属地市" }]} rules={[{ required: true, message: "请选择归属地市" }]}
> >
<CitySelect <CitySelect
selectData={selectCityData} selectData={selectCityData}
onAdd={handleAddNewCitySelect} onAdd={handleAddNewCitySelect}
onReduce={handleReduceCitySelect} onReduce={handleReduceCitySelect}
onChange={handleCityChange} onChange={handleCityChange}
/> />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
labelAlign="left" labelAlign="left"
name="logo" name="logo"
label={<RequireItem label="公司LOGO" isRequire={true} />} label={<RequireItem label="公司LOGO" isRequire={true} />}
rules={[{ required: true, message: "请上传公司LOGO" }]} rules={[{ required: true, message: "请上传公司LOGO" }]}
> >
<UploadImage <UploadImage
imgUrl={logo} imgUrl={logo}
fileMaxSize={50} fileMaxSize={50}
size="275*50" size="275*50"
onChange={(val) => { onChange={(val) => {
setLogo(val) setLogo(val)
form.setFieldsValue({ form.setFieldsValue({
logo: val logo: val
}) })
}} }}
/> />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
labelAlign="left" labelAlign="left"
name="describe" name="describe"
label={<RequireItem label="公司简介" isRequire={true} />} label={<RequireItem label="公司简介" isRequire={true} />}
rules={[{ required: true, message: "请输入公司简介" }]} rules={[{ required: true, message: "请输入公司简介" }]}
> >
<Input.TextArea allowClear rows={5} className={styles.form_item} placeholder="请输入公司简介" maxLength={200} /> <Input.TextArea rows={5} className={styles.form_item} placeholder="请输入公司简介" maxLength={200} />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
labelAlign="left" labelAlign="left"
name="workshopPics" name="workshopPics"
label={<RequireItem label="厂房照片" />} label={<RequireItem label="厂房照片" />}
> >
<div className={styles.form_item_wrap}> <div className={styles.form_item_wrap}>
<div className={styles.img_list}> <div className={styles.img_list}>
{ {
workshopPics.map((item, index) => ( workshopPics.map((item, index) => (
<div key={index} className={cx(styles.upload_btn, styles.large, styles.upload)}> <div key={index} className={cx(styles.upload_btn, styles.large, styles.upload)}>
<div className={styles.delete_btn} onClick={() => handleDeleteWorkShopImgItem(item)}><DeleteOutlined /></div> <div className={styles.delete_btn} onClick={() => handleDeleteWorkShopImgItem(item)}><DeleteOutlined /></div>
<div className={styles.upload_img} style={{ backgroundImage: `url(${item})` }} /> <div className={styles.upload_img} style={{ backgroundImage: `url(${item})` }} />
</div> </div>
)) ))
} }
<UploadImage
</div> imgUrl={""}
<UploadImage large={true}
imgUrl={""} fileMaxSize={100}
large={true} size="600x400"
fileMaxSize={100} onChange={(url) => handleAddworkshopPics(url)}
size="600x400" />
onChange={(url) => handleAddworkshopPics(url)} </div>
/> </div>
</div> </Form.Item>
</Form.Item> <Form.Item
<Form.Item labelAlign="left"
labelAlign="left" name="honorPics"
name="honorPics" label={<RequireItem label="资质荣誉" brief={<Tooltip placement="top" title="如商标注册证书、品牌授权证书等证明材料"><QuestionCircleOutlined /></Tooltip>} />}
label={<RequireItem label="资质荣誉" brief={<Tooltip placement="top" title="如商标注册证书、品牌授权证书等证明材料"><QuestionCircleOutlined /></Tooltip>} />} >
> <div className={styles.form_item_wrap}>
<div className={styles.form_item_wrap}> <div className={styles.img_list}>
<div className={styles.img_list}> {
{ honorPics.map((item, index) => (
honorPics.map((item, index) => ( <div key={index} className={cx(styles.upload_btn, styles.large, styles.upload)}>
<div key={index} className={cx(styles.upload_btn, styles.large, styles.upload)}> <div className={styles.delete_btn} onClick={() => handleDeleteHonorPicsItem(item)}><DeleteOutlined /></div>
<div className={styles.delete_btn} onClick={() => handleDeleteHonorPicsItem(item)}><DeleteOutlined /></div> <img className={styles.upload_img} src={item} />
<img className={styles.upload_img} src={item} /> </div>
</div> ))
)) }
} <UploadImage
imgUrl={""}
</div> large={true}
<UploadImage fileMaxSize={100}
imgUrl={""} size="106x107"
large={true} onChange={(url) => handleAddhonorPics(url)}
fileMaxSize={100} />
size="106x107" </div>
onChange={(url) => handleAddhonorPics(url)} </div>
/> </Form.Item>
</div> <Form.Item
</Form.Item> labelAlign="left"
<Form.Item name="shopId"
labelAlign="left" label={<RequireItem label="店铺链接" />}
name="shopId" // rules={[{ required: true, message: "请输入客服链接" }]}
label={<RequireItem label="店铺链接" />} >
// rules={[{ required: true, message: "请输入客服链接" }]} <Select allowClear value={shopId} className={styles.form_item} onChange={handleMallSelectChange}>
> {
<Select allowClear value={shopId} className={styles.form_item} onChange={handleMallSelectChange}> allMallList.map(item => (
{ <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
allMallList.map(item => ( ))
<Select.Option key={item.id} value={item.id}>{item.name}</Select.Option> }
)) </Select>
} {
</Select> getSelectMallStoreUrl()
{ }
getSelectMallStoreUrl() </Form.Item>
} <Form.Item
</Form.Item> labelAlign="left"
<Form.Item name="customerUrl"
labelAlign="left" label={<RequireItem label="客服链接" />}
name="customerUrl" rules={[{ pattern: /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/, message: '请输入正确的客服链接' }]}
label={<RequireItem label="客服链接" />} >
rules={[{ pattern: /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/, message: '请输入正确的客服链接' }]} <Input allowClear className={styles.form_item} />
> </Form.Item>
<Input allowClear className={styles.form_item} /> <Form.Item
</Form.Item> label={<RequireItem label="" />}
<Form.Item >
label={<RequireItem label="" />} <Button type="primary" style={{ marginRight: 16 }} onClick={handleSave}>保存</Button>
> </Form.Item>
<Button type="primary" style={{ marginRight: 16 }} onClick={handleSave}>保存</Button> </Form>
</Form.Item> </div>
</Form> </PageHeaderWrapper>
</div> )
</PageHeaderWrapper> }
)
} export default inject('SiteStore')(ShopInfo)
export default inject('SiteStore')(ShopInfo)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment