uatcomponent
Version:
311 lines (246 loc) • 6.47 kB
JavaScript
//组件类型
export type ComponentType = '4' //商户自行挑选商品
|'5' //推荐商品列表
|'6' //搜索框
|'9' //轮播组件
|'8' //图片导航,icon+标题
|'13'//橱窗
|'11'//空白行
|'88'//推荐分类
|'89'//推荐系列
//链接跳转类型
export class LinkType {
/**选择商品 */
static SelectProduct = 1;
/**分类导航 */
static CategoryNavigation = 2;
/**商品分类 */
static ProductCategory = 3;
/**商品系列 */
static ProductSeries = 4;
/**营销活动 */
static SaleActivity = 5;
/**店铺主页 */
static StoreHome = 6;
/**会员主页 */
static VIPHome = 7;
/**购物车 */
static ShoppingCart = 8;
/**全部商品 */
static AllProducts = 9;
/**自定义链接 */
static CustomizeLink = 10;
/**调查问卷 */
static Survey = 11;
/**团购活动 */
static GroupBuyActivity = 12;
/**限时抢购 */
static LimitBuy = 13;
/**自定义页面 */
static CustomizePage = 14;
/**积分商场 */
static IntegralStore = 15;
/**优惠券列表 */
static DiscountList = 16;
/**注册送券 */
static RegisterBack = 17;
/**选择优惠券 */
static TicketSelect = 18;
/**火拼团 */
static MuchGroupBuy = 19;
/**周边门店 */
static ArroundStore = 20;
/**选择文章 */
static ArticleSelect = 21;
/**摇一摇 */
static Shake = 22;
/**电话 */
static Cell = 23;
/**品牌列表 */
static BrandList = 24;
/**文章列表 */
static ArticleList = 25;
}
//轮播图数据类型
export type ScrollShowType = {}//显示类型
export type ScrollDataLinkType = {}//轮播图图片链接类型
export type ScrollDataType = {
linkType : LinkType,
link : String,
title : String,
showtitle : String,
pic : String,
}//轮播单行数据对象模型
/**跳转时,需要的数据模型 */
export type NaviParams = ScrollDataType;
export type ScrollProps = {
showType : ScrollShowType,
space : Number,
margin : Number,
dataset : ScrollDataType[],
}
export type FooterStatus = 'loading'//加载中
|'noMore'//没有更多
|'loadFail'//加载更多失败
|'normal'//一般
|'hide'//隐藏
//imgNav图片导航
export type ImgNavDataProps = ScrollDataType;
export type ImgNavProps = {
dataset : ImgNavDataProps[],
}
//橱窗数据模型
export type WindowDataProps = ScrollDataType;
//商品对象模型
export type RecommendItemProps = {
item_id : String,
title : String,
pic : String,
RowNumber: Number
}
export class RecommendItem {
_item_id : String;
_title : String;
_pic: String;
_RowNumber :Number;
constructor(props:RecommendItemProps){
this._item_id = props.item_id;
this._title = props.title;
this._pic = props.pic;
this._RowNumber = props.RowNumber;
}
// get pic(): String {
// return `http://192.168.0.127:14513//${this._pic}`;
// }
// set pic(value: String) {
// this._pic = value;
// }
}
export type WindowDisplayProps = {};//橱窗显示类型
export type WindowProps = {
layout : WindowDisplayProps,
dataset: WindowDataProps[],
}
//空白行
export type BlankLineProps = {
height : Number,
}
//推荐商品列表
export type RecommendListProps = {
/**一次加载获取的数量 */
goodsize : Number,
/**用于数据请求,作用不详 */
firstPriority : Number,
}
//推荐商品行
export type RecommendProductProps = ScrollDataType;
//推荐系列行
export type RecommendSeriesCallbackParams = ScrollDataType;
//推荐分类
export type RecommendCategoryProps = {
/**分类级别 */
depth : Number,
/**分类总个数 */
goodsize : Number,
/**分类一行个数 */
linesize : Number,
}
//推荐分类点击回调对象
export type RecommendCategoryCallbackParams = ScrollDataType;
//推荐系列
export type RecommendSeriesProps = {
/**总个数 */
goodsize : Number,
/**行个数 */
linesize : Number,
}
//基础组件模型
export type ComponentBase<T> = {
type : ComponentType,//组件类型
content? : T,
}
//请求对象模型
export type URequestModel = {
url : String,
method : 'GET'|'POST',
params?: Object,
header?: Object,
}
//数据位置信息
export type DataInfo<T> = {
arr : Array<T>,
index : Number,
}
//基础属性
export type ComponentProps<T,B> = {
data : T,
onClick : (data:T,value?:B)=>{},
dataInfo: DataInfo<T>,
//用于需要内部请求组件,返回fetch函数所需要基本数据
request?: (data:T)=>URequestModel,
baseUrl?: String,//如果涉及图片,需要补全地址,可用此参数
}
/**响应类 */
export type Response<T> = {
ErrorCode :Number,
ErrorMsg :String,
Data :T,
}
export class ResponseClass<T>{
code : Number;
msg : String;
data : T;
/**请求成功返回码 */
static SUCCESS_CODE:Number = 0;
constructor(data:Response<T>){
this.code = data.ErrorCode;
this.msg = data.ErrorMsg;
this.data = data.Data;
}
isSuccess():Boolean{
return this.code == ResponseClass.SUCCESS_CODE;
}
}
//类型4:商品列表
export class ProductProps {
item_id:String;
title:String;
price:String;
original_price:String;
create_time:String;
link: String;
pic:String;
is_compress:Number;
constructor(props:Object){
this.item_id = props.item_id;
this.title = props.title;
this.price = props.price;
this.original_price = props.original_price;
this.create_time = props.create_time;
this.link = props.link;
this.pic = props.pic;
this.is_compress = props.is_compress;
}
}
//类型4
export type ProductItemProps = {
goodslist:ProductProps[],
}
//搜索框模型:
export type SearchModel = ComponentBase<Object>;
//轮播组件模型
export type BannerModel = ComponentBase<ScrollProps>
//图片导航
export type ImgNavModel = ComponentBase<ImgNavProps>
//橱窗
export type WindowModel = ComponentBase<WindowProps>
//空白行
export type BlankModel = ComponentBase<BlankLineProps>
//自定义商品
export type ProductModel = ComponentBase<ProductItemProps>
//推荐商品
export type RecommendListModel = ComponentBase<RecommendListProps>
//推荐分类
export type RecommentCategoryModel = ComponentBase<RecommendCategoryProps>
/**推荐系列 */
export type RecommendSeriesModel = ComponentBase<RecommendSeriesProps>