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

wind-label-print-miniprogram

v1.0.2

Published

一个用于微信小程序的蓝牙打印机核心包

Readme

wind-label-print-miniprogram

一个用于微信小程序的蓝牙打印机核心包

0.支持的蓝牙标签打印机

0.1 Gprinter佳博 热敏条码打印机 型号 GP-3120TU

1.安装

// 1. 在小程序开发工具

npm install wind-label-print-miniprogram --save

// 2. 小程序开发工具选择 [工具] -> [构建npm]

不错的教程👇🏻👇🏻👇🏻

微信小程序如何引入npm包?

2.使用

// $fxLabelPrint为蓝牙电子秤实例
import { $fxLabelPrint } from 'wind-label-print-miniprogram'

2.1 蓝牙电子秤初始化 --- init

// 失败会自动提示蓝牙未开启
$fxLabelPrint.init().then(res => {
    // 蓝牙开启成功
})

2.2 扫描蓝牙打印机 --- scanLabelPrint

// 扫描蓝牙打印机
$fxLabelPrint.scanLabelPrint().then(res => {
	if (res.length === 0) {
		wx.showToast({
			title: '未扫描到可使用的打印机',
			icon: 'error',
			duration: 2000
		})
	}
	this.setData({
		deviceList: res,
		connectDeviceId: ''
	})
})

2.3 停止扫描蓝牙打印机 --- stopScan

$fxLabelPrint.stopScan().then(() => {
    this.setData({
        searchState: false
    })
})

2.4 连接蓝牙打印机 --- connectionLabelPrint

$fxLabelPrint.connectionLabelPrint(deviceId, name).then(() => {
	this.setDeviceConnect(deviceId, name)
}).catch(() => {
	this.setData({
		connectDeviceId: ''
	})
})

2.5 断开蓝牙打印机 --- closeLabelPrint

$fxLabelPrint.closeLabelPrint(deviceId).then(() => {
    wx.showToast({
		title: '已断开标签打印机连接',
		icon: 'success',
		duration: 2000
	})
})

2.6 获取蓝牙打印机连接状态 --- getDeviceConnect

$fxLabelPrint.getDeviceConnect()

2.7 获取已经扫描过的设备列表

$fxLabelPrint.getDevicesList()

2.8 获取电子秤扫描状态

$fxLabelPrint.getScanState()

2.9 监听标签打印机连接状态, 如果断开, 则进行断开逻辑

wx.onBLEConnectionStateChange((res) => {
	$fxLabelPrint.doBLEConnectionStateChange(res)
})

2.10 打印单张标签

$fxLabelPrint.print(printData, labelTemplate)

2.11 打印多张标签

$fxLabelPrint.printMulity(printDataList, labelTemplate)

2.12 标签模板/数据

const ITEM_LABEL_TEMPLATE = {
	size: {
		// 标签宽度
		pageWidght: 60,
		// 标签高度
		pageHeight: 40
	},
	content: [
		{
			// 字段id
			id: 'date',
			// 字段类型, 支持 text(文本), barcode(条码)
			type: 'text',
			// x坐标
			x: 280,
			// y坐标
			y: 5,
			// 内容, 接收回调, 传参为printData
			handle (data) {
				return data.date
			}
		}, {
			id: 'name',
			type: 'text',
			x: 30,
			y: 5,
			handle (data) {
				return data.name
			}
		},{
			id: 'barcode',
			type: 'barcode',
			x: 50,
			y: 205,
			height: 60,
			handle (data) {
				return data.barcode || ''
			}
		}
	]
}
const printData = {
	date: '2022/07/01',
	name: '要打印的文本',
	barcode: '0123456789'
}
const printDataList = [{
	date: '2022/07/01',
	name: '要打印的文本',
	barcode: '0123456789'
}, {
	date: '2022/07/01',
	name: '要打印的文本',
	barcode: '0123456789'
}, {
	date: '2022/07/01',
	name: '要打印的文本',
	barcode: '0123456789'
}]

2.12 开启调试

$fxLabelPrint.openDebug()