可视化搭建移动端店铺解决方案

</DecorateContext.Provider>

);

}

}

数据

前面说到与列举的产品有哪些区别,区别在于PC端与移动端的数据交互,它们都是通过 iframe 嵌套 H5 的页面,通过 postmessage API 来做数据交互,而是我没有这样做,原因是项目特别紧,加上人员分配问题,所以采用数据定义模式。

通过上面的设计结构图可以看出PC端最后会生成一份 schema 数据存储服务端,移动端从服务端获取到 schema 数据进行解析。数据格式如下:

// 图片广告

{

component: ‘ImageTextAd’,

options: {

template: ‘image’, // image:一行一个 carousel:轮播海报 slide:大图横向滑动 zone:绘制热区

image: [

{

id: ‘’,

url: ‘’,

title: ‘’,

linkCode: ‘’,

linkName: ‘’,

// 热区

zones: [

{

x: 178,

y: 91,

width: 158,

height: 132,

code: ‘123’,

text: ‘测试链接2’,

}

],

},

{

id: ‘’,

url: ‘’,

title: ‘’,

linkCode: ‘’,

linkName: ‘’,

// 热区

zones: [

{

x: 436,

y: 97,

width: 170,

height: 168,

code: ‘’,

text: ‘’,

}

],

},

],

indicator: ‘dotted’, // 指示器

style: {

boxShadow: ‘none’,

borderRadius: ‘none’,

padding: ‘0’,

},

},

},

// 公告

{

component: ‘Notice’,

options: {

content: ‘公告内容’,

style: {

background: ‘rgb(255, 248, 233)’,

color: ‘rgb(100, 101, 102)’,

},

},

},

// 图文导航

{

component: ‘ImageTextNav’,

options: {

template: ‘image-nav’, // image-nav:图片导航 text-nav:文字导航

images: [{

url: ‘’,

title: ‘’,

link: ‘’,

}],

style: {

background: ‘rgb(255, 248, 233)’,

color: ‘rgb(100, 101, 102)’,

},

},

},

// 标题栏

{

component: ‘Title’,

options: {

style: {

textAlign: ‘left’,

background: ‘#FFFFFF’,

},

title: {

text: ‘’,

style: {

fontSize: ‘16px’,

fontWeight: ‘bold’,

color: ‘#323233’,

},

},

content: {

text: ‘’,

style: {

fontSize: ‘12px’,

fontWeight: ‘400’,

color: ‘#969799’,

},

},

},

},

// 文本模块

{

component: ‘RichText’,

options: {

content: ‘’,

style: {

backgroundColor: ‘#F9F9F9’,

padding: ‘10px 10px 0’,

},

},

},

// 辅助分割

{

component: ‘DivideLine’,

options: {

template: ‘block’, // block:辅助空白 line:辅助线

style: {

height: 30,

// borderTopWidth: ‘1px’,

// borderTopStyle: ‘dashed’,

// borderTopColor: ‘#EBEDF0’,

// margin: ‘10px 0 0’,

},

},

},

// 商品搜索

{

component: ‘GoodSearch’,

options: {

style: {

backgroundColor: ‘#FFFFFF’,

},

box: {

style: {

borderRadius: ‘none’,

textAlign: ‘left’,

height: 28,

backgroundColor: ‘#F7F8FA’,

color: ‘#c8c9cc’,

},

},

},

},

// 左右图文

{

component: ‘LRImageText’,

options: {

template: ‘lr’, // lr:左图右文 rl:左文右图

content: ‘’, // 内容

image: {

url: ‘’, // 图片地址

linkCode: ‘’, // 跳转页面code

linkName: ‘’, // 跳转页面name

style: {

boxShadow: ‘none’,

borderRadius: ‘none’,

},

},

},

},

// 图文导航

{

component: ‘ImageTextNav’,

options: {

template: ‘image’, // image:图片导航 text:文字导航

image: [

{

url: ‘’,

title: ‘导航一’,

linkCode: ‘’,

linkName: ‘’,

},

{

url: ‘’,

title: ‘导航二’,

linkCode: ‘’,

linkName: ‘’,

},

{

url: ‘’,

title: ‘导航三’,

linkCode: ‘’,

linkName: ‘’,

},

{

url: ‘’,

title: ‘导航四’,

linkCode: ‘’,

linkName: ‘’,

},

{

id: uuid(),

url: ‘’,

title: ‘导航五’,

linkCode: ‘’,

linkName: ‘’,

},

],

style: {

backgroundColor: ‘#FFFFFF’,

color: ‘#333333’,

},

},

},

// 魔方

{

component: ‘Cube’,

options: {

template: ‘row-one’, // row-one:一行一个 row-two:一行两个 row-four:一行四个 row-col:一大两小

image: [

{

url: ‘’,

linkType: ‘’,

linkName: ‘’,

},

],

imageMargin: 0,

layoutMargin: 0,

},

},

// 定位菜单

{

component: ‘PositionMenu’,

data: [], // 分组信息

options: {

template: ‘tab-style-one’, // tab-style-one:样式1 tab-style-two:样式2 tab-style-three:样式3

data: [

{

id: ‘9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d’,

code: ‘’,

name: ‘’,

menuName: ‘’,

comsize: 6,

},

{

id: ‘9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6c’,

code: ‘’,

name: ‘’,

menuName: ‘’,

comsize: 6,

},

],

style: {

borderRadius: ‘none’,

fontWeight: ‘400’,

paddingLeft: ‘5px’,

paddingRight: ‘5px’,

},

listStyle: ‘row-one’, // row-one:大图模式 row-two:一行两个 row-three:一行三个 row-col:详细列表

commodityStyle: ‘no-border’, // no-border:无边白底 shadow:卡片投影 stroke:描边白底 transparent:无边透明底

commodityName: true, // 商品名称

commodityDesc: true, // 商品描述

commodityPrice: true, // 商品价格

originalPrice: true, // 划线价格

buyButton: true, // 购买按钮

buyButtonStyle: ‘style-1’, // 购买按钮样式

buyButtonText: ‘马上抢’, // 购买按钮文字

commoditySubscript: true, // 商品角标

commoditySubscriptStyle: ‘new’, // 商品角标样式

},

},

// 普通商品

{

component: ‘Goods’,

data: [], // 商品信息

options: {

template: ‘large’, // large:大图模式 small:一行两个 three:一行三个 list:详细列表

data: [], // 商品信息

style: {

borderRadius: ‘none’,

fontWeight: ‘400’,

paddingLeft: ‘5px’,

paddingRight: ‘5px’,

},

listStyle: ‘row-one’, // row-one:大图模式 row-two:一行两个 row-three:一行三个 row-col:详细列表

commodityStyle: ‘no-border’, // no-border:无边白底 shadow:卡片投影 stroke:描边白底 transparent:无边透明底

commodityName: true, // 商品名称

commodityDesc: true, // 商品描述

commodityPrice: true, // 商品价格

originalPrice: true, // 划线价格

buyButton: true, // 购买按钮

buyButtonStyle: ‘style-1’, // 购买按钮样式

buyButtonText: ‘马上抢’, // 购买按钮文字

commoditySubscript: true, // 商品角标

commoditySubscriptStyle: ‘new’, // 商品角标样式

},

},

// 限时折扣

{

template: ‘row-one’,

data: [],

style: {

borderRadius: ‘none’,

fontWeight: ‘400’,

padding: ‘0’,

margin: ‘0’,

},

comsize: 10,

tag: ‘限时折扣’,

commodityStyle: ‘no-border’,

commodityName: true,

commodityDesc: false,

commodityPrice: true,

originalPrice: true,

lastStock: true,

countdown: true,

progressBar: true,

buyButton: true,

buyButtonStyle: ‘style-1’,

buyButtonText: ‘即将开抢’,

}

拖拽

拖拽依赖第三方库react-dnd,提供的Hooks Api特别方便,上面的设计结构图 Component组件(DragSource) 和 Preview组件(DropTarget) 用到了拖拽,Preview组件不仅要支持上下拖拽,而且需要配合Compiler组件联动。

/*

* @description: DragSource 拖动组件

* @version: 分支号 20210629

* @author: xuchao

*/

import React, { useContext } from ‘react’;

import { useDrag } from ‘react-dnd’;

import { findIndex, some, isUndefined, filter } from ‘lodash’;

import { v1 as uuid } from ‘uuid’;

import { DecorateContext } from ‘…/…/utilities’;

import schema from ‘…/Materials/schema’;

export default ({ component, name, icon, max, componentType, fixedIndex }) => {

const { previewData = [], setState } = useContext(DecorateContext);

const number = filter(previewData, { component }).length;

const [, drag] = useDrag(

() => ({

type: ‘component’,

options: {

dropEffect: ‘copy’,

},

item: {

type: ‘add’,

component,

name,

max,

componentType,

fixedIndex,

},

end: (item, monitor) => {

const hasPh = some(previewData, { component: ‘placeholder’ });

const phIndex = findIndex(previewData, { component: ‘placeholder’ });

if (!hasPh) return;

// 组件放置已达上限

if (number === max) {

previewData.splice(phIndex, 1);

setState({ previewData: […previewData] });

return;

}

if (monitor.didDrop()) {

// 判断拖拽放入Preview组件中,占位元素替换成组件元素

previewData.splice(phIndex, 1, {

id: uuid(),

component: item.component,

options: schema[component].defaultOptions,

});

} else {

// 判断拖拽没有放入Preview组件中,删除占位元素

previewData.splice(phIndex, 1);

}

setState({

previewData: […previewData],

selectIndex: phIndex,

compiler: item.component,

});

},

}),

[previewData],

);

/**

* @description: 新增组件

* @author: xuchao

*/

const handleClick = () => {

if (number === max) return;

previewData.splice(!isUndefined(fixedIndex) ? fixedIndex : previewData.length, 0, {

id: uuid(),

component,

options: schema[component].defaultOptions,

});

setState({

previewData: […previewData],

selectIndex: !isUndefined(fixedIndex) ? fixedIndex : previewData.length - 1,

compiler: component,

});

};

return (

{name}

{number}/{max}

);

};

/*

* @description: DropTarget 放置组件

* @version: 分支号 20210629

* @author: xuchao

*/

import React, { useContext, useCallback } from ‘react’;

import { useDrop } from ‘react-dnd’;

import { findIndex, some, isUndefined, filter } from ‘lodash’;

import update from ‘immutability-helper’;

import { DecorateContext } from ‘…/…/utilities’;

import Item from ‘./Item’;

export default () => {

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:前端)

最后

整理面试题,不是让大家去只刷面试题,而是熟悉目前实际面试中常见的考察方式和知识点,做到心中有数,也可以用来自查及完善知识体系。

《前端基础面试题》,《前端校招面试题精编解析大全》,《前端面试题宝典》,《前端面试题:常用算法》PDF完整版点击这里领取

前端面试题宝典

前端校招面试题详解

上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。**

深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

[外链图片转存中…(img-lhroTO0k-1713204188986)]

[外链图片转存中…(img-FxjRcOIN-1713204188986)]

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!

[外链图片转存中…(img-eP87E3R4-1713204188987)]

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:前端)

最后

整理面试题,不是让大家去只刷面试题,而是熟悉目前实际面试中常见的考察方式和知识点,做到心中有数,也可以用来自查及完善知识体系。

《前端基础面试题》,《前端校招面试题精编解析大全》,《前端面试题宝典》,《前端面试题:常用算法》PDF完整版点击这里领取

[外链图片转存中…(img-gRNOOW1M-1713204188987)]

[外链图片转存中…(img-5tPGldwg-1713204188987)]

[外链图片转存中…(img-MmPpAsce-1713204188987)]

  • 25
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值