惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
V
V2EX
爱范儿
爱范儿
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
小众软件
小众软件
Vercel News
Vercel News
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
J
Java Code Geeks
P
Proofpoint News Feed
MongoDB | Blog
MongoDB | Blog
B
Blog
美团技术团队
量子位

zodream梦想开源/个人编程日记

文件解析笔记-zodream梦想开源/个人编程日记 密码本开发笔记之读写与保存-zodream梦想开源/个人编程日记 SkiaSharp 把 pixel byte[] 转成 SKBitmap-zodream梦想开源/个人编程日记 nas 使用 Docker 安装 gogs-zodream梦想开源/个人编程日记 复制 android 手机中的文件到电脑-zodream梦想开源/个人编程日记 周报:寻找优质的周刊-zodream梦想开源/个人编程日记 开发日志:对Markdown的代码块新增引用来源支持-zodream梦想开源/个人编程日记 周报:怎么写技术类的教程文章-zodream梦想开源/个人编程日记 css display:flex 布局尺寸超出问题-zodream梦想开源/个人编程日记 周报:SEO优化的思考-zodream梦想开源/个人编程日记 Edge 浏览器不适用 Edge Image Viewer 打开图片 -zodream梦想开源/个人编程日记 SEO 学习笔记(一) 内容来源-zodream梦想开源/个人编程日记 PHP 实现双因素身份认证(2FA)-zodream梦想开源/个人编程日记 WPF MVVM 获取List 多选数据-zodream梦想开源/个人编程日记 Burp Suite 抓包-zodream梦想开源/个人编程日记 使用 indexnow 注意事项-zodream梦想开源/个人编程日记 Godot 使用字体图标 例如: Iconfont、FontAwesome-zodream梦想开源/个人编程日记 angular 15 对指定页面进行访问限制-zodream梦想开源/个人编程日记 CSS 使用 column-count 实现瀑布流出现内容分割的解决办法-zodream梦想开源/个人编程日记 input 确认按键事件在手机端不生效-zodream梦想开源/个人编程日记 C# 使用socket 进行通讯-zodream梦想开源/个人编程日记 Maui开发中Windows应用开启管理员权限-zodream梦想开源/个人编程日记 Maui 中自定义控件-zodream梦想开源/个人编程日记 angular 14 使用 ng-template 实现tree 结构显示-zodream梦想开源/个人编程日记 c# 动态安装和卸载dll-zodream梦想开源/个人编程日记 慎用 CompositionTarget.Rendering-zodream梦想开源/个人编程日记 c# 重写 c++ 程序笔记:数据初始化-zodream梦想开源/个人编程日记 源码编译 aseprite-zodream梦想开源/个人编程日记 记录一下字符串分隔split各语言之间的不同-zodream梦想开源/个人编程日记 c# Gzip解码无头内容-zodream梦想开源/个人编程日记
【Vue Shop】基本架构-zodream梦想开源/个人编程日记
zodream · 2019-09-27 · via zodream梦想开源/个人编程日记

基本架构

项目结构

src

api 定义实现api接口

model.ts 定义接口数据结构

assets 样式及图片资源

components 公共基本部件

pages 页面

Home

Child 本页面用的部件

pipes 自定义过滤器

router 注册的页面路由

store 保存的状态及跨页面传递的数据

utils 辅助方法,http 请求

代码约定

  1. 页面及部件文件夹名使用首字母大写的驼峰写法
  2. 函数方法名使用驼峰写法
  3. 页面及部件全部使用class 类的写法,属性使用驼峰命名
  4. 语句结束必须使用;
  5. 代码一行不超过120 个字符
  6. 对象内部必须使用,结束
  7. html 标签class 类名使用 小写加 -
  8. css 尽量不使用 !important
  9. scss 嵌套层数不超过5层

具体typescript 规范请查看 tslint.json

网络请求

先定义相应数据模型,基本的模型

// 分页数据
export interface IPaging {
    limit: number;
    offset: number;
    total: number;
    more: boolean;
}
// 页面数据
export interface IPage<T> {
    paging: IPaging;
    data: T[];
}
// 全局相应
export interface IBaseResponse {
    appid?: string;
    sign?: string;
    sign_type?: string;
    timestamp?: string;
    encrypt?: string;
    encrypt_type?: string;
}
// 失败响应
export interface IErrorResponse {
    code: number;
    message?: string;
    errors?: any;
    description?: string;
}

export interface IData<T> extends IBaseResponse {
    data?: T[];
}

export interface IDataOne<T> extends IBaseResponse {
    data?: T;
}

123456789101112131415161718192021222324252627282930313233343536

接着封装一个http 请求,包括注入appid 及sign,设置请求头,处理一些全局响应包括token 过期

暴露几个常用的请求方式 get post delete 最后返回一个 Promise<T>

具体页面

[√] 首页

[√] 分类页

[√] 搜索页

[√] 商品详情页

[√] 商品评论显示页

[√] 购物车页

[√] 结算页

[√] 支付页

[√] 个人中心页

[√] 浏览记录页

[√] 个人账户页(包含提现、充值弹窗)

[√] 个人账户记录页

[√] 银行卡页

[√] 银行卡绑定页

[√] 发票页

[√] 发票申请页

[√] 发票抬头页

[√] 发票抬头编辑页

[√] 发票记录页

[√] 登录注册页

[√] 订单列表页

[√] 订单详情页

[√] 商品收藏页

[√] 消息页

[√] 账号关联页

[√] 个人信息页

[√] 账户注销页

[√] 登陆设备管理页

[√] 修改密码页

[√] 实名认证页

[√] 收货地址页

[√] 收货地址编辑页

[√] 评论商品页

[√] 发表评论页

[√] 退换货页

[√] 退换货申请页

[√] 文章列表页

[√] 文章分类页

[√] 文章详情页

[√] 推荐页

[√] 推荐规则页

[√] 推荐订单页

[√] 推荐会员页

[√] 推荐二维码页

[√] 优惠券领取页

[√] 我的优惠券页

[√] 签到页

转载请保留原文链接: https://zodream.cn/blog/id/63.html