微信小程序插件 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/

相关推荐
qq_124987075321 小时前
基于Spring Boot的心理咨询预约微信小程序(源码+论文+部署+安装)
java·spring boot·后端·spring·微信小程序·小程序·毕业设计
Front_Yue21 小时前
微信小程序实现实时噪声(分贝)检测技术方案详解
微信小程序·小程序
莫桐21 小时前
微信小程序-日常开发体验提升小巧思--持续更新
微信小程序·小程序
漏刻有时2 天前
微信小程序学习实录14:微信小程序手写签名功能完整开发方案
学习·微信小程序·notepad++
莫桐2 天前
微信小程序tab模块滚动至顶部导航栏置顶效果实现
微信小程序·小程序
sheji34162 天前
【开题答辩全过程】以 基于微信小程序健康跑平台的设计与实现为例,包含答辩的问题和答案
微信小程序·小程序
努力学前端Hang2 天前
微信小程序安装tdsign组件库
微信小程序·小程序
莫桐2 天前
微信小程序-横向轮播时,轮播高度随内容高度动态撑开
微信小程序·小程序
敲敲了个代码2 天前
UniApp 的 rpx是什么,跟rem比呢?
前端·javascript·面试·职场和发展·微信小程序·uni-app
imHere·2 天前
UniApp + 微信小程序 xr-frame 3D 开发实战指南
微信小程序·uni-app·xr