Commit 98587de9 authored by GuanHua's avatar GuanHua

feat:商品详情接口对接

parent 11e7af7d
...@@ -210,6 +210,9 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -210,6 +210,9 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
const handleMallSelectChange = (mallId: number) => { const handleMallSelectChange = (mallId: number) => {
setShopId(mallId) setShopId(mallId)
if (!shopInfo) {
return
}
if (shopInfo.shopId && shopInfo.memberId) { if (shopInfo.shopId && shopInfo.memberId) {
let resUrl = getMallItemAndSetUrl(mallId) let resUrl = getMallItemAndSetUrl(mallId)
setStoreUrl(resUrl) setStoreUrl(resUrl)
...@@ -219,8 +222,12 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -219,8 +222,12 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
} }
const getMallItemAndSetUrl = (mallId) => { const getMallItemAndSetUrl = (mallId) => {
let result = "" let result = ""
let mallItem = allMallList.filter(item => item.id === mallId)[0] let mallItem = allMallList.filter(item => item.id === mallId)[0]
if (!mallItem) {
return ""
}
if (mallItem.environment === 1) { if (mallItem.environment === 1) {
switch (mallItem.type) { switch (mallItem.type) {
case 3: case 3:
...@@ -247,6 +254,9 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -247,6 +254,9 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
} }
const getSelectMallStoreUrl = () => { const getSelectMallStoreUrl = () => {
if (!shopInfo) {
return null
}
if (shopId && shopInfo.shopId && shopInfo.memberId) { if (shopId && shopInfo.shopId && shopInfo.memberId) {
let resUrl = getMallItemAndSetUrl(shopId) let resUrl = getMallItemAndSetUrl(shopId)
return resUrl ? ( return resUrl ? (
......
...@@ -104,6 +104,10 @@ const CategoryRecommendSetting: React.FC<CategoryRecommendSettingPropsType> = (p ...@@ -104,6 +104,10 @@ const CategoryRecommendSetting: React.FC<CategoryRecommendSettingPropsType> = (p
reject() reject()
return return
} }
if (selectKeys.length > 4) {
message.error('最多推荐4个二级品类')
return
}
let param = { let param = {
templateId: templateid, templateId: templateid,
categoryId: categoryid, categoryId: categoryid,
......
...@@ -153,6 +153,9 @@ const GoodsSetting: React.FC<GoodsSettingPropsType> = (props) => { ...@@ -153,6 +153,9 @@ const GoodsSetting: React.FC<GoodsSettingPropsType> = (props) => {
if (selectGoodsList.length <= 0) { if (selectGoodsList.length <= 0) {
message.error("请选择要推荐的商品") message.error("请选择要推荐的商品")
return return
} else if (selectGoodsList.length > 10) {
message.error("最多只能推荐10件商品")
return
} }
setConfirmLoading(true) setConfirmLoading(true)
saveGoods().then(() => { saveGoods().then(() => {
......
...@@ -62,7 +62,7 @@ const PropsSettings: React.FC<PropsSettingsPropsType> = (props) => { ...@@ -62,7 +62,7 @@ const PropsSettings: React.FC<PropsSettingsPropsType> = (props) => {
return ( return (
<Drawer <Drawer
// maskClosable={false} maskClosable={false}
title={drawerTitle} title={drawerTitle}
placement="right" placement="right"
onClose={onClose} onClose={onClose}
......
...@@ -15,10 +15,12 @@ import ProductDescription from './components/ProductDescription' ...@@ -15,10 +15,12 @@ import ProductDescription from './components/ProductDescription'
import InputNumber from '@/components/InputNumber' import InputNumber from '@/components/InputNumber'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import { GetSearchShopStoreGetCommodityDetailResponse } from '@/services/SearchApi' import { GetSearchShopStoreGetCommodityDetailResponse } from '@/services/SearchApi'
import { getAuth } from '@/utils/auth'
import { numFormat, priceFormat } from '@/utils/numberFomat' import { numFormat, priceFormat } from '@/utils/numberFomat'
import jinhuodanIcon from '@/assets/imgs/jinhuodan.png' import jinhuodanIcon from '@/assets/imgs/jinhuodan.png'
import styles from './index.less' import styles from './index.less'
import { isEmpty } from 'lodash' import { isEmpty } from 'lodash'
import { LAYOUT_TYPE } from '@/constants'
enum COMMODITY_TYPE { enum COMMODITY_TYPE {
/** /**
...@@ -53,8 +55,7 @@ interface imgItemType { ...@@ -53,8 +55,7 @@ interface imgItemType {
const CommodityDetail = (props) => { const CommodityDetail = (props) => {
const { query: { id } } = props.location const { query: { id } } = props.location
const { shopInfo = {} } = props const { shopInfo = {}, layoutType, memberId } = props
const OrderStore = useLocalStore(() => store.OrderStore) const OrderStore = useLocalStore(() => store.OrderStore)
const { updateOrderInfo } = OrderStore const { updateOrderInfo } = OrderStore
const [addSuccessVisible, setAddSuccessVisible] = useState<boolean>(false) const [addSuccessVisible, setAddSuccessVisible] = useState<boolean>(false)
...@@ -80,12 +81,24 @@ const CommodityDetail = (props) => { ...@@ -80,12 +81,24 @@ const CommodityDetail = (props) => {
* 获取商品详情 * 获取商品详情
*/ */
const fetchDetail = () => { const fetchDetail = () => {
PublicApi.getSearchShopStoreGetCommodityDetail({ commodityId: id }).then(res => { let getDetailFn
let params: any = {
commodityId: id
}
if (layoutType === LAYOUT_TYPE.channel) {
params.channelMemberId = memberId
getDetailFn = PublicApi.getSearchShopChannelGetCommodityDetail
} else {
getDetailFn = PublicApi.getSearchShopStoreGetCommodityDetail
}
getDetailFn(params).then(res => {
if (res.code === 1000) { if (res.code === 1000) {
setCommodityDetail(res.data) setCommodityDetail(res.data)
initAttributeAndValueList(res.data) initAttributeAndValueList(res.data)
getPayWayListByMemberId(res.data?.memberId) getPayWayListByMemberId(res.data?.memberId)
res.data?.isMemberPrice && getMemberCredit(res.data?.memberId, res.data?.memberRoleId) if (getAuth() && res.data?.isMemberPrice) {
getMemberCredit(res.data?.memberId, res.data?.memberRoleId)
}
} }
}) })
} }
......
...@@ -209,6 +209,9 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -209,6 +209,9 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
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) {
return null
}
if (shopInfo.shopId && shopInfo.memberId) { if (shopInfo.shopId && shopInfo.memberId) {
let resUrl = getMallItemAndSetUrl(mallId) let resUrl = getMallItemAndSetUrl(mallId)
setStoreUrl(resUrl) setStoreUrl(resUrl)
...@@ -219,7 +222,11 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -219,7 +222,11 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
const getMallItemAndSetUrl = (mallId) => { const getMallItemAndSetUrl = (mallId) => {
let result = "" let result = ""
console.log(mallId, allMallList, "mallId")
let mallItem = allMallList.filter(item => item.id === mallId)[0] let mallItem = allMallList.filter(item => item.id === mallId)[0]
if (!mallItem) {
return ""
}
if (mallItem.environment === 1) { if (mallItem.environment === 1) {
switch (mallItem.type) { switch (mallItem.type) {
case 1: case 1:
...@@ -243,6 +250,9 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -243,6 +250,9 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
} }
const getSelectMallStoreUrl = () => { const getSelectMallStoreUrl = () => {
if (!shopInfo) {
return null
}
if (shopId && shopInfo.shopId && shopInfo.memberId) { if (shopId && shopInfo.shopId && shopInfo.memberId) {
let resUrl = getMallItemAndSetUrl(shopId) let resUrl = getMallItemAndSetUrl(shopId)
return resUrl ? ( return resUrl ? (
......
...@@ -24,11 +24,10 @@ const LoginWrap: React.FC = () => { ...@@ -24,11 +24,10 @@ const LoginWrap: React.FC = () => {
setRouters(data.urls) setRouters(data.urls)
// 此处需使用href跳转, 否则无法触发app.ts中的路由初始化校验 // 此处需使用href跳转, 否则无法触发app.ts中的路由初始化校验
if (redirect) { if (redirect) {
window.location.href = decodeURIComponent(atob(redirect)) window.location.replace(decodeURIComponent(atob(redirect)))
} else { } else {
window.location.href = '/memberCenter/home' window.location.replace('/memberCenter/home')
} }
} }
}) })
} }
......
...@@ -116,8 +116,9 @@ class ApiRequest { ...@@ -116,8 +116,9 @@ class ApiRequest {
baseRequest<IRequestSuccess<T>>(url, options).then(res => { baseRequest<IRequestSuccess<T>>(url, options).then(res => {
// 登录验证 // 登录验证
if (res.code === 1101) { if (res.code === 1101) {
removeAuth()
// history.replace(`/user/login?redirect=${btoa(encodeURIComponent(String(window.location)))}`) // history.replace(`/user/login?redirect=${btoa(encodeURIComponent(String(window.location)))}`)
removeAuth()
window.location.replace(`/user/login?redirect=${btoa(encodeURIComponent(String(window.location)))}`) window.location.replace(`/user/login?redirect=${btoa(encodeURIComponent(String(window.location)))}`)
message.destroy() message.destroy()
message.error(res.message) message.error(res.message)
......
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