微信小程序插件 painter 生成海报、二维码

GitHub 地址:https://github.com/Kujiale-Mobile/Painter

一、引入

将 components/painter 整个文件放到自己项目的 components 中;以组件的形式在页面的 json 文件中引入;

二、使用
复制代码
<view class="container">
  <image style="width: 300px; height: 300px;" src="{{path}}"></image>
  <painter palette="{{detail}}" bind:imgOK="onImgOK" style="position:fixed; top:-999px;"></painter>
</view>

Page({
  data:{
    detail:null,
    path:null
  },
  onShow() {
    this.handleCode();
  },
  handleCode(){
    let detail = {
      width:"300px",
      height:"300px",
      background:"#f8f8f8",
      views:[
        {
          type:"qrcode",
          content:"xxs",
          css:{
            width:"80px",
            height:"80px",
            right:"10px",
            bottom:"10px",
            rotate:'0',
            borderRadius:"0px"
          }
        },{
          id:"img",
          type:"image",
          url:"../../assets/logo.png",
          css:{
            width:"40px",
            height:"40px",
            right:'30px',
            bottom:"30px",
            background:"#fff"
          }
        },{
        type:"text",
        text:"扫描二维码参加活动",
        css:{
          left:"10px",
          bottom:"10px",
          fontSize:"30rpx",
          color:"red"
        }
      }]
    }
    this.setData({detail})
  },
  onImgOK(e){
    this.setData({
      path:e.detail.path
    })
  }
})
最后、这个插件使用起来还是比较简单的,直接根据 GitHub 里面的介绍使用就可以了

1、二维码中间无法添加 logo,想要生成能添加 logo 的二维码可以使用 weapp-qrcode

2、如果觉得写配置太麻烦,可以借助可视化平台布局然后生成对应的 JSON:https://lingxiaoyi.github.io/painter-custom-poster/

相关推荐
志遥3 小时前
我把 Sentry 接进了 7 端小程序:从异常捕获、Breadcrumb 到 Source Map 定位
微信小程序·监控
云起SAAS4 小时前
在线客服系统源码 | 支持PC管理端+H5访客端+实时聊天
微信小程序·ai编程·看广告变现轻·在线客服系统源码
2501_933907215 小时前
如何通过上海本凡科技获得优质的小程序开发服务?
科技·微信小程序·小程序
计算机徐师兄6 小时前
Java基于微信小程序的青少年科普教学系统【附源码、文档说明】
java·微信小程序·青少年科普教学系统小程序·java青少年科普教学小程序·青少年科普教学微信小程序·青少年科普教学小程序·科普教学微信小程序
花卷HJ1 天前
微信小程序国际化完整方案
微信小程序·小程序·notepad++
nhc0881 天前
贵阳纳海川科技・上门洗车行业解决方案
科技·微信小程序·软件开发·小程序开发
hashiqimiya1 天前
微信小程序--动态切换登录注册标签页
微信小程序·小程序
hashiqimiya1 天前
微信小程序--获取验证码设计倒计时灰白色
微信小程序·小程序
2501_933907211 天前
宁波小程序公司提供专业的小程序开发服务
科技·微信小程序·小程序
扶苏10021 天前
记一次 uni-app开发微信小程序 textarea 的“伪遮挡”踩坑实录
微信小程序·小程序·uni-app