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

hj-uni-common

v0.0.18

Published

公共服务

Downloads

9

Readme

uni-app 公共工具类

安装命令

npm install hj-uni-common --save

commonObj(一般在uni.$H5)

适配H5 微信jssdk 和 支付宝

::: details 文件引入示例

main.js 中

// #ifdef H5
import { installH5 } from '@/utils/h5';
// #endif

// #ifdef H5
// 微信、支付宝 jssdk
let { $H5 } = installH5(hj.commonObj);
uni.$H5 = $H5;
// #endif

/src/utils/h5.js

import wx from 'weixin-js-sdk';

// 校验接口
import { jsApiWxpay } from '@/service/common';

// 重新组装api
const installH5Api = (tObj) => {
  //  扫码
  uni.scanCode = (...args) => {
    return tObj.scanCode(...args);
  };

  // 支付
  uni.pay = (...args) => {
    return tObj.pay(...args);
  };
};

// 引入H5文件
export const installH5 = (commonObj) => {
  let h5options = {
    jsApiWxpay,
    uni: uni,
    sysAppid: '20220322391mFrgoH37',
    wx,
  };
  let $objH5 = new commonObj(h5options);
  let $H5 = null;
  // 劫持uni原有方法
  if ($objH5.targetObj) {
    $H5 = $objH5.targetObj;
    installH5Api($H5);
  }

  return { $H5 };
};

:::

uni.$H5.getBrowser

获取浏览器信息

返回对象

{
	outputDevice, // 设备信息
	outputLang, // 语言
	shellName // 端名称(wxpay | alipay)
}

uni.scanCode

二维码扫码

uni.scanCode({
  scanType: ['qrCode'],
  success(res) {
    let result = ImeiUtils.analysis(res.result)
    formData.value.cd = result
  },
})

uni.pay

支付,这里的支付参数(payData.value)需要向后台请求

uni.$H5.pay(payData.value).then((res) => {
	console.log(res, 'res')
})

StringUtils

字符串操作

isBlank

判断字符串是否有内容, 如果为null,undefined,空,多个空格都返回true

isStartWith

判断字符串是否已给定字符开头, 如: StringUtils.isStartWith('asdf','as') --> true

join

拼接字符串, 按拼接顺序一次传入, 如: StringUtils.join(2,3,'aaa') --> '23aaa'

ImeiUtils

imei工具类

analysis

解析Imei字符(一般用于二维码扫描)

isTermQrCode

判断是否为 terminalNo

analysisImei

解析模块二维码

analysisUrl

解析URL二维码

analysisLSGC

解析龙尚国产的IMEI

GpsUtils

位置信息处理工具

translateToBaidu

将高德(微信)坐标转换为百度坐标

function (lng, lat)

translateToGaode

将百度坐标转换为高德(微信)坐标

function (lng, lat)

升级日志

2022-12-17 16:47:24 新增 GpsUtils 工具类 [v0.0.18]