Commit 6e70c912 authored by GuanHua's avatar GuanHua

feat:店铺收藏

parent 732d77dc
.detail_wrap {
position: relative;
}
\ No newline at end of file
...@@ -4,6 +4,7 @@ import { PageHeaderWrapper } from '@ant-design/pro-layout' ...@@ -4,6 +4,7 @@ import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { history, Helmet } from 'umi' import { history, Helmet } from 'umi'
import { Button } from 'antd' import { Button } from 'antd'
import ReutrnEle from '@/components/ReturnEle' import ReutrnEle from '@/components/ReturnEle'
import styles from './detail.less'
interface OrderDetailProps { interface OrderDetailProps {
location: any, location: any,
...@@ -23,7 +24,6 @@ const OrderDetail: React.FC<OrderDetailProps> = (props) => { ...@@ -23,7 +24,6 @@ const OrderDetail: React.FC<OrderDetailProps> = (props) => {
default: default:
return '' return ''
} }
} }
return ( return (
...@@ -41,8 +41,10 @@ const OrderDetail: React.FC<OrderDetailProps> = (props) => { ...@@ -41,8 +41,10 @@ const OrderDetail: React.FC<OrderDetailProps> = (props) => {
</Button>, </Button>,
]} ]}
> >
OrderDetail <div className={styles.detail_wrap}>
</div>
</PageHeaderWrapper> </PageHeaderWrapper>
</> </>
) )
......
import React, { useState } from 'react' import React, { useState, useEffect } from 'react'
import { Rate, Button, message } 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'
...@@ -16,7 +16,13 @@ interface ShopInfoPropsType { ...@@ -16,7 +16,13 @@ interface ShopInfoPropsType {
const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
const { shopInfo, shopUrlParam, updateShopInfo } = 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 [collectState, setCollectState] = useState<boolean>(false)
useEffect(() => {
if (shopInfo) {
setCollectState(shopInfo.collectStatus)
}
}, [shopInfo])
const applyFroVip = () => { const applyFroVip = () => {
if (shopInfo) { if (shopInfo) {
......
...@@ -21,7 +21,7 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => { ...@@ -21,7 +21,7 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => {
const { updateShopInfo, 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 [collectState, setCollectState] = useState<boolean>(false)
const { search } = history.location.query const { search } = history.location.query
useEffect(() => { useEffect(() => {
...@@ -32,6 +32,12 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => { ...@@ -32,6 +32,12 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => {
} }
}, [search]) }, [search])
useEffect(() => {
if (shopInfo) {
setCollectState(shopInfo.collectStatus)
}
}, [shopInfo])
const handleSearchCommodity = () => { const handleSearchCommodity = () => {
if (!isEmpty(searchValue)) { if (!isEmpty(searchValue)) {
history.push(`/shop/commodity/search?shopId=${shopUrlParam}&search=${encodeURIComponent(searchValue)}`) history.push(`/shop/commodity/search?shopId=${shopUrlParam}&search=${encodeURIComponent(searchValue)}`)
......
...@@ -34,6 +34,15 @@ ...@@ -34,6 +34,15 @@
border: 1px solid #EEF0F3; border: 1px solid #EEF0F3;
cursor: pointer; cursor: pointer;
&.active {
background-color: var(--mall_main_color);
color: #FFFFFF;
&:hover {
background-color: var(--mall_main_color);
}
}
&:hover { &:hover {
opacity: .9; opacity: .9;
} }
......
import React, { useState } from 'react' import React, { useState, useEffect } from 'react'
import { Rate, Button } from 'antd' import { Rate, Button, message } from 'antd'
import { LeftOutlined, RightOutlined } from '@ant-design/icons' import { LeftOutlined, RightOutlined } from '@ant-design/icons'
import cx from 'classnames' import cx from 'classnames'
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 styles from './index.less' import styles from './index.less'
import { LAYOUT_TYPE } from '@/constants'
interface ShopAboutPropType { interface ShopAboutPropType {
shopInfo: any shopInfo: any,
layoutType: LAYOUT_TYPE,
updateShopInfo: Function
} }
const ShopAbout: React.FC<ShopAboutPropType> = (props) => { const ShopAbout: React.FC<ShopAboutPropType> = (props) => {
const { shopInfo } = props const { shopInfo, layoutType, updateShopInfo } = props
const [offSetLeft, setOffSetLeft] = useState<number>(0) const [offSetLeft, setOffSetLeft] = useState<number>(0)
const [applyLoading, setApplyLoading] = useState<boolean>(false) const [applyLoading, setApplyLoading] = useState<boolean>(false)
const [collectState, setCollectState] = useState<boolean>(false)
const unitDistance = 406 const unitDistance = 406
useEffect(() => {
if (shopInfo) {
setCollectState(shopInfo.collectStatus)
}
}, [shopInfo])
const handlePrev = () => { const handlePrev = () => {
if (offSetLeft < 0) { if (offSetLeft < 0) {
setOffSetLeft(offSetLeft + unitDistance) setOffSetLeft(offSetLeft + unitDistance)
...@@ -48,6 +58,27 @@ const ShopAbout: React.FC<ShopAboutPropType> = (props) => { ...@@ -48,6 +58,27 @@ const ShopAbout: React.FC<ShopAboutPropType> = (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_about}> <div className={styles.shop_about}>
<div className={styles.shop_about_container}> <div className={styles.shop_about_container}>
...@@ -72,10 +103,11 @@ const ShopAbout: React.FC<ShopAboutPropType> = (props) => { ...@@ -72,10 +103,11 @@ const ShopAbout: React.FC<ShopAboutPropType> = (props) => {
</div> </div>
<div className={cx(styles.shop_about_info_item)}> <div className={cx(styles.shop_about_info_item)}>
<div className={styles.shop_about_btn_group}> <div className={styles.shop_about_btn_group}>
<div className={styles.shop_about_btn}>收藏本店</div> {
layoutType === LAYOUT_TYPE.shop && <div className={cx(styles.shop_about_btn, collectState ? styles.active : "")} onClick={() => handleCollect()}>{collectState ? '已收藏本店' : '收藏本店'}</div>
}
<Button loading={applyLoading} className={cx(styles.shop_about_btn, styles.primary)} onClick={() => applyFroVip()}>申请成为本店会员</Button> <Button loading={applyLoading} className={cx(styles.shop_about_btn, styles.primary)} onClick={() => applyFroVip()}>申请成为本店会员</Button>
</div> </div>
</div> </div>
<div className={cx(styles.shop_about_info_item, styles.auto_width)}> <div className={cx(styles.shop_about_info_item, styles.auto_width)}>
<i className={styles.shop_about_info_item_character}></i> <i className={styles.shop_about_info_item_character}></i>
......
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