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

相关推荐
Dignity_呱9 小时前
如何在不发版时,实现小程序的 AB 测试?
前端·面试·微信小程序
咸虾米_1 天前
微信小程序通过uni.chooseLocation打开地图选择位置,相关设置及可能出现的问题
微信小程序·小程序·uniapp开发·小程序地图api
不如摸鱼去2 天前
Trae 辅助下的 uni-app 跨端小程序工程化开发实践分享
微信小程序·小程序·uni-app·aigc·ai编程
意会2 天前
微信闪照小程序实现
前端·css·微信小程序
小白_ysf2 天前
uniapp 开发微信小程序,获取经纬度并且转化详细地址(单独封装版本)
微信小程序·uni-app
是一碗螺丝粉3 天前
拯救你的app/小程序审核!一套完美避开审核封禁的URL黑名单机制
前端·javascript·微信小程序
我叫黑大帅4 天前
微信小程序分包:告别加载慢,像拆快递一样简单!
前端·微信小程序
两个月菜鸟4 天前
vue+微信小程序 五角星
前端·vue.js·微信小程序
熬耶4 天前
Uniapp之微信小程序自定义底部导航栏形态
微信小程序·小程序·uni-app
誰在花里胡哨5 天前
微信小程序实现陀螺仪卡片景深效果
前端·微信小程序·动效