Commit 732d77dc authored by GuanHua's avatar GuanHua

feat:店铺收藏接口对接

parent 2229a998
...@@ -120,6 +120,15 @@ ...@@ -120,6 +120,15 @@
text-align: center; text-align: center;
cursor: pointer; cursor: pointer;
&.active {
background-color: var(--mall_main_color);
color: #FFFFFF;
&:hover {
background-color: var(--mall_main_color);
}
}
&>a { &>a {
display: block; display: block;
color: #303133; color: #303133;
......
import React, { useState } from 'react' import React, { useState } from 'react'
import { Rate, Button } from 'antd' import { Rate, Button, message } from 'antd'
import { Link } from 'umi' import { Link } from 'umi'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import shop_icon from '@/assets/imgs/shop_icon.png' import shop_icon from '@/assets/imgs/shop_icon.png'
import credit_icon from '@/assets/imgs/credit_icon.png' import credit_icon from '@/assets/imgs/credit_icon.png'
import cx from 'classnames'
import styles from './index.less' import styles from './index.less'
interface ShopInfoPropsType { interface ShopInfoPropsType {
shopInfo: any; shopInfo: any;
shopUrlParam: string; shopUrlParam: string;
updateShopInfo: Function
} }
const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
const { shopInfo, shopUrlParam } = props const { shopInfo, shopUrlParam, updateShopInfo } = props
const [applyLoading, setApplyLoading] = useState<boolean>(false) const [applyLoading, setApplyLoading] = useState<boolean>(false)
const [collectState, setCollectState] = useState<boolean>(shopInfo?.collectStatus || false)
const applyFroVip = () => { const applyFroVip = () => {
if (shopInfo) { if (shopInfo) {
...@@ -32,13 +35,22 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -32,13 +35,22 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
} }
const handleCollect = () => { const handleCollect = () => {
let status = !collectState
let param = { let param = {
shopId: shopInfo.shopId, shopId: shopInfo.id,
status: true status
} }
PublicApi.postTemplateShopCollect(param).then(res => { PublicApi.postTemplateShopCollect(param).then(res => {
if (res.code === 1000) { if (res.code === 1000) {
updateShopInfo()
message.destroy()
if (status) {
message.success("收藏成功")
setCollectState(true)
} else {
message.success("取消收藏成功")
setCollectState(false)
}
} }
}) })
} }
...@@ -83,7 +95,7 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -83,7 +95,7 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
<div className={styles.dashed_split}></div> <div className={styles.dashed_split}></div>
<div className={styles.shop_info_btn_group}> <div className={styles.shop_info_btn_group}>
<div className={styles.shop_info_btn}><Link to={`/shop?shopId=${shopUrlParam}`}>进入店铺</Link></div> <div className={styles.shop_info_btn}><Link to={`/shop?shopId=${shopUrlParam}`}>进入店铺</Link></div>
<div className={styles.shop_info_btn} onClick={() => handleCollect()}>收藏本店</div> <div className={cx(styles.shop_info_btn, collectState ? styles.active : '')} onClick={() => handleCollect()}>{collectState ? '已收藏本店' : '收藏本店'}</div>
</div> </div>
<Button loading={applyLoading} className={styles.apply_member_btn} onClick={() => applyFroVip()}>申请成为本店会员</Button> <Button loading={applyLoading} className={styles.apply_member_btn} onClick={() => applyFroVip()}>申请成为本店会员</Button>
</div> </div>
......
...@@ -810,7 +810,9 @@ const CommodityDetail = (props) => { ...@@ -810,7 +810,9 @@ const CommodityDetail = (props) => {
</div> </div>
<div className={styles.commodity_detail_body}> <div className={styles.commodity_detail_body}>
<div className={styles.commodity_detail_body_left}> <div className={styles.commodity_detail_body_left}>
<ShopInfo {...props} /> {
layoutType === LAYOUT_TYPE.shop && <ShopInfo {...props} />
}
<Interested priceType={commodityDetail?.priceType} /> <Interested priceType={commodityDetail?.priceType} />
</div> </div>
<div className={styles.commodity_detail_body_right}> <div className={styles.commodity_detail_body_right}>
......
...@@ -245,6 +245,15 @@ ...@@ -245,6 +245,15 @@
text-align: center; text-align: center;
cursor: pointer; cursor: pointer;
&.active {
background-color: var(--mall_main_color);
color: #FFFFFF;
&:hover {
background-color: var(--mall_main_color);
}
}
&:hover { &:hover {
background-color: #F4F5F7; background-color: #F4F5F7;
} }
......
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import { CaretDownOutlined } from '@ant-design/icons' import { CaretDownOutlined } from '@ant-design/icons'
import { Rate, Input, Button } from 'antd' import { Rate, Input, Button, message } from 'antd'
import { history, Link } from 'umi' import { history, Link } from 'umi'
import isEmpty from 'lodash/isEmpty' import isEmpty from 'lodash/isEmpty'
import shop_icon from '@/assets/imgs/shop_icon.png' import shop_icon from '@/assets/imgs/shop_icon.png'
import credit_icon from '@/assets/imgs/credit_icon.png' import credit_icon from '@/assets/imgs/credit_icon.png'
import styles from './index.less' import styles from './index.less'
import cx from 'classnames'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
interface ShopHeaderPropsType { interface ShopHeaderPropsType {
...@@ -13,12 +14,14 @@ interface ShopHeaderPropsType { ...@@ -13,12 +14,14 @@ interface ShopHeaderPropsType {
shopUrlParam: string; shopUrlParam: string;
shopInfo: any; shopInfo: any;
logo: string; logo: string;
updateShopInfo: Function
} }
const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => { const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => {
const { shopId, shopUrlParam, shopInfo, logo } = props const { updateShopInfo, shopUrlParam, shopInfo, logo } = props
const [searchValue, setSearchValue] = useState<string>("") const [searchValue, setSearchValue] = useState<string>("")
const [applyLoading, setApplyLoading] = useState<boolean>(false) const [applyLoading, setApplyLoading] = useState<boolean>(false)
const [collectState, setCollectState] = useState<boolean>(shopInfo?.collectStatus || false)
const { search } = history.location.query const { search } = history.location.query
useEffect(() => { useEffect(() => {
...@@ -53,7 +56,26 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => { ...@@ -53,7 +56,26 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => {
} }
} }
const handleCollect = () => {
let status = !collectState
let param = {
shopId: shopInfo.id,
status
}
PublicApi.postTemplateShopCollect(param).then(res => {
if (res.code === 1000) {
updateShopInfo()
message.destroy()
if (status) {
message.success("收藏成功")
setCollectState(true)
} else {
message.success("取消收藏成功")
setCollectState(false)
}
}
})
}
return ( return (
<div className={styles.shop_header}> <div className={styles.shop_header}>
...@@ -110,7 +132,7 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => { ...@@ -110,7 +132,7 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => {
<div className={styles.dashed_split}></div> <div className={styles.dashed_split}></div>
<div className={styles.shop_info_btn_group}> <div className={styles.shop_info_btn_group}>
<div className={styles.shop_info_btn}><Link to={`/shop?shopId=${shopUrlParam}`}>进入店铺</Link></div> <div className={styles.shop_info_btn}><Link to={`/shop?shopId=${shopUrlParam}`}>进入店铺</Link></div>
<div className={styles.shop_info_btn}>收藏本店</div> <div className={cx(styles.shop_info_btn, collectState ? styles.active : '')} onClick={() => handleCollect()}>{collectState ? '已收藏本店' : '收藏本店'}</div>
</div> </div>
<Button loading={applyLoading} className={styles.apply_member_btn} onClick={() => applyFroVip()}>申请成为本店会员</Button> <Button loading={applyLoading} className={styles.apply_member_btn} onClick={() => applyFroVip()}>申请成为本店会员</Button>
</div> </div>
......
...@@ -80,6 +80,10 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -80,6 +80,10 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => {
const basicInfo = getMenuData(props.route.routes, { locale: true }, formatMessage) const basicInfo = getMenuData(props.route.routes, { locale: true }, formatMessage)
const menuData = basicInfo.menuData ? basicInfo.menuData.filter(item => !item.redirect) : [] const menuData = basicInfo.menuData ? basicInfo.menuData.filter(item => !item.redirect) : []
const handleUpdate = () => {
fetchShopInfo(query.memberId)
}
return ( return (
<Fragment> <Fragment>
<Helmet> <Helmet>
...@@ -90,7 +94,7 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -90,7 +94,7 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => {
<div className={styles.lxmall_page}> <div className={styles.lxmall_page}>
<TopBar langComponent={<SelectLang />} name={mallInfo.name} type={LAYOUT_TYPE.shop} /> <TopBar langComponent={<SelectLang />} name={mallInfo.name} type={LAYOUT_TYPE.shop} />
<div className={styles.content}> <div className={styles.content}>
<ShopHeader logo={mallInfo.logoUrl} shopId={query.shopId} shopUrlParam={shopId} shopInfo={shopInfo} /> <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} />
{ {
children && React.Children.map(children, (child: any) => { children && React.Children.map(children, (child: any) => {
...@@ -100,7 +104,8 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => { ...@@ -100,7 +104,8 @@ const LXShopLayout: React.FC<LXMallLayoutPropsType> = (props) => {
shopId: query.shopId, shopId: query.shopId,
memberId: query.memberId, memberId: query.memberId,
shopUrlParam: shopId, shopUrlParam: shopId,
shopInfo shopInfo,
updateShopInfo: () => handleUpdate()
}, },
); );
}) })
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
font-size: 12px; font-size: 12px;
color: #303133; color: #303133;
font-weight: 500; font-weight: 500;
cursor: pointer;
} }
&_about { &_about {
......
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import cx from 'classnames' import cx from 'classnames'
import { Rate, Pagination } from 'antd' import { Rate, Pagination, Modal } from 'antd'
import { StarFilled } from '@ant-design/icons' import { StarFilled } from '@ant-design/icons'
import shop_icon from '@/assets/imgs/shop_icon.png' import shop_icon from '@/assets/imgs/shop_icon.png'
import credit_icon from '@/assets/imgs/credit_icon.png' import credit_icon from '@/assets/imgs/credit_icon.png'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import moment from 'moment'
import styles from './index.less' import styles from './index.less'
const Shops: React.FC = () => { const Shops: React.FC = () => {
...@@ -38,6 +39,40 @@ const Shops: React.FC = () => { ...@@ -38,6 +39,40 @@ const Shops: React.FC = () => {
setCurrent(page) setCurrent(page)
} }
const handleCancelCollect = (detail) => {
Modal.confirm({
centered: true,
className: styles.mallComfirm,
content: `是否要取消收藏?`,
onOk: () => {
return new Promise((resolve, reject) => {
let param = {
shopId: detail.id,
status: false
}
PublicApi.postTemplateShopCollect(param).then(res => {
if (res.code === 1000) {
// fetchPurchaseList()
fetchCollectShopList()
resolve()
} else {
reject()
}
}).catch(() => {
reject()
})
})
}
})
}
const linkToDetail = (detail) => {
let el = document.createElement('a')
el.href = `/shop?shopId=${btoa(JSON.stringify({ shopId: detail.id, memberId: detail.memberId }))}`;
el.target = '_blank';
el.click()
}
return ( return (
<> <>
<div className={styles.shops_list}> <div className={styles.shops_list}>
...@@ -47,21 +82,21 @@ const Shops: React.FC = () => { ...@@ -47,21 +82,21 @@ const Shops: React.FC = () => {
<div className={cx(styles.shops_list_item_item, styles.morehalf)}> <div className={cx(styles.shops_list_item_item, styles.morehalf)}>
<div className={styles.shop_header_info}> <div className={styles.shop_header_info}>
<div className={styles.shop_header_info_logo}> <div className={styles.shop_header_info_logo}>
<img src="https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/69f3f329d5a848119dc89029a10acb081600332395671.jpg" /> <img src={item.logo} />
</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} onClick={() => linkToDetail(item)}>
<span>温州市龙昌皮业有限公司</span> <span>{item.memberName}</span>
</div> </div>
<div className={styles.shop_header_info_content_about}> <div className={styles.shop_header_info_content_about}>
<div className={styles.shop_header_info_content_about_item}> <div className={styles.shop_header_info_content_about_item}>
<i className={styles.icon}><img src={shop_icon} /></i> <i className={styles.icon}><img src={shop_icon} /></i>
<span className={styles.red}>2</span> <span className={styles.red}>{item.registerYears}</span>
<span></span> <span></span>
</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>1288</span> <span>{item.integral}</span>
</div> </div>
</div> </div>
...@@ -69,17 +104,17 @@ const Shops: React.FC = () => { ...@@ -69,17 +104,17 @@ const Shops: React.FC = () => {
</div> </div>
</div> </div>
<div className={cx(styles.shops_list_item_item)}> <div className={cx(styles.shops_list_item_item)}>
<i className={cx(styles.level_icon, styles.level3)}></i> {/* <i className={cx(styles.level_icon, styles.level3)}></i> */}
<div className={styles.rate_wrap}> <div className={styles.rate_wrap}>
<span>满意度:</span> <span>满意度:</span>
<Rate disabled defaultValue={2} /> <Rate disabled defaultValue={item.satisfied} />
</div> </div>
</div> </div>
<div className={cx(styles.shops_list_item_item)}> <div className={cx(styles.shops_list_item_item)}>
<span className={styles.date}>2020-10-25 10:58</span> <span className={styles.date}>{moment(item.collectTime).format("YYYY-MM-DD HH:mm")}</span>
</div> </div>
<div className={cx(styles.shops_list_item_item)}> <div className={cx(styles.shops_list_item_item)}>
<div className={cx(styles.collection_state)}> <div className={cx(styles.collection_state)} onClick={() => handleCancelCollect(item)}>
<StarFilled /> <StarFilled />
<label>收藏</label> <label>收藏</label>
</div> </div>
......
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