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

tthg-jssdk

v0.4.0

Published

用于和 `tthigo App WebView` 通信的 `jssdk`。

Downloads

5

Readme

tthg-jssdk

用于和 tthigo App WebView 通信的 jssdk

如何使用tthigo-jssdk?

首先需要在页面中引入 tthg-jssdk.min.js,然后初始化代码如下:

// WebView已经准备好交互
ttHigo.ready(async function(){
  // 获取登录状态
  const loginStatus = await ttHigo.checkLoginStatus();
  // 获取登录用户信息
  const customerInfo = await ttHigo.getCustomerInfo();
  // 唤起App登录
  ttHigo.login();
  // 使用App打开商品
  const productNo = ''; // 商品编号
  ttHigo.openProduct(productNo);
});
// 获取App的具体版本号
console.log(ttHigo.higoAppVersion);

// 获取SDK的版本号
console.log(ttHigo.version);

// 如果是在App的WebView中打开,则会输出true
console.log(ttHigo.isInApp); // true

API文档

1、ready(fn): void

// Webview通信环境加载完毕后触发,类似JQ的$.ready
ttHigo.ready(function(){
  // do something
});

2、checkLoginStatus(): Promise<{isLogin: bool}>

// 获取当前用户是否已经登录
ttHigo.checkLoginStatus()
  .then(data => {
    console.log(data.isLogin); // 打印用户是否登录
  });

3、getCustomerInfo(): Promise

// 获取登录用户信息,如果用户未登录,返回null
ttHigo.getCustomerInfo()
  .then(customerInfo => {
    console.log(customerInfo);
  });

CustomerInfo:

{
  loginName: string, // 登录名
  nickName: string, // 用户昵称
  contactWith: string, // 姓名
  encryptedCustomerNumber: string, // 加密后的客户ID
  homePhone: string, // 账号绑定的手机号
}

4、login(): void

// 请求用户登录,如果用户已经登录不会有任何变化
ttHigo.login();

5、openProduct(productNo: string, extraOptions?: any): void

// 在App上打开指定商品的商品详情页面
ttHigo.openProduct('商品ID');

6、openSeller(sellerId: string, extraOptions?: any): void

// 在App上打开指定的经销商页面
ttHigo.openSeller('seller ID');

7、openStore(storeId: number, extraOptions?: any): void

// 在App上打开指定的EventStore页面
ttHigo.openStore('store ID');

8、openBrand(brandId: number, extraOptions?: any): void

// 在App上打开指定的品牌商页面
ttHigo.openBrand('brand ID');

9、openShoppingCart(extraOptions?: any): void

// 在APP上打开购物车页面
ttHigo.openShoppingCart();

10、addProductToCart(itemNumber, extraOptions?: any): Promise

// 添加商品到购物车
ttHigo.addProductToCart(itemNumber); // itemNumber,为商品编号

11、close(extraOptions?: any): void

// 关闭Webview(路由goBack)
ttHigo.close();

12、openUrl(url, extraOptions?: any): void (注:暂未启用)

// 使用UniversalWebview 打开页面
ttHigo.openUrl(url);

13、openShareModal(shareChannels: string[], extraOptions?: any): void

该方法用于自定义分享渠道及分享数据,如果要自定义分享数据 channels为必选参数(可以为空数组)

// 传递分享渠道信息并打开分享弹出窗
// 目前支持的分享渠道有 微信 朋友圈 新浪微博 QQ QQ空间
// 分别对应channel: wechat moments weibo qq qqzone
// 如果没有传递,默认是全部渠道
/**
   * 传递分享渠道信息并打开分享弹出窗
   * @param {Array} channels 渠道列表
   * @param {object} extraOptions 额外参数
   * @param {string} [extraOptions.shareTitle] 分享标题,默认为“TT海购”
   * @param {string} [extraOptions.shareLink] 分享链接,默认为“https://www.tthigo.com”
   * @param {string} [extraOptions.shareImgUrl] 分享图片链接,默认为“https://c9.neweggimages.com.cn/Higo/images/NavyBlueLogo_120.png”
   * @param {string} [extraOptions.shareDescription] 分享描述,默认为“推荐给你tt海购正品精选好物,点开看看吧”
   */
ttHigo.openShareModal(['channel1','channel2'], extraOptions);

14、openBindPhone(extraOptions?:any): void

// 打开绑定手机号页面
const result = await ttHigo.openBindPhone();
console.log(result);

15、监控页面前置

document.addEventListener('higoWebviewFocus', ()=>{
  console.log('focus', '当前活动页面为WebView');
});

16、监控页面后置

document.addEventListener('higoWebviewBlur', ()=>{
  console.log('blur', '已经跳出Webview');
});

如何开发?

npm i
# run dev
npm run dev
# run build
npm run build