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

@minidesign/formid

v0.0.9

Published

**如何突破模板消息的推送限制?**

Downloads

5

Readme

@minidesign/formid

如何突破模板消息的推送限制?

突破口:“1 次提交表单可下发 1 条,多次提交下发条数独立,相互不影响”

为了突破模板消息的推送限制,实现7天内任性推送,只需收集到足够的推送码,即每次提交表单时获取到的formId。一个formId代表着开发者有向当前用户推送模板消息的一次权限。

在客户端需要在一切可以点击的地方放置搜集点,使用:@minidesign/formid替代所有的点击事件节点。

Install

  • 从小程序基础库版本 2.2.1 或以上、及开发者工具 1.02.1808300 或以上开始,小程序支持使用 npm 安装第三方包
  • 如果你的不支持,那么可以先下载下来,在手动拷贝到你的components/formid文件夹下,在使用的细节上调整一下就行了。
  1. npm install --save @minidesign/formid
  2. 【微信开发者工具】->【工具】-> 【构建 npm】
  3. ok. (别忘记执行【构建 npm】步骤)

Usage

[page].json

{
  "usingComponents": {
    "formid": "@minidesign/formid"
  }
}

[page].wxml

<formid bindclick="dosomething" class="your-class">xxx</formid>

app.js

统一一个地方app.js来收集formId,并保存到服务器,用于推送模板消息给用户。

App({
  // ...

  // minidesign config
  minidesign() {
    return {
      log: true, // 是否打印执行日志
      onGetFormId: formId => {
        // 收集 form id 的地方
        // Like: common.saveFormId(formId);
        // 注意 一个 formId 的有效期暂为 7 天
      }
    };
  }
});

Style & Class

  1. 可直接设置组件的classstyle
  2. 特定情况下,单独设置组件内button元素的classbtn-class="your-custom-button-class-name"
  3. 特定情况下,单独设置组件内form元素的classform-class="your-custom-form-class-name"

Options

minidesign {Function} return {Object} 全局配置

配置在app.js文件内的全局配置:

App({
  // ...

  // minidesign config
  minidesign() {
    return {
      log: true, // 是否打印执行日志
      onGetFormId: formId => {
        // 收集 form id 的地方
        // Like: common.saveFormId(formId);
        // 注意 一个 formId 的有效期暂为 7 天
      }
    };
  }
});

minidesign 应为一个返回object的方法。

  • log {Boolean} 是否打印执行日志
  • onGetFormId {Function} 统一收集 formId 的地方,可以在这里设计保存formId的策略

payload {any} 荷载器

一般用户事件数据传输使用

<formid bindclick="dosomething" payload="{{somedata}}">Minidesign</formid>

opentype {String} 对应 button 的 open-type,开放类型种类

可以取以下值(详见官方文档buttonopen-type 有效值)

  • contact 打开客服会话,如果用户在会话中点击消息卡片后返回小程序,可以从 bindcontact 回调中获得具体信息,具体说明 1.1.0
  • share 触发用户转发,使用前建议先阅读使用指引 1.2.0
  • getUserInfo 获取用户信息,可以从 bindgetuserinfo 回调中获取到用户信息 1.3.0
  • getPhoneNumber 获取用户手机号,可以从 bindgetphonenumber 回调中获取到用户信息,具体说明 1.2.0
  • launchApp 打开 APP,可以通过 app-parameter 属性设定向 APP 传的参数具体说明 1.9.5
  • openSetting 打开授权设置页 2.0.7
  • feedback 打开“意见反馈”页面,用户可提交反馈内容并上传日志,开发者可以登录小程序管理后台后进入左侧菜单“客服反馈”页面获取到反馈内容 2.1.0

longPressDuration {Number} 长按触发时间

扩展按钮长按功能,配置长按触发临界时间。

<formid
  bindclick="dosomething"
  payload="{{somedata}}"
  longPressDuration="{{500}}"
  bindtouch="ontouchstart"
  bindcancel="ontouchcancel"
  bindend="ontouchend"
>
  Minidesign
</formid>

bubbles {Boolean} 事件是否冒泡

默认值 false

composed {Boolean} 事件是否可以穿越组件边界

默认值false,为false时,事件将只能在引用组件的节点树上触发,不进入其他任何组件内部

capturephase {Boolean} 事件是否拥有捕获阶段

默认值 false

bindclick {Function} 点击事件

<formid bindclick="dosomething" payload="{{somedata}}">Minidesign</formid>
Page({
  dosomething({ detail }) {
    const { event, payload } = detail;
    // do something with event and payload.
  }
});

bindtouch {Function} 长按按钮按下动作开始

bindcancel {Function} 长按按钮动作取消

bindend {Function} 长按按钮动作结束

bindgetuserinfo {Function} 用户点击该按钮时,会返回获取到的用户信息,回调的 detail 数据与 wx.getUserInfo 返回的一致 open-type="getUserInfo"

bindcontact {Function} 客服消息回调 open-type="contact"

bindgetphonenumber {Function} 获取用户手机号回调 open-type="getPhoneNumber"

binderror {Function} 当使用开放能力时,发生错误的回调 open-type="launchApp"

bindopensetting {Function} 在打开授权设置页后回调 open-type="openSetting"

sessionfrom {String} 会话来源 open-type="contact"

sendmessagetitle {String} 会话内消息卡片标题 open-type="contact"

默认值为当前标题

sendmessagepath {String} 会话内消息卡片点击跳转小程序路径 open-type="contact"

默认值为当前分享路径

sendmessageimg {String} 会话内消息卡片图片 open-type="contact"

默认值为截图

sendmessagecard {Boolean} 显示会话内消息卡片 open-type="contact"

默认值为false

appparameter {String} 打开 APP 时,向 APP 传递的参数 open-type="launchApp"

默认值为@minidesign/formid