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

@firstshow/ad-wja-coupon

v0.0.8

Published

万佳安卡券广告组件

Downloads

6

Readme

@firstshow/ad-wja-coupon

卡券广告组件

使用前准备

一. 添加域名

  1. 小程序账号登录微信公众平台
  2. 开发 —> 开发管理 —> 开发设置 —> 服务器域名
  3. request合法域名 中增加如下配置
https://advertising.adcomeon.com
https://fshows-ecs-pro.cn-hangzhou.log.aliyuncs.com

使用方法

一. npm 安装, 参考 小程序 npm 支持

npm install @firstshow/ad-wja-coupon --save

二. 构建

  1. 小程序开发者工具 -> 详情(工具右上角) -> 本地设置 -> 使用 npm 模块
  2. 小程序开发者工具 -> 工具 -> 构建 npm
  3. 构建成功后小程序代码包中将产出 "miniprogram_npm" 文件夹

三. 使用

分两种场景: 场景一. 先预加载组件,一段时间后再进行展示。

  1. 页面的 json 文件中做如下配置
{
  "usingComponents": {
    "ad-wja-coupon": "@firstshow/ad-wja-coupon"
  }
}
  1. 页面的 wxml文件
<ad-wja-coupon
  wx:if="{{toLoadAd}}"
  show="{{showAd}}"
  flowMasterId="{{flowMasterId}}"
  openId="{{openId}}"
/>
  • openId若为异步获取的,保证获取到openId后再将toLoadAd设置为true,否则会提示缺少必传参数。
  • toLodaAd初始值设置为false,页面onLoad时将其设置为true,这时候只是加载组件,组件为隐藏状态,这时有足够的时间去获取广告数据。待要展示广告时,将showAd设为true,组件变为显示状态。
  1. 页面的 js文件
Page({
  data: {
    openId: 'o2BFN5Y5RDqAaJwNilSNtpA49Jlf', // 用户openId
    flowMasterId: 'fshows', // 流量主标识,联系运营人员提供
    toLoadAd: false, // 加载广告组件(通过切换这个标识,来重新获取广告数据)
    showAd: false // 是否显示广告
  },
  onLoad () {
    // 加载组件
    this.setData({
      toLoadAd: true
    })
  },
  /**
   * @function 显示广告
   */
  showAd () {
    this.setData({
      showAd: true
    })
  }
})

场景二. 进入页面立即展示。

  1. 页面的 json 文件中做如下配置
{
  "usingComponents": {
    "ad-wja-coupon": "@firstshow/ad-wja-coupon"
  }
}
  1. 页面的 wxml文件
<view class="vcy-coupon-ad-box" hidden="{{!showAd}}">
  <ad-wja-coupon
    wx:if="{{openId}}"
    openId="{{openId}}"
    flowMasterId="xxx"
    show="{{showAd}}"
    bind:onAdInfoReady="onAdInfoReady"
    ></ad-wja-coupon>
</view>
  1. 页面的 js文件
Page({
  data: {
    openId: '', // 用户openId
    flowMasterId: 'fshows', // 流量主标识,联系运营人员提供
    showAd: false // 是否显示广告
  },
  onLoad () {
    // 模拟异步获取openId
    setTimeout(() => {
      this.setData({
        openId: 'o2BFN5Y5RDqAaJwNilSNtpA49Jlg'
      })
    }, 100)
  },
  /**
   * @function 显示广告
   */
  showAd () {
    this.setData({
      showAd: true
    })
  },
  /**
   * @function 广告数据加载完后显示广告
   */
  onAdInfoReady () {
    this.showAd()
  }
})

注意事项

  • 如果必传参数openId是异步获取的,请通过wx:if,确保在获取openId参数后再进行组件的加载,以防提示缺少必传参数;
  • 进入页面直接展示广告的场景下,需要调用onAdInfoReady,onAdInfoReady是成功获取广告数据的回调,在回调中展示广告。否则曝光会有问题。

四. 组件参数说明

| 变量 | 类型 | 必填 | 说明 | |:----|:----:|:----:|:----| | show | String | 是 | 控制广告的显示 | | openId | String | 是 | 用户openId | | flowMasterId | String | 是 | 流量主id,联系运营人员提供 | | orderId | String | 否 | 订单id,有则提供,没有可以不提供 |

五. 组件事件说明

| 事件名称 | 回调参数 | 说明 | |:----|:----:|:----| | onAdInfoReady | e | 广告数据获取成功后触发 |

e.detail中包含了获取到的广告数据。