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

movit-utils

v0.2.32

Published

movit-utils

Downloads

14

Readme

微信小程序方法 wxMethods

方法都是async编写,可以使用await调用
import {commonMethods,wxMethods,appMethods} from 'movit-utils'
AjaxMethod类管理接口调用
    -初始化:url为接口地址
        let params = {
            methodUrl: '/api/xxx/',
            methodPre: 'xxx'
        }
        const ajaxMethod = new AjaxMethod(params)
    -使用:接收三个参数
        let params = {
            url: '/api/xxx/',
            method: 'post',
            data: {}
        }
        await ajaxMethod.ajax(params)


CommonParameters类管理公共参数
    -初始化:params参数为Object
        let params = {
            token: String,
            ossUrl: String,
            cityInfo: Object,
            userInfo: Object,
        }
        const commonParameters = new CommonParameters(params)
    --使用:对应的方法为getxxx和setxxx 后面再有其它都是一样的命名规则
        await commonParameters.setToken(String)
        await commonParameters.getToken()


NavigateMethod类用来统一管理页面跳转
    -初始化:暂时没有定义初始化参数
        const navigateMethod = new NavigateMethod()
    --使用:方法为to 参数type不传的话为默认navigateTo,类型auth会验证token是否存在不存在跳转到授权页面
        let params = {
            url: 'xxx',
            type: 'navigateTo', // 参数为navigateTo/reLaunch/auth,默认navigateTo
            token: 'xxx'
        }
        navigateMethod.to(params)

SettingMethod类用来统一管理设置 获取设置 获取用户信息 获取code
    -初始化:暂时没有定义初始化参数
        const settingMethod = new SettingMethod()
    --使用:
        settingMethod.getSetting() // 获取已授权信息
        settingMethod.getUserInfo() // 获取用户信息
        settingMethod.login() // 获取code

一些常用的方法列表(commonMethods)

处理金额: 1000转成1,000
    NumFormat(Number)
json转成get请求参数
    ParamsToString(JSON)
2020-01-01 转 日期对象 => ios系统new Date(xxxx-xx-xx)的时候会报NaN-NaN-NaN NaN:NaN异常
    DateToStamp(String)
日期对象 转 日期字符串 -- Date => 2020-01-01
    DateToString(Date)
日期对象 转 时间字符串 -- Date => 2020-01-01 01:01:01
    DateToTime(Date)
数字 转 汉字 -- 10转成十
    ConvertToChinaNum(String)
验证身份证号码
    CheckCard(String)
 获取当前环境 IOS为1 Android为2
	getDevice()
对象深度拷贝
	deepCopy(data)
时间拼接(加上初始化时分秒 '00:00:00','23:59:59')
	spliceTime(data)
map对象转数组()
	mapToArray(data)
数组取百分比(3个参数:1:数组例[1,2,3],2:return出的百分比的下标,3:保留几位小数)
	getPercentWithPrecision

app 方法 appMethods(参数 type-登录设备系统,data-如需要参数 .then 获取回调)

//拨打电话
1、SendPhone(type,data),
//发送短信
2、SendMessage(type,data),
//扫码图片
3、ScanCode(type).then((res)=>{}),
//下载图片
4、DownloadImage(type,data),
//上传图片
5、UploadImage(type,{token:XXX,base:XXX,url:XXX}) base:接口前缀,url 相对路径
//上传图片只可拍照不可上传
6、uploadCameraWithToken(type,{token:XXX,base:XXX,url:XXX}) base:接口前缀,url 相对路径
//签到获取定位
7、startLocation(type).then((res)=>{})
//开始鹰眼
8、startTrackWithUserId(type,userId) (userId:用户ID)
//退出鹰眼
9、stopTrack(type,userId)(userId:用户ID)
//获取安全区域
10、getSafeArea(type)
//上传附件
11、uploadFile(type,{token: xxx,url: 接口地址全路径})
//开始录音
12、startRecord(type,{token: xxx,url: 接口地址全路径})
//停止录音
13、stopRecord(type,{url: 接口地址})
//小程序分享
14、shareProgramWithTitle(type,{
    title: xxx,//标题
    text: xxx,//内容
    imgUrl: xxx,//图片
    url: xxx,// h5地址
    copy: false,// 是否有复制链接
    xcxId: xxx,//原始ID
    xcxPath: xxx//小程序路径
})
15、showNavigationSheet(type,{
    lng: xxx,//地理经度
    lat: xxx,//地理纬度
    address: xxx//地址
})