0.2.32 • Published 2 years ago

movit-utils v0.2.32

Weekly downloads
73
License
ISC
Repository
-
Last release
2 years ago

微信小程序方法 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//地址
})
0.2.30

2 years ago

0.2.32

2 years ago

0.2.31

2 years ago

0.2.27

2 years ago

0.2.26

2 years ago

0.2.25

2 years ago

0.2.24

2 years ago

0.2.23

2 years ago

0.2.22

2 years ago

0.2.29

2 years ago

0.2.28

2 years ago

0.2.21

2 years ago

0.2.20

2 years ago

0.2.19

3 years ago

0.2.18

3 years ago

0.2.17

3 years ago

0.2.16

3 years ago

0.2.15

3 years ago

0.2.14

3 years ago

0.2.13

3 years ago

0.2.12

3 years ago

0.2.11

3 years ago

0.2.10

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago