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 🙏

© 2026 – Pkg Stats / Ryan Hefner

smartyard-js

v1.1.27

Published

智慧大院jssdk

Readme

Table of Contents generated with DocToc

JS API说明

引用说明

安装

通过npm安装

	npm i smartyard-js

本地文件引入

使用script标签引入

	<script src="./index.js"></script>

测试

Vue环境

	// Vue项目在main.js配置全局属性,即可全局引用
	// main.js
	import wzcc from "smartyard-js"
	Vue.use(wzcc)
	Vue.prototype.wzcc = wzcc;
	
	// 页面内调用jsapi方法
	this.wzcc.hello()

本地文件script标签引入

	// 本地文件script标签引入 调用对象wzcc
	wzcc.hello()

1. 业务逻辑类

1.1 wzcc.getUserToken

获取用户token

支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

Object.success 回调函数

参数

Object res

|属性|类型|说明| |:-|:-|:-| |code|string|状态值: 200(成功);401(失败)| |msg|string|状态描述或失败原因| |data|string|结果内容|

Object res.data

|属性|类型|说明| |:-|:-|:-| |access_token|string|用户token值|

1.2 wzcc.saveImage

保存图片至相册

不支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |fileUrl|string||是|图片网络地址| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

示例代码

    wzcc.saveImage({
    	fileUrl: "https://t7.baidu.com/it/u=4162611394,4275913936&fm=193&f=GIF",
    	success: res=>{
    		console.log("保存图片成功")
    		wzcc.showToast("保存图片成功")
    	},
		fail: error=>{
			console.log("保存图片失败",error)
		}
    })

1.3 wzcc.getAppVersion

获取app版本信息(可用此方法判断是否为智慧大院app环境)

支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

Object.success 回调函数

参数

Object res

|属性|类型|说明| |:-|:-|:-| |code|string|状态值: 200(成功);401(失败)| |msg|string|状态描述或失败原因| |data|string|结果内容|

Object res.data

|属性|类型|说明| |:-|:-|:-| |name|string|app名称| |version|string|app版本号|

示例代码

	wzcc.getAppVersion({
		success: res=>{
			console.log("getAppVersion",res)
			wzcc.showToast(res.data.name+" " +res.data.version)
		}
	})
	wzcc.getAppVersion().then(res=>{
		console.log("getAppVersion",res)
			wzcc.showToast(res.data.name+" " +res.data.version)
	})

1.4 wzcc.getAppVersionSync

同步获取app版本信息(可用此方法判断是否为智慧大院app环境)

Object 返回值

参数

Object res

|属性|类型|说明| |:-|:-|:-| |code|string|状态值: 200(成功);401(失败)| |msg|string|状态描述或失败原因| |data|string|结果内容|

Object res.data

|属性|类型|说明| |:-|:-|:-| |name|string|app名称| |version|string|app版本号|

示例代码

	let res = wzcc.getAppVersionSync()
	console.log("getAppVersion",res)

1.5 wzcc.createOrder

一卡通预下单

不支持promise风格

请求参数

Object object

|属性|类型|必填|说明| |:-|:-|:-|:-| |orders|string|是|订单json数组| |success|function|否|接口调用成功的回调函数| |fail|function|否|接口调用失败的回调函数| |complete|function|否|接口调用结束的回调函数(调用成功、失败都会执行)|

orders 订单json对象

|属性|类型|必填|说明| |:-|:-|:-|:-| |bizorgid|string|是|商户号| |orderAmount|string|是|订单金额| |orderNo|string|是|订单号| |remark|string|否|订单备注 字数不超过100字|

Object.success 回调函数

返回参数

Object res

|属性|类型|说明| |:-|:-|:-| |code|string|状态码:200(成功);401(失败);| |msg|string|提示信息| |data|string|订单号对象|

Object data

|属性|类型|说明| |:-|:-|:-| |tradeNo|string|交易单号| |orderNo|string|业务系统提交的订单号|

示例代码

	let order = {
		orders:[
		{
		    orderAmount: "0.01", //金额
		    orderNo:"TEST01", // 订单号
		    remark:"测试1",
			bizorgid: "229"
		},
		{
		    orderAmount: "0.02", //金额
		    orderNo:"TEST02", // 订单号
		    remark:"测试2",
			bizorgid: "230"
		},
		],
		success: res=>{
			console.log("createOrder",res)
			wzcc.showToast(res.msg)
		}
	}
	wzcc.createOrder(order)

1.6 wzcc.gotoAbcBankApp

前往农行app支付订单

支持promise风格

请求参数

Object object

|属性|类型|必填|说明| |:-|:-|:-|:-| |orderToken|string|是|农行预下单的订单token值| |success|function|否|接口调用成功的回调函数| |fail|function|否|接口调用失败的回调函数| |complete|function|否|接口调用结束的回调函数(调用成功、失败都会执行)|

Object.success 回调函数

返回参数

Object res

|属性|类型|说明| |:-|:-|:-| |code|string|状态码:200(成功);401(失败);| |msg|string|提示信息|

示例代码

	wzcc.gotoAbcBankApp({
		orderToken: "12345667",
		success: (res)=>{
			console.log("gotoabcapp success",res)
		},
		fail: (err)=>{
			console.log("gotoabcapp fail",err)
		}
	})
	wzcc.gotoAbcBankApp({
		orderToken: "12345667"
	}).then(res=>{
		console.log("gotoabcapp",res)
	})

1.7 wzcc.payNSHBankOrder

前往农商行丰收互联app支付订单

支持promise风格

请求参数

Object object

| 属性 |类型|必填| 说明 | |:---------|:-|:-|:-------------------------| | order |string|是| 农商行预下单的订单信息order | | success |function|否| 接口调用成功的回调函数 | | fail |function|否| 接口调用失败的回调函数 | | complete |function|否| 接口调用结束的回调函数(调用成功、失败都会执行) |

Object.success 回调函数

返回参数

Object res

|属性|类型|说明| |:-|:-|:-| |code|string|状态码:200(成功);401(失败);| |msg|string|提示信息|

示例代码

	wzcc.payNSHBankOrder({
		order: "12345667",
		success: (res)=>{
			console.log("payNSHBankOrder success",res)
		},
		fail: (err)=>{
			console.log("payNSHBankOrder fail",err)
		}
	})
	
	wzcc.payNSHBankOrder({
		order: "12345667"
	}).then(res=>{
	})

1.8 wzcc.openAppByPN

唤起三方app

支持promise风格

请求参数

Object object

| 属性 |类型|必填| 说明 | |:------------|:-|:-|:-------------------------| | packageName |string|是| 三方app的包名 | | success |function|否| 接口调用成功的回调函数 | | fail |function|否| 接口调用失败的回调函数 | | complete |function|否| 接口调用结束的回调函数(调用成功、失败都会执行) |

Object.success 回调函数

返回参数

Object res

|属性|类型|说明| |:-|:-|:-| |code|string|状态码:200(成功);401(失败);| |msg|string|提示信息|

示例代码

	wzcc.openAppByPN({
		packageName: "com.test.xxxx",
		success: (res)=>{
			console.log("openAppByPN success",res)
		},
		fail: (err)=>{
			console.log("openAppByPN fail",err)
		}
	})
	
	wzcc.payNSHBankOrder({
		packageName: "com.test.xxxx"
	}).then(res=>{
	})

2. 设备

2.1 wzcc.getNetworkType

获取网络类型

支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

Object.success 回调函数

参数

Object res

|属性|类型|说明| |:-|:-|:-| |code|string|状态值: 200(成功);401(失败)| |msg|string|状态描述或失败原因| |data|string|结果内容|

Object res.data

|属性|类型|说明| |:-|:-|:-| |networkType|string|网络类型|

data.networkType值枚举

|值|类型| |:-|:-| |wifi|string| |4G|string| |5G|string| |网络不可用|string| |网络未连接|string| |未知网络|string|

示例代码

    wzcc.getNetworkType({
        success: function(res){
            const networkType = res.data.networkType
        },
        fail: function(error){
        }
    })
    
    wzcc.getNetworkType().then(res=>{
        const networkType = res.data.networkType
    })

2.2 wzcc.setStatusBarLightMode

设置设备状态栏浅色/深色模式

支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |mode|string||否|默认值:light;可选值:light;dark| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

示例代码

    wzcc.setStatusBarLightMode({
		type: "dark",
        success: function(res){
        },
        fail: function(error){
        }
    })
    
    wzcc.setStatusBarLightMode({
		type: "dark"
	}).then(res=>{
        
    })

2.3 wzcc.setStatusBarColor

设置设备状态栏颜色

支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |color|string||否|默认值:app主题色;请传6位标准的16进制格式颜色值,否则无法解析,示例:#ffffff| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

示例代码

    wzcc.setStatusBarColor({
		color: "#2684FF",
        success: function(res){
        },
        fail: function(error){
        }
    })
    
    wzcc.setStatusBarLightMode({
		type: "#000000"
	}).then(res=>{
        
    })

2.4 wzcc.showStatusBar

设置设备状态栏显示/隐藏

支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |show|string||否|默认值:true;可选值:true,false| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

示例代码

    wzcc.showStatusBar({
		show: "true",
        success: function(res){
        },
        fail: function(error){
        }
    })
    
    wzcc.showStatusBar({
		show: "true"
	}).then(res=>{
        
    })

2.5 wzcc.getSystemInfo

获取设备基础信息

支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

Object.success 回调函数

参数

Object res

|属性|类型|说明| |:-|:-|:-| |code|string|状态值: 200(成功);401(失败)| |msg|string|状态描述或失败原因| |data|string|结果内容|

Object res.data

|属性|类型|说明| |:-|:-|:-| |screenWidth|string|屏幕的宽度(单位:px)| |screenHeight|string|屏幕的高度(单位:px)| |windowWidth|string|应用屏幕的宽度(单位:px)| |windowHeight|string|应用屏幕的高度(单位:px)| |statusBarHeight|string|状态栏高度(单位:px)| |sdkVersion|string|设备系统版本号| |macAddress|string|设备 MAC 地址| |model|string|设备型号| |system|string|系统平台|

示例代码

    wzcc.getSystemInfo({
        success: function(res){
			console.log("system",res.data)
        },
        fail: function(error){
        }
    })
    
    wzcc.getSystemInfo({
	}).then(res=>{
        console.log("system",res.data)
    })

2.6 wzcc.vibrate

设备震动

支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |lastTime|int||否|震动时长,单位ms,默认1000ms| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

示例代码

    wzcc.vibrate({
		lastTime: 2000,
        success: function(res){
			console.log(res)
        },
        fail: function(error){
        }
    })
    
    wzcc.vibrate({
	}).then(res=>{
        console.log(res)
    })

2.7 wzcc.addPhoneContact

添加联系人到设备通讯录

不支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |firstName|string||否|联系人名字| |lastName|string||否|联系人姓氏| |mobilePhone|string||否|联系人手机号码| |remark|string||否|联系人备注| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

注意: 虽然每个参数都非必填,但为了联系人可以正常创建,姓氏、名字、手机号码此三项至少填写一项,否则会报错

示例代码

    wzcc.addPhoneContact({
		firstName: "三",
		lastName: "张",
		mobilePhone: "18900001111",
		remark: "测试联系人",
        success: function(res){
			console.log(res)
        },
        fail: function(error){
        }
    })
    
    wzcc.addPhoneContact({
		firstName: "张三",
		mobilePhone: "18900001111",
	}).then(res=>{
        console.log(res)
    })

2.8 wzcc.callPhone

拨打电话

不支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |phone|string||是|要拨打的电话号码| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

示例代码

    wzcc.callPhone({
		phone: "123456"
    })

2.9 wzcc.showSafeArea

设置设备安全区域显示/隐藏

支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |show|string||否|默认值:false;可选值:true,false| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

示例代码

    wzcc.showSafeArea({
		show: "false",
        success: function(res){
        },
        fail: function(error){
        }
    })
    
    wzcc.showSafeArea({
		show: "false"
	}).then(res=>{
        
    })

2.10 wzcc.bindPushAccount

为当前设备绑定阿里推送的目标账号

支持promise风格

参数

Object object

| 属性 |类型|默认值| 必填 | 说明 | |:---------|:-|:-|:---|:-------------------------| | account |string|| 是 | 用于阿里的推送目标 | | success |function|| 否 | 接口调用成功的回调函数 | | fail |function|| 否 | 接口调用失败的回调函数 | | complete |function|| 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |

示例代码

    wzcc.bindPushAccount({
		account: "xxxxxxx",
        success: function(res){
        },
        fail: function(error){
        }
    })
    
    wzcc.bindPushAccount({
		account: "xxxxxxxx"
	}).then(res=>{
        
    })

2.11 wzcc.unbindPushAccount

为当前设备解除已绑定的阿里推送账号

支持promise风格

参数

Object object

| 属性 |类型|默认值| 必填 | 说明 | |:---------|:-|:-|:---|:-------------------------| | success |function|| 否 | 接口调用成功的回调函数 | | fail |function|| 否 | 接口调用失败的回调函数 | | complete |function|| 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |

示例代码

    wzcc.unbindPushAccount({
        success: function(res){
        },
        fail: function(error){
        }
    })
    
    wzcc.unbindPushAccount().then(res=>{
        
    })

3. 界面交互

3.1 wzcc.showToast

显示消息提示框

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |message|string||是|提示的内容|

示例代码

    wzcc.showToast("你好")

3.2 wzcc.scanCode

调起客户端扫码界面进行扫码

不支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

Object.success 回调函数

参数

Object res

|属性|类型|说明| |:-|:-|:-| |code|string|状态值: 200(成功);401(失败)| |msg|string|状态描述或失败原因| |data|string|结果内容|

Object res

|属性|类型|说明| |:-|:-|:-| |result|string|扫码结果|

示例代码

    wzcc.scanCode({
        success: function(res){
            const result = res.result
        },
        fail: function(error){
        }
    })

3.3 wzcc.closeWebView

关闭整个webview页面

示例代码

    wzcc.closeWebView()

3.4 wzcc.goBack

webview回退

示例代码

    wzcc.goBack()

3.5 wzcc.gotoBrowser

跳转至外部浏览器

支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |url|string||是|请输入准确的网页地址| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

示例代码

    wzcc.gotoBrowser({
    	url:"https://www.baidu.com"
    }).then(res=>{
    	console.log("跳转成功")
    })
    
    wzcc.gotoBrowser({
    	url:"https://www.baidu.com",
		success: res=>{
			console.log("跳转成功")
		}
    })

3.6 wzcc.openNewWebView

跳转打开新的webview

支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |url|string||是|请输入准确的网页地址| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

示例代码

    wzcc.openNewWebView({
    	url:"https://www.baidu.com"
    }).then(res=>{
    	console.log("跳转成功")
    })
    
    wzcc.openNewWebView({
    	url:"https://www.baidu.com",
		success: res=>{
			console.log("跳转成功")
		}
    })

3.7 wzcc.canIUse

检查app是否支持某函数/方法

参数

String name

要检查的函数/方法名称

Object 返回值

参数

Object res

|属性|类型|说明| |:-|:-|:-| |code|string|状态值: 200(存在);404(不存在)| |msg|string|描述函数是否存在| |data|string|结果内容|

示例代码

	let res = wzcc.canIUse("gotoAbcBankApp")
	console.log("canIUse",res)

3.8 wzcc.gotoSchemeUrl

通过schemeUrl跳转三方app

支持promise风格

参数

Object object

|属性|类型|默认值|必填| 说明 | |:-|:-|:-|:-|:-------------------------| |url|string||是| 请输入准确的schemeUrl | |success|function||否| 接口调用成功的回调函数 | |fail|function||否| 接口调用失败的回调函数 | |complete|function||否| 接口调用结束的回调函数(调用成功、失败都会执行) |

Object 返回值

参数

Object res

|属性|类型| 说明 | |:-|:-|:--------------------------------------------------------| |code|string| 状态值: 200(成功);403(未找到对应的三方app,可能未安装或者版本过低);500(唤起过程发生异常) | |msg|string| 状态描述或失败原因 | |data|string| 结果内容 |

示例代码

    wzcc.gotoSchemeUrl({
    	url:"weixin://"
    }).then(res=>{
    	console.log("跳转成功")
    })
    
    wzcc.gotoSchemeUrl({
    	url:"weixin://",
		success: res=>{
			console.log("跳转成功")
		}
    })

4. 位置定位

4.1 wzcc.getLocation

定位当前GPS坐标

不支持promise风格

参数

Object object

|属性|类型|默认值|必填|说明| |:-|:-|:-|:-|:-| |success|function||否|接口调用成功的回调函数| |fail|function||否|接口调用失败的回调函数| |complete|function||否|接口调用结束的回调函数(调用成功、失败都会执行)|

Object.success 回调函数

参数

Object res

|属性|类型|说明| |:-|:-|:-| |code|string|状态值: 200(成功);401(失败)| |msg|string|状态描述或失败原因| |data|string|结果内容|

Object res.data

|属性|类型|说明| |:-|:-|:-| |longitude|string|经度| |latitude|string|纬度|

注意: 目前支持的定位坐标类型为gcj02

示例代码

    wzcc.getLocation({
    	success: res=>{
    		console.log("gps",res.longitude+","+res.latitude)
    	},
    	fail: error=>{
    		console.log(error)
    	}
    })