Commit 4d0c08ac authored by 前端-钟卫鹏's avatar 前端-钟卫鹏
parents 14a086c9 818b7fdf
......@@ -82,7 +82,7 @@
"god": "0.2.11",
"immutability-helper": "^3.1.1",
"js-cookie": "^2.2.1",
"lingxi-design-ui": "^2.0.17",
"lingxi-design-ui": "^2.0.19",
"lint-staged": "^10.0.7",
"lodash": "^4.17.20",
"mobx": "^5.15.4",
......
......@@ -11,6 +11,10 @@ const FLAG_SIZE = 60
const IMG_WIDTH = 352
const IMG_HEIGHT = 180
// 国家前缀 暂时写死
const prefixCode = '+86'
const Phone = (props) => {
const { value, form, schema } = props
const {text, isActive, start} = useCountDown({
......@@ -18,6 +22,7 @@ const Phone = (props) => {
minTime: 0,
initText: '获取验证码',
onEnd: () => {
instanceRef.current.canIUseSms = false
form.setFieldState('phone', state => {
state.smsLoading = instanceRef.current.canIUseSms
})
......@@ -74,10 +79,43 @@ const Phone = (props) => {
}
}, [isShowValidate, isActive])
const validatePhoneRequest = async () => {
return new Promise(async (resolve, reject) => {
try {
// 这种情况说明是忘记密码, 无需校验手机号
if (!form.getFieldValue('phone') && form.getFieldValue('account')) {
resolve(true)
return ;
}
const { code } = await PublicApi.getMemberRegisterPhoneCheck({
countryCode: prefixCode,
phone: form.getFieldValue('phone')
}, { ctlType: 'none', useCache: true, ttl: 60 * 1000 })
if (code !== 1000) {
form.setFieldState('phone', state => {
state.errors = ['手机号已存在']
resolve(false)
godEvent.emit('SHOW_PHONE_VALIDATE', false)
})
} else {
resolve(true)
}
} catch(err) {
console.log(err)
resolve(false)
}
})
}
const handleClickSms = async () => {
const validateState = await form.validate('phone')
// 注册页手机号字段
const validatePhoneState = await form.validate('phone')
// 忘记密码 手机号或邮箱字段
const validateAccountState = await form.validate('account')
const phoneAsyncValidate = await validatePhoneRequest()
// 手机号未通过校验
if (validateState.errors > 0) {
if (validatePhoneState.errors > 0 || validateAccountState.errors > 0 || !phoneAsyncValidate) {
return false
}
......
......@@ -157,6 +157,21 @@ const OwnMallEdit: React.FC<ShopEditPropsType> = (props) => {
// })
// }
const fetchNewByLabel = (label: string) => {
// 1-头条文章 2-轮播新闻 3-图片新闻 4-推荐阅读
return new Promise((resolve, reject) => {
PublicApi.getManageContentInformationFindAllByRecommendLabel({ recommendLabel: label }).then((res: { code: number; data: unknown }) => {
if (res.code === 1000) {
resolve(res.data);
} else {
reject();
}
}).catch(() => {
reject();
});
});
};
const getComponentsConfig = async () => {
// 导航栏
const navData = await getOwnMallNavData();
......@@ -182,6 +197,9 @@ const OwnMallEdit: React.FC<ShopEditPropsType> = (props) => {
topBarConfig[topBarConfig.key].props.shopname = webMallInfo.name
headerConfig[headerConfig.key].props.logoUrl = webMallInfo.logoUrl
// 行情资讯
InformationConfig[InformationConfig.key].props.newsList = await fetchNewByLabel('4');
// AboutUsConfig[AboutUsConfig.key].props.shopInfo = shopInfo
let initIndex = 100
let floorLineConfig: any = {}
......@@ -236,7 +254,7 @@ const OwnMallEdit: React.FC<ShopEditPropsType> = (props) => {
}
mallLayoutConfig["0"].childNodes = [...mallLayoutConfig["0"].childNodes, ...floorLineKeys, fourBannerConfig.key, FooterConfig.key]
mallLayoutConfig["0"].childNodes = [...mallLayoutConfig["0"].childNodes, ...floorLineKeys, fourBannerConfig.key, InformationConfig.key, FooterConfig.key]
const config = {
...mallLayoutConfig,
...topBarConfig,
......@@ -250,7 +268,7 @@ const OwnMallEdit: React.FC<ShopEditPropsType> = (props) => {
...threeBannerConfig,
...floorLineConfig,
...fourBannerConfig,
// ...InformationConfig,
...InformationConfig,
...FooterConfig
}
setComponentConfigs(config)
......
import React, { useEffect, useState } from 'react'
import { BrickProvider } from '@lingxi-disign/react'
import { message }from 'antd'
import ToolBar from '../components/toolBar'
import PreviewPanel from '../components/PreviewPanel'
import config from '../configs'
import { isEmpty } from 'lodash'
import { LAYOUT_TYPE } from '@/constants'
import {
topBarConfig,
topAdvertConfig,
headerConfig,
mainNavConfig,
bannerWrap,
oneBannerConfig,
bannerColumnWrap,
twoBannerConfig,
threeBannerConfig,
mallLayoutConfig,
fourBannerConfig,
InformationConfig,
FooterConfig,
} from './defaultData'
import { menuData } from './defaultMenu'
import Loading from '../components/Loading'
import { PublicApi } from '@/services/api'
import { GlobalConfig } from '@/global/config'
import { getAuth } from '@/utils/auth'
import styles from './index.less'
interface ShopEditPropsType {
location: {
query: {
/**
* 模板id
*/
id: number;
/**
* 模板名称
*/
template: string;
shopId: number
}
}
}
const TemplateList = ['science']
const OwnMallEdit: React.FC<ShopEditPropsType> = (props) => {
const { query: { id, template, shopId } } = props.location
const [loading, setLoading] = useState<boolean>(true)
const [theme, setTheme] = useState<string>('theme-ownmall-science')
const [componentConfigs, setComponentConfigs] = useState({})
const { memberId, memberRoleId } = getAuth() || {}
useEffect(() => {
if (!TemplateList.includes(template)) {
setTheme(`theme-ownmall-${TemplateList[0]}`)
} else {
setTheme(`theme-ownmall-${template}`)
}
getComponentsConfig()
}, [])
/**
* 获取所有一级品类信息
*/
const fetchFirstCategory = () => {
return new Promise((resolve) => {
const param: any = {
memberId,
roleId: memberRoleId
}
const headers: any = {
shopId
}
PublicApi.getTemplateAdornWebSelfFindAllFirstCategory(param, { headers }).then(res => {
if (res.code === 1000) {
resolve(res.data)
}
})
})
}
/**
* 获取导航栏菜单数据
*/
const getOwnMallNavData = () => {
return new Promise((resolve) => {
const param: any = {
templateId: id,
memberId,
roleId: memberRoleId,
};
PublicApi.getTemplateAdornWebSelfFindColumn(param).then(res => {
if (res.code === 1000) {
resolve(res.data);
}
});
});
};
/**
* 获取一级品类详细信息
*/
const fetchCategoryById = (categoryId) => {
return new Promise((resolve) => {
const param: any = {
templateId: id,
categoryId,
memberId,
roleId: memberRoleId
}
PublicApi.getTemplateAdornWebSelfMemberCategoryAdorn(param).then(res => {
if (res.code === 1000) {
resolve(res.data)
}
})
})
}
const findAdvertsByType = (type: number) => {
return new Promise((resolve) => {
const params: any = {
templateId: id,
type,
memberId,
roleId: memberRoleId
}
PublicApi.getTemplateAdornWebSelfFindAdvertsByType(params).then(res => {
if (res.code === 1000) {
resolve(res.data)
} else {
resolve([])
}
})
})
}
// const getCategoryTree = () => {
// return new Promise((resolve) => {
// const param: any = {
// templateId: id,
// categoryId,
// memberId,
// roleId: memberRoleId
// }
// PublicApi.getTemplateAdornWebSelfMemberCategoryAdorn(param).then(res => {
// if (res.code === 1000) {
// resolve(res.data)
// }
// })
// })
// }
const fetchNewByLabel = (label: string) => {
// 1-头条文章 2-轮播新闻 3-图片新闻 4-推荐阅读
return new Promise((resolve, reject) => {
PublicApi.getManageContentInformationFindAllByRecommendLabel({ recommendLabel: label }).then((res: { code: number; data: unknown }) => {
if (res.code === 1000) {
resolve(res.data);
} else {
reject();
}
}).catch(() => {
reject();
});
});
};
const getComponentsConfig = async () => {
// 导航栏
const navData = await getOwnMallNavData();
if(!isEmpty(navData)) {
mainNavConfig[mainNavConfig.key].props.menuData = navData;
} else {
mainNavConfig[mainNavConfig.key].props.menuData = menuData;
}
mainNavConfig[mainNavConfig.key].props.type = LAYOUT_TYPE.shop
mainNavConfig[mainNavConfig.key].props.categoryList = []
// 一号位广告
oneBannerConfig[oneBannerConfig.key].props.advertList = await findAdvertsByType(1)
// 二号位广告
twoBannerConfig[twoBannerConfig.key].props.advertList = await findAdvertsByType(2)
// 三号位广告
threeBannerConfig[threeBannerConfig.key].props.advertList = await findAdvertsByType(3)
// 四号位广告
fourBannerConfig[fourBannerConfig.key].props.advertList = await findAdvertsByType(4)
//商城信息
const shopList = GlobalConfig.web.shopInfo
const webMallInfo = shopList.filter(item => item.id === Number(shopId))[0]
topBarConfig[topBarConfig.key].props.shopname = webMallInfo.name
headerConfig[headerConfig.key].props.logoUrl = webMallInfo.logoUrl
// 行情资讯
InformationConfig[InformationConfig.key].props.newsList = await fetchNewByLabel('4');
// AboutUsConfig[AboutUsConfig.key].props.shopInfo = shopInfo
let initIndex = 100
let floorLineConfig: any = {}
const floorLineKeys: any = []
const firstCategory: any = await fetchFirstCategory()
for (const item of firstCategory) {
if (item.categoryId ){
const categoryDetail: any = await fetchCategoryById(item.categoryId)
let floorLineConfigItem = {}
floorLineKeys.push(String(initIndex + 1))
const FloorLine = {
[String(initIndex + 1)]: {
"componentName": "ShopFloorLine",
"props": {
title: item.categoryName
},
"childNodes": [String(initIndex + 2), String(initIndex + 3)]
}
}
const Category = {
[String(initIndex + 2)]: {
"componentName": "ShopFloorLine.Category",
"props": {
categoryAdvertPicUrl: categoryDetail.categoryAdvertPicUrl,
categoryid: item.categoryId,
linkdisable: true,
categoryList: categoryDetail.categoryBOList
},
},
}
const Goods = {
[String(initIndex + 3)]: {
"componentName": "ShopFloorLine.Goods",
"props": {
linkdisable: true,
categoryid: item.categoryId,
goodsList: categoryDetail.goodsBOList
},
},
}
floorLineConfigItem = { ...FloorLine, ...Category, ...Goods }
floorLineConfig = { ...floorLineConfig, ...floorLineConfigItem }
initIndex += 100
}
}
mallLayoutConfig["0"].childNodes = [...mallLayoutConfig["0"].childNodes, ...floorLineKeys, fourBannerConfig.key, InformationConfig.key, FooterConfig.key]
const config = {
...mallLayoutConfig,
...topBarConfig,
...topAdvertConfig,
...headerConfig,
...mainNavConfig,
...bannerWrap,
...oneBannerConfig,
...bannerColumnWrap,
...twoBannerConfig,
...threeBannerConfig,
...floorLineConfig,
...fourBannerConfig,
...InformationConfig,
...FooterConfig
}
setComponentConfigs(config)
setLoading(false)
}
return !loading ? (
<BrickProvider
config={config}
warn={(msg: string) => {
message.warning(msg);
}}
>
<div className={styles['wrapper']}>
<ToolBar type={2} title="首页" />
<div className={styles['content']}>
<div className={styles['canvas-container']}>
<PreviewPanel onlyEidt theme={theme} pageConfig={componentConfigs} />
</div>
</div>
</div>
</BrickProvider>
) : <Loading />
}
export default OwnMallEdit
......@@ -43,8 +43,10 @@ const TemplateDetail: React.FC<TemplateDetailPropsType> = (props) => {
*/
const handleConfirmUse = () => {
setConfirmLoading(true)
PublicApi.postTemplateWebPageTemplateWebUseShopTemplate({ id }).then(res => {
const params: any = {
id
}
PublicApi.postTemplateWebPageTemplateWebUseSelfTemplate(params).then(res => {
if (res.code === 1000) {
setUseModalVisible(false)
fetchDetail()
......@@ -124,7 +126,7 @@ const TemplateDetail: React.FC<TemplateDetailPropsType> = (props) => {
</div>
<UseModal
title="使用店铺模板"
title="使用自营商城模板"
visible={useModalVisible}
dataInfo={detailInfo}
confirmLoading={confirmLoading}
......
......@@ -191,7 +191,7 @@ export const GeneralEffect = (int, data) => {
col: [
{
label: '优惠规则', extra: <Space direction='vertical'>
{data.ladderBOList.map(item => (<div>{`满 ${item.discount} 件, 打 ${item.num} 折`}</div>))}
{data.ladderList.map(item => (<div>{`满 ${item.discount} 件, 打 ${item.num} 折`}</div>))}
</Space>
},
{
......
......@@ -13,20 +13,11 @@ const columns_1 = ({
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
const _idx = Number(((current - 1) * 10) + _i);
if (_idx === index) {
return {
..._item,
[name]: Number(value)
}
}
return _item
})
params[index][name] = Number(value);
form.setFieldsValue({
'productList': newData
'productList': params
})
setDataSource(newData)
setDataSource(params)
}
return (
......
......@@ -16,28 +16,16 @@ const columns_2 = ({
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
const _idx = Number(((current - 1) * 10) + _i);
if (_idx === index) {
if (name === 'plummetPrice') {
return {
..._item,
[name]: Number(value),
'activityPrice': sumTotal(_item.price, value)
}
} else {
return {
..._item,
[name]: Number(value)
}
}
}
return _item
})
if(name === 'plummetPrice') {
params[index][name] = Number(value);
params[index]['activityPrice'] = sumTotal(params[index]['price'], value);
} else {
params[index][name] = Number(value);
}
form.setFieldsValue({
'productList': newData
'productList': params
})
setDataSource(newData)
setDataSource(params)
}
return (
......
......@@ -13,29 +13,16 @@ const columns_3 = ({
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
const _idx = Number(((current - 1) * 10) + _i);
if (_idx === index) {
if (name === 'discount') {
return {
..._item,
[name]: Number(value),
'activityPrice': Number(_item.price) * (Number(value)) / 100,
}
} else {
return {
..._item,
[name]: Number(value)
}
}
}
return _item
})
if(name === 'discount') {
params[index][name] = Number(value);
params[index]['activityPrice'] = Number(params[index]['price']) * (Number(value)) / 100;
} else {
params[index][name] = Number(value);
}
form.setFieldsValue({
'productList': newData
'productList': params
})
setDataSource(newData)
setDataSource(params)
}
return (
[
......
......@@ -14,20 +14,11 @@ const columns_4 = ({
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
const _idx = Number(((current - 1) * 10) + _i);
if (_idx === index) {
return {
..._item,
[name]: Number(value)
}
}
return _item
})
params[index][name] = Number(value);
form.setFieldsValue({
'productList': newData
'productList': params
})
setDataSource(newData)
setDataSource(params)
}
return (
[
......
......@@ -12,20 +12,11 @@ const columns_5 = ({
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
const _idx = Number(((current - 1) * 10) + _i);
if (_idx === index) {
return {
..._item,
[name]: Number(value)
}
}
return _item
})
params[index][name] = Number(value);
form.setFieldsValue({
'productList': newData
'productList': params
})
setDataSource(newData)
setDataSource(params)
}
return (
[
......
......@@ -13,20 +13,11 @@ const columns_6 = ({
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
const _idx = Number(((current - 1) * 10) + _i);
if (_idx === index) {
return {
..._item,
[name]: Number(value)
}
}
return _item
})
params[index][name] = Number(value);
form.setFieldsValue({
'productList': newData
'productList': params
})
setDataSource(newData)
setDataSource(params)
}
return (
[
......
......@@ -13,20 +13,11 @@ const columns_7 = ({
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
const _idx = Number(((current - 1) * 10) + _i);
if (_idx === index) {
return {
..._item,
[name]: Number(value)
}
}
return _item
})
params[index][name] = Number(value);
form.setFieldsValue({
'productList': newData
'productList': params
})
setDataSource(newData)
setDataSource(params)
}
return (
......
......@@ -12,20 +12,11 @@ const columns_8 = ({
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
const _idx = Number(((current - 1) * 10) + _i);
if (_idx === index) {
return {
..._item,
[name]: Number(value)
}
}
return _item
})
params[index][name] = Number(value);
form.setFieldsValue({
'productList': newData
'productList': params
})
setDataSource(newData)
setDataSource(params)
}
return (
[
......
......@@ -9,6 +9,7 @@ import CollocationLayout from '@/pages/transaction/marketingAbility/components/c
import { remindLayout, RemindLayoutProps } from '@/pages/transaction/marketingAbility/paltformSign/readySubmitExamine/components/productListLayout/remind';
import CouponsListLayout from '@/pages/transaction/marketingAbility/components/couponsListLayout';
import { number } from 'yargs';
import { PublicApi } from '@/services/api';
type optionProps = {
/** key */
......@@ -185,7 +186,6 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
setDataSource(fields)
}
return (
<CardLayout
id="productListLayout"
......
......@@ -199,6 +199,22 @@ const DetialLayout = () => {
})
}
// useEffect(() => {
// if (!isEmpty(dataSource)) {
// PublicApi.postMarketingPlatformActivitySignupGetFilterSkuId({
// activityType: dataSource.activityType,
// activityDefinedBO: dataSource.activityDefined.allowActivity,
// startTime: dataSource.startTime,
// endTime: dataSource.endTime,
// }, { ctlType: 'none' }).then(res => {
// if (res.code !== 1000) {
// return
// }
// console.log(res.data)
// })
// }
// }, [dataSource])
return (
<Context.Provider value={dataSource}>
<PeripheralLayout
......
......@@ -5,6 +5,7 @@ import CardLayout from '../card';
import style from './index.less';
import { isEmpty } from 'lodash';
import { PublicApi } from '@/services/api';
import { GlobalConfig } from '@/global/config';
type ShopItem = {
describe?: string
......@@ -31,7 +32,7 @@ const ShopLayout: React.FC<shopListProps> = (props: any) => {
const [mallList, setMallList] = useState<ShopItem[]>([]);
useEffect(() => {
PublicApi.getManageShopFindByMemberType().then(res => {
PublicApi.postManageWebShopWebAll({siteId: GlobalConfig.global.siteInfo.id.toString(), hasMemberType: 1}, { ctlType: 'none' }).then(res => {
if (res.code !== 1000) {
return
}
......@@ -69,6 +70,8 @@ const ShopLayout: React.FC<shopListProps> = (props: any) => {
console.log(onSetShopList, mallList)
}, [onSetShopList])
return (
<CardLayout
id="shopLayout"
......
......@@ -59,21 +59,6 @@ const GetBack: React.FC = () => {
})
$('onFieldValidateEnd', 'account').subscribe(fieldState => {
if (fieldState.valid) {
if (PATTERN_MAPS.phone.test(fieldState.value)) {
// 校验手机号格式通过时, 需请求接口判断手机号是否存在数据库
PublicApi.getMemberRegisterPhoneCheck({
countryCode: prefixCode,
phone: fieldState.value
}, { ctlType: 'none', useCache: true, ttl: 60 * 1000 }).then(({ code, data }) => {
message.destroy()
if (code === 1000) {
setFieldState('account', state => {
state.errors = ['手机号不存在, 请检查']
})
}
})
return ;
}
if (PATTERN_MAPS.email.test(fieldState.value)) {
// 校验邮箱格式通过时, 需请求接口判断邮箱是否存在数据库
PublicApi.postMemberRegisterEmailCheck({
......
......@@ -48,24 +48,24 @@ const useLinkageValidateEffects = () => {
})
})
onFieldValidateEnd$('phone').subscribe(fieldState => {
if (fieldState.valid && !fieldState.smsLoading) {
// 校验手机号格式通过时, 需请求接口判断手机号是否存在数据库
PublicApi.getMemberRegisterPhoneCheck({
countryCode: prefixCode,
phone: fieldState.value
}, { ctlType: 'none', useCache: true, ttl: 60 * 1000 }).then(({ code, data }) => {
if (code !== 1000) {
setFieldState('phone', state => {
state.errors = ['手机号已存在']
eventEmitter.emit('SHOW_PHONE_VALIDATE', false)
})
} else {
eventEmitter.emit('SHOW_PHONE_VALIDATE', true)
}
})
} else {
eventEmitter.emit('SHOW_PHONE_VALIDATE', false)
}
// if (fieldState.valid && !fieldState.smsLoading) {
// // 校验手机号格式通过时, 需请求接口判断手机号是否存在数据库
// PublicApi.getMemberRegisterPhoneCheck({
// countryCode: prefixCode,
// phone: fieldState.value
// }, { ctlType: 'none', useCache: true, ttl: 60 * 1000 }).then(({ code, data }) => {
// if (code !== 1000) {
// setFieldState('phone', state => {
// state.errors = ['手机号已存在']
// eventEmitter.emit('SHOW_PHONE_VALIDATE', false)
// })
// } else {
// eventEmitter.emit('SHOW_PHONE_VALIDATE', true)
// }
// })
// } else {
// eventEmitter.emit('SHOW_PHONE_VALIDATE', false)
// }
})
onFieldValueChange$('*(confirmPassword)').subscribe(fieldState => {
const selfValue = fieldState.value
......
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