Skip to content

Erupt MiniApp WeChat Mini Program ​

erupt-miniapp is a WeChat Mini Program admin built on Erupt. Add the dependency, register an app, and a Mini Program menu appears with users and sign-in, subscribe messages and the template library, codes and links, content checks, live rooms, the inbox and statistics. Built on WxJava.

xml
<dependency>
    <groupId>xyz.erupt</groupId>
    <artifactId>erupt-miniapp</artifactId>
    <version>${erupt.version}</version>
</dependency>

Needs erupt 2.4.0 or newer. H2 comes along as the zero-config database; set spring.datasource.* to use another.

Try it ​

bash
mvn spring-boot:run
# http://localhost:8080  erupt / erupt

Built-in menus ​

MenuSourceActions
Mini ProgramsdatabaseAppID, AppSecret, token, AES key, push format
UsersdatabaseEveryone who signed in through the API below, with the phone they shared; remark, send a customer service message
Subscribe templatesWeChatAdd by library id, delete, send with a log
Template libraryWeChatBrowse WeChat's public templates by category and their keywords, add one to the app
SubscriptionsdatabaseWho accepted or rejected which template, as WeChat pushes it
CodesdatabaseScene codes (unlimited) and path codes; the image is kept under the upload path
LinksdatabaseURL links, URL schemes and short links, generated on save
Content checksdatabaseRun a text through WeChat's content security check and keep the verdict
Live roomsWeChatThe live streaming component's rooms
InboxdatabaseEvery message and event the portal received
Daily statistics / RetentionWeChatThe last 7 days, or a searched range up to 30 days

Pages marked WeChat call the API when opened and page in memory; nothing of theirs is stored.

Workspace: the current app ​

The Workspace picker in the header holds the Mini Program. Database pages are filtered by it and new rows land in it; WeChat pages call its API. The pick travels with every request in the erupt-scope header and the server checks it against the apps the user is offered. This is Erupt's @EruptScope feature; MaScope is a plain Erupt form.

Signing users in ​

The Mini Program calls two endpoints, no erupt session needed. The session key stays on the server.

POST /miniapp/{appid}/login?code=<wx.login code>                  → {"data": {"openid": "...", "unionid": "..."}}
POST /miniapp/{appid}/phone?openid=...&code=<getPhoneNumber code> → {"data": "13800000000"}

Each login upserts the user; the phone is kept on the user once shared.

Message push ​

Copy the app's Server URL ({callback-domain}/miniapp/portal/{appid}) into the WeChat console, Development → Message push, with the same token and format (JSON or XML). Customer service messages and events land in the Inbox; subscribe prompt answers are kept under Subscriptions, so the Send action knows who may receive a template.

yaml
erupt:
  miniapp:
    callback-domain: https://admin.example.com   # shown in the Server URL column
    # api-host: https://proxy.example.com        # route API calls through a proxy

Notes

  • Subscribe messages reach a user once per acceptance of a one-time template; a long-term template needs a qualified category.
  • Codes and links are generated once on save and kept; delete and save again to change one.
  • Statistics are reported the morning after, so the trailing window ends yesterday.
  • Code management for third-party platforms is out of scope: it needs a component access token, not an app's own.

Contributors

The avatar of contributor named as YuePeng YuePeng

Changelog

Released under the Apache-2.0 License.