Commit 98587de9 authored by GuanHua's avatar GuanHua

feat:商品详情接口对接

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