npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@max-tool/decorate-isv-sdk

v1.0.19

Published

装修服务商sdk

Downloads

2

Readme

店铺装修 isv sdk 文档

注意事项

shopId 获取

从组件 props 中获取 propsId

const { extraProps } = props || {};
const { secShopId } = extraProps || {};

如何跳转页面

从 props 中获取方法,来打开其他页面。

这个方法只有在 c 端执行的时候 props 中有,在 b 端编辑器中没有

预览跳转需要将二维码内容解析出来并拼接上&pass_through_api=%7B%22isJump%22%3A1%7D生成一个新的二维码,否则预览无法跳转。 可使用 草料二维码解码 来将预览二维码内容解析出来

const { extraProps } = props || {};
const { methods } = extraProps || {};
const { openPage, openCouponPanel } = methods || {};

enum JumpActionType {
  noJump = 0,
  jumpGoodsDetail = 1, // 跳转商详
  jumpGoodsList = 2, // 跳转商品列表
  jumpMember = 3, // 跳转会员页
}

// action_type为1时,是商品id;
// action_type为2时是, action_value是tmp_id(自定义页面的id,从props中获取)
// action_type为3时是,action_value是(页面的链接,从props中获取)

const item = {
  action_type, // jumpActionType中取值
  action_value,
};

// module_name 来自props.schemaNode.name
// mid 来自props.schemaNode.material_id
const { name, material_id } = props?.schemaNode || {};
const logData = {
  module_name: name,
  mid: material_id,
};

if (typeof openPage === "function") {
  openPage(item, logData);
}

如何打开领取优惠券页面

const { extraProps, schemaNode } = props || {};
const { methods, secShopId } = extraProps || {};
const { openCouponPanel } = methods || {};

// 优惠券id的获取只是一个示例,不同的配置有不同的获取方式,根据自己的情况决定
const couponId = props.couponId;

if (typeof openCouponPanel === "function") {
  openCouponPanel(couponId, secShopId);
}

如何将图片转换为 webp

import React, { useEffect, useState } from "react";
import {
  isSupportWebp2,
  transformImgToWebp2,
} from "@max-tool/decorate-isv-sdk";

const FunApp = () => {
  const [supportWebp, setSupportWebp] = useState(false);
  const [isWebpEnd, setIsWebpEnd] = useState(false);

  useEffect(() => {
    isSupportWebp2().then((res) => {
      setSupportWebp(res);
      setIsWebpEnd(true);
    });
  }, []);

  const url = "******";

  if (!isWebpEnd) {
    return null;
  }

  return (
    <div>
      <img src={supportWebp ? transformImgToWebp2(url) : url} />
    </div>
  );
};

日历 SDK

const { extraProps, schemaNode } = props || {};
const { methods, secShopId } = extraProps || {};
const { addCalendarV2, removeCalendarV2, getCalendarV2 } = methods || {};

// 返回值:无
const data = await removeCalendarV2({
  "identifier": "xbridgecase",
});

// 返回值:无
// 备注:若event_id重复则没有任何效果,状态码10004
// 目前双端都要求0<start_time<=end_time
const data = await addCalendarV2({
  "alarmOffset": 300000,
  "allDay": false,
  "endDate": 1660460400,
  "identifier": "xbridgecase",
  "notes": "xbridge calendar test",
  "repeatCount": 5,
  "repeatFrequency": "DAILY",
  "repeatInterval": 1,
  "startDate": 1660114800,
  "title": "xbridge回归case",
  "url": "www.baidu.com",
  "location": "China"
});


const data = await getCalendarV2({
  "identifier": "xbridgecase",
});

埋点上报

const { extraProps, schemaNode } = props || {};
const { methods, secShopId } = extraProps || {};
const { sendEvent } = methods || {};

const eventName = ''; // 埋点唯一标识
const params = {}; // 参数
sendEvent(eventName, params);

接口

通用类型数据

// 配置类型
enum MaterialConfigType {
	Manually,
	Smart
}

// 活动类型
enum CampaignType {
	UnKnow = 0,
	TimeBuy = 7,
	ShpFullDiscount = 100
}

fetchCampaign

拉取活动信息接口

请求参数

struct GetShopActivitiesApiRequest {
    1: optional list<i64> activity_ids (go.tag = 'validate:"required_without=MConfigType"') // 活动id,手动配置的时候传
    2: required ActivityType activity_type (go.tag = 'validate:"oneof=7 100"') // 活动类型
    3: MaterialConfigType m_config_type (go.tag = 'validate:"oneof=0 1"') // 配置类型 0 手动配置,1 智能配置,默认手动配置
    4: optional string sec_shop_id (go.tag = 'validate:"required_with=MConfigType"') // 加密店铺id
}

enum ActivityType {
    Unknow = 0
    TimeBuy = 7 // 限时特卖(限时限量购活动)
    ShopFullDiscount = 100 // 店铺满减活动
}

enum MaterialConfigType{
    Manually = 0 // 手动配置
    Smart    = 1 // 智能配置
}

返回数据

struct GetShopActivitiesApiResponse {
    1: required i32 status_code
    2: optional string status_msg
    3: optional ShopActivitiesApiData data

    255: base.BaseResp BaseResp
}

struct ShopActivitiesApiData {
    1: optional map<i64, TimeBuyInfo> time_buy_map // 限时限量购活动列表
    2: optional map<i64, FullDiscountInfo> full_discount_map // 店铺满减活动列表
}

struct TimeBuyInfo {
    1: optional string activity_id // 活动 id
    2: optional i64 activity_type // 活动类型, 7-限时限量购, 100-店铺满减
    3: optional string activity_name // 活动名称
    4: optional i64 pre_start_time // 活动预热开始时间 ms
    5: optional i64 start_time // 活动开始时间 ms
    6: optional i64 end_time // 活动结束时间 ms
    7: optional i64 create_time // 活动创建时间 ms
    8: optional i64 ts // 服务端时间戳 ms
    9: optional list<TimeBuyProductEntity> products // 活动中的商品
    10: optional i64 status // 活动状态 0-正常 1-失效
}

// 限时限量购活动的商品
struct TimeBuyProductEntity {
    1: optional ShopProduct product_base // 商品的基本信息
    2: optional i32 sale_status // 0-未开始. 1-秒杀中. 2-已抢光, 3-已结束
    3: optional i64 total_stock // 商品总库存
    4: optional i64 left_stock // 商品剩余库存
    8: optional i64 min_sku_price // 活动 sku 最低价
    9: optional i64 max_sku_price // 活动 sku 最高价
}

// 商品基本信息
struct ShopProduct {
    1: required string product_id            // 商品Id
    2: optional string name                  // 名称
    3: optional string main_img_url          // 主图
    4: optional i64 sale_price               // 售价
    5: optional i64 original_price           // 原价
    6: optional i16 status                   // 上下架状态, 0 上架,1 下架,2 删除
    7: optional i16 check_status             // 商品审核状态,1 未审核,2 待审核,3 审核通过,4 审核不通过
    8: optional i64 product_type             // 商品类型
    9: optional i64 sell_num                 // 销量
    10: optional string category_id          // 所属类目
}

struct FullDiscountInfo {
    1: optional string activity_id // 活动 id
    2: optional i64 activity_type // 活动类型, 7-限时限量购, 100-店铺满减
    3: optional string discount_id // 折扣 id
    4: optional i64 condition_type // 门槛类型  1:数量  2:价格  3:原价
    5: optional string condition_value // 门槛值
    6: optional i64 discount_type // 优惠类型 1:打折  2:一口价 3:减钱 4:赠品
    7: optional string discount // 优惠值
    8: optional list<ShopProduct> products // 活动中的商品
    9: optional i64 status // 活动状态 0-正常 1-失效
    10: optional i64 pre_start_time // 活动预热开始时间
    11: optional i64 start_time // 活动开始时间
    12: optional i64 end_time // 活动结束时间
    13: optional string activity_name // 活动名称
}

fetchCoupons

拉取优惠券信息接口

请求参数

couponIds: Array<string>,
type: MaterialConfigType,
shopId: string

返回数据

// 优惠券实体
struct ShopCouponInfo {
      1: required string coupon_meta_id         // 优惠券Id
      2: required i64 type                      // 券类型:1平台折扣券 2平台直减券 3平台满减券 21 商家折扣券 22 商家直减券 23 商家满减券 31 渠道折扣券 32 渠道直减券 33 渠道满减券 41 单品折扣券 42 单品直减券 43 单品满减券
      3: required string what_coupon            // 券类型展示文案,例:店铺券
      4: required bool is_discount              // 是否为折扣类型券
      5: optional string coupon_range           // 优惠券使用范围
      6: required i64 threshold                 // 券使用门槛金额,单位:分
      7: optional string threshold_text         // 券使用门槛文案
      8: optional i64 credit                    // 减免类券的优惠金额
      9: optional string discount               // 折扣类券的折扣值
      10: optional i64 discount_limit           // 折扣类券的优惠金额上限
      11: required i64 period_type              // 券有效期类型:1固定有效期类型,2浮动有效期类型
      12: optional i64 valid_period             // 浮动有效期天数
      13: optional i64 start_time               // 优惠券开始时间
      14: optional i64 expire_time              // 优惠券过期时间
      15: optional string time_limit            // 优惠券有效期文案
      16: required ApplyStatus apply_status     // 券领取状态
      17: optional string status_text           // 券领取状态文案
      18: optional i64 coupon_biz_type          // 优惠券类型,0 unknown,4 店铺粉丝券,5 达人粉丝券,6 店铺新人券,7 全店通用券
      19: optional list<string> tags            // 券标签列表
      20: optional string period_display        // 优惠券有效期文案,格式: 有效值至2022-09-05 23:59:59
      21: optional i64 is_show                  // 推广渠道,0:全网店铺推广(店铺券),1:自有渠道推广,3:新客专享(新人券),4:联盟达人定向券(粉丝券),5:单品广告推广券,6:评价返券
}

struct ShopCouponsApiData {
    1: optional list<ShopCouponInfo> coupons
}

struct GetShopCouponsApiResponse {
    1: required i32 status_code
    2: optional string status_msg
    3: optional ShopCouponsApiData data
    255: base.BaseResp BaseResp
}

fetchIsFan

请求是否是粉丝

请求参数

shopId: string

返回数据

struct ShopFanApiData {
    1: optional bool is_fan     // true 是粉丝(已关注), false 不是粉丝(未关注)
}

struct JudgeShopFanApiResponse {
    1: required i32 status_code
    2: optional string status_msg
    3: optional ShopFanApiData data

    255: base.BaseResp BaseResp
}

fetchIsMember

请求是否是会员

请求参数

shopId: string

返回数据

struct MemberInfo {
      1: required bool is_member           // 是否为会员
      2: optional i64 integral             // 会员积分
}

struct ShopMemberApiData {
    1: optional MemberInfo member_info
}

struct JudgeShopMemberApiResponse {
    1: required i32 status_code
    2: optional string status_msg
    3: optional ShopMemberApiData data

    255: base.BaseResp BaseResp
}

fetchProducts

获取商品信息的接口

请求参数

productIds: Array<string>, // 商品id列表,手动配置要传,智能配置不需要传
type: MaterialConfigType, // 0 手动配置,1 智能配置,默认手动配置
personalizedRecommendation: boolean, // 是否千人千面
secShopId: string // 加密店铺id,千人千面的时候必须要传
display_num?: number, // 最多展示数量
order_type?: number // 选品类型:0 高销量商品, 1 好评商品, 2低价商品, 3新品

返回数据

struct ShopProduct {
    1: required i64 product_id               // 商品Id
    2: optional string name                  // 名称
    3: optional string main_img_url          // 主图
    4: optional i64 sale_price               // 售价
    5: optional i64 original_price           // 原价
    6: optional i16 status                   // 上下架状态, 0 上架,1 下架,2 删除
    7: optional i16 check_status             // 商品审核状态,1 未审核,2 待审核,3 审核通过,4 审核不通过
    8: optional i64 product_type             // 商品类型
    9: optional i64 sell_num                 // 销量
    10: optional i64 category_id             // 所属类目
}

struct ShopProductsApiData {
    1: optional list<ShopProduct> products
}

struct GetShopProductsApiResponse {
    1: required i32 status_code
    2: optional string status_msg
    3: optional ShopProductsApiData data
    255: base.BaseResp BaseResp
}

fetchSellPoint

获取卖点

请求参数

struct GetProductSellPointsApiRequest {
    1: required list<i64> product_ids (go.tag = 'validate:"required"')

    253: optional ecom_shop_openapi_common.HeaderCommonParam header_common_param (agw.source = "not_body_struct")
    254: optional ecom_shop_openapi_common.TTNetCommonParam ttnet_common_param (agw.source = "not_body_struct" go.tag = 'validate:"-"')
    255: base.Base Base
}

返回数据

struct GetProductSellPointsApiResponse {
    1: required i32 status_code
    2: optional string status_msg
    3: optional ProductSellPointsApiData data

    255: base.BaseResp BaseResp
}

struct ProductSellPointsApiData {
    1: optional map<string, list<SellPoints>> sell_points
}

struct SellPoints {
    1: optional string content // 卖点内容
    2: optional string avatars // 头像列表-只需要一个头像
}

fetchVideoInfo

获取视频信息

请求参数

fetchVideoInfo(
	vids: Array<string>, // 商品id列表,手动配置要传,智能配置不需要传
	secShopId: string // 加密店铺id,必须要传
)

返回数据

struct GetPlayInfoApiResponse {
    1: required i32 status_code
    2: optional string status_msg
    3: optional PlayInfoApiData data

    255: base.BaseResp BaseResp
}

struct PlayInfoApiData {
    1: map<string, material_center.VideoInfo> success_map // key为vid,value为视频信息
    2: map<string, material_center.FailResult> fail_map // 失败的原因
}

struct VideoInfo {
    1:string Vid  //视频云的vid
    2:i32 Height // 图片高度
    3:i32 Width  // 图片宽度
    4:string Format // 资源格式
    5:i64 Size // 原始大小
    6:string URI // 视频云返回的uri
    7:double Duration // 视频时长
    8:string VideoCoverUrl // 视频封面
    9: string MainUrl // 播放地址,时效1h
    10: i64 MainUrlExpire // 播放地址时效时间
}

struct FailResult {
    1: i32 ErrCode
    2: string ErrMsg
}