0.0.75 • Published 3 days ago

fs-adcomeon-component v0.0.75

Weekly downloads
-
License
MIT
Repository
-
Last release
3 days ago

fs-adcomeon-component

微信小程序支付后广告组件

使用前准备

一. 申请发券插件使用权限

  1. 小程序账号登录微信公众平台
  2. 设置 —> 第三方设置 -> 插件管理 —> 添加插件,进入添加插件操作页面
  3. 搜索插件名 微信支付券 并添加, 提交审核待通过

二. 在小程序 app.json 文件中加入配置

{
  "plugins": {
    "sendCoupon": { // 微信支付券
      "version": "1.4.11",
      "provider": "wxf3f436ba9bd4be7b"
    }
  }
}

三. 添加域名

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

使用方法

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

npm install fs-adcomeon-component --save

二. 构建

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

三. 使用

方案一:在支付页接入组件

使用场景:支付页和支付结果页在同一页面下。 组件引入位置:支付页。 优势:对接在支付页,在支付页中加载组件时,广告进行预加载,能提升曝光率。

接入步骤

  1. 页面的 json 文件中做如下配置
{
  "usingComponents": {
    "fs-ad": "fs-adcomeon-component"
  }
}
  1. 页面的 wxml文件

pageMode传入1,表示在支付页接入组件。

<view wx:if="{{showFsAd}}">
  <fs-ad
    id="fsAd"
    pageMode="{{1}}"
    flowMasterId="xxx"
    openId="xxx"
  ></fs-ad>
</view>
  1. 页面的 js文件
Page({
  data: {
    showFsAd: false
  },
  onLoad () {
    // 加载广告组件
    this.setData({
      showFsAd: true,
    })
  },
  /**
   * @function 展示广告(在微信支付成功的回调时调用)
   * @desc wx.requestPayment的success中调用
   */
  handleOpenAd () {
    const fsAd = this.selectComponent('#fsAd')
    fsAd.showAd() // 展示广告
  },
  /**
   * @function 页面中的支付函数
   */
  handleWxPay () {
    wx.requestPayment({
      timeStamp: '',
      nonceStr: '',
      package: '',
      signType: 'MD5',
      paySign: '',
      success (res) {
        // 点击完成按钮
        this.handleOpenAd()
      },
      fail (res) { }
    })
  }
})

注意事项

  • 如果必传参数openId是异步获取的,请通过wx:if,确保在获取openId参数后再进行组件的一个显示,以防提示缺少必传参数

方案二:在新开页(支付结果页)接入组件

使用场景:支付页和支付结果页是两个不同的页面。 组件引入位置:支付结果页。 劣势:对接在支付结果页即进入支付结果页的同时加载广告组件,无法提前渲染组件,流失率会比「方案一」高。

接入步骤 1. 页面的 json 文件中做如下配置

{
  "usingComponents": {
    "fs-ad": "fs-adcomeon-component"
  }
}
  1. 页面的 wxml文件

pageMode传入2,表示在新开页接入组件。

<view wx:if="{{showFsAd}}">
  <fs-ad
    pageMode="{{2}}"
    flowMasterId="xxx"
    openId="xxx"
  ></fs-ad>
</view>
  1. 页面的 js文件

注意:showFsAd在data中的初始值应设置为false

Page({
  data: {
    showFsAd: false // showFsAd在data中的初始值应设置为false
  },
  onLoad () {
    // 显示广告
    this.setData({
      showFsAd: true
    })
  }
})

四. 组件参数说明

变量类型必填说明
pageModeNumber组件接入的位置:pageMode=1:在支付页接入组件,会先预加载广告数据 pageMode=2:在新开页放置组件。 默认值为1
openIdString用户openId
flowMasterIdString流量主id,联系运营人员提供
ipAddressString如需跑口令广告必传顾客的真实ip
uaString如需跑口令广告必传顾客浏览器的UA信息
orderIdString订单id,有则提供,没有可以不提供
haveNavBarBoolean是否有微信顶部导航栏,默认为true, 默认有导航栏
payAmountString实际支付金额

五. 组件方法说明

调用组件的showAd方法展示广告

const fsAd = this.selectComponent('#fsAd')
fsAd.showAd() // 展示广告
0.0.75

3 days ago

0.0.74

5 days ago

0.0.73

18 days ago

0.0.72

1 month ago

0.0.71

1 month ago

0.0.70

1 month ago

0.0.67

1 month ago

0.0.68

1 month ago

0.0.69

1 month ago

0.0.66

2 months ago

0.0.65

2 months ago

0.0.64

3 months ago

0.0.63

3 months ago

0.0.62

4 months ago

0.0.60

6 months ago

0.0.61

6 months ago

0.0.59

6 months ago

0.0.57

6 months ago

0.0.58

6 months ago

0.0.55

9 months ago

0.0.56

9 months ago

0.0.43-test

11 months ago

0.0.40-test

11 months ago

0.0.53-beta

9 months ago

0.0.45-beta

11 months ago

0.0.46

11 months ago

0.0.47

11 months ago

0.0.43-beta

11 months ago

0.0.52-test

9 months ago

0.0.39-test

11 months ago

0.0.44-beta

11 months ago

0.0.42-test

11 months ago

0.0.51

10 months ago

0.0.37-test

11 months ago

0.0.41-test

11 months ago

0.0.50

11 months ago

0.0.54-beta

9 months ago

0.0.48

11 months ago

0.0.49

11 months ago

0.0.38-test

11 months ago

0.0.20

11 months ago

0.0.35-test

11 months ago

0.0.21

11 months ago

0.0.22

11 months ago

0.0.23

11 months ago

0.0.24

11 months ago

0.0.25

11 months ago

0.0.15

11 months ago

0.0.16

11 months ago

0.0.17

11 months ago

0.0.18

11 months ago

0.0.19

11 months ago

0.0.30

11 months ago

0.0.31

11 months ago

0.0.32

11 months ago

0.0.10

12 months ago

0.0.33

11 months ago

0.0.11

11 months ago

0.0.34

11 months ago

0.0.12

11 months ago

0.0.13

11 months ago

0.0.14

11 months ago

0.0.36-test

11 months ago

0.0.26

11 months ago

0.0.9

12 months ago

0.0.27

11 months ago

0.0.8

12 months ago

0.0.28

11 months ago

0.0.29

11 months ago

0.0.5

12 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago