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

@mg-ott/wechat-mp-login

v0.0.5

Published

和丰微信小程序登录授权插件

Downloads

14

Readme

和丰微信小程序登录授权插件

插件接入前准备

参考微信官方文档 开放标签说明文档 完成微信开放标签wx-open-launch-weapp 的签名。

插件使用

安装依赖

npm i @mg-ott/wechat-mp-login --save

实例化

import WechatLogin from '@mg-ott/wechat-mp-login';
 
const wechatLogin = new WechatLogin({
  props: {
    appid: 'appid',
    channel: 'channel',
    qrcodeId: 'qrcodeId',
  },
  listeners: {
    onStart: (res) => {
      console.log('onStart', res);
 
      if (res.ok) {
        // 设置跳转小程序路径
        this.path = res.path;
      }
    },
    onExpire: () => {
      // 登录凭证失效,重新获取凭证
      wechatLogin.start();
    },
    onLogin: async (res) => {
      console.log('onLogin', res);
      if (res.ok) {
        // 登录态处理
      }
    },
  },
});
 
// 开启小程序跳转
wechatLogin.start();

配合开放标签使用

以Vue项目示例:

template

<wx-open-launch-weapp
  v-if="!!path"
  id="launch-btn"
  :appid="appid"
  :path="path"
  :env-version="envVersion"
  @launch="onLaunch"
  @error="onError"
  @click="handleOk"
>
  <script type="text/wxtag-template">
    <style> .btn-launch-weapp {width: 100%; height: 48px;} </style>
    <div class="btn-launch-weapp"></div>
  </script>
</wx-open-launch-weapp>

script

export default {
  data() {
    return {
      appid: 'appid',
      path: '',
      envVersion: 'release',
      // envVersion: 'trial',
      // envVersion: 'develop',
    };
  },
  onLaunch(e) {
    console.log('launch success:', e);
  },
  onError(err) {
    console.log('launch error:', err);
  },
  handleOk() {
     // 跳转小程序页面
  },
}

style

设置标签在需要点击的元素之上。

wx-open-launch-weapp {
   position: absolute;
   left: 0;
   top: 0;
   width: 100%;
   height: 100%;
   z-index: 1;
}

插件文档

参数说明

| 属性 | 类型 | 默认值 | 必填 | 说明 | | -------------------- | ---------- | -------- | ------ | ---------------------- | | props.appid | string | 无 | 是 | 微信小程序appid | | props.channel | string | 无 | 是 | 所属渠道 | | props.qrcodeId | string | 无 | 否 | 二维码ID | | listeners.onStart | function | | 否 | 开启小程序跳转时触发 | | listeners.onExpire | function | | 否 | 登录凭证失效时触发 | | listeners.onLogin | function | | 否 | 同步登录结果时触发 |

listeners.onStart 回调函数

参数 Object res

| 属性 | 类型 | 说明 | | ------ | --------- | ---------------- | | ok | boolean | 是否正常 | | msg | string | 描述信息 | | path | string | 小程序跳转路径 |

listeners.onLogin 回调函数

参数 Object res

| 属性 | 类型 | 说明 | | ------ | -------------------------------------------------------------------- | ------------ | | ok | boolean | 是否正常 | | msg | string | 描述信息 | | data | Object* ticket - 登录凭证* uuid - 用户ID* openid - 小程序openid | 登录态信息 |

插件实例方法

| 事件名 | 参数 | 说明 | | --------- | ------ | ---------------- | | start | 无 | 开启小程序跳转 | | destroy | 无 | 销毁组件 |