惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
S
Secure Thoughts
月光博客
月光博客
美团技术团队
雷峰网
雷峰网
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
News and Events Feed by Topic
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Forbes - Security
Forbes - Security
W
WeLiveSecurity
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
爱范儿
爱范儿
G
GRAHAM CLULEY
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
AI
AI
Last Week in AI
Last Week in AI
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
云风的 BLOG
云风的 BLOG
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Recent Announcements
Recent Announcements
Webroot Blog
Webroot Blog
T
Tor Project blog
Cisco Talos Blog
Cisco Talos Blog
N
News and Events Feed by Topic
罗磊的独立博客
The Register - Security
The Register - Security
Blog — PlanetScale
Blog — PlanetScale
T
Threat Research - Cisco Blogs
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
人人都是产品经理
人人都是产品经理
T
The Exploit Database - CXSecurity.com
www.infosecurity-magazine.com
www.infosecurity-magazine.com
B
Blog
腾讯CDC
Microsoft Azure Blog
Microsoft Azure Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Engineering at Meta
Engineering at Meta
Latest news
Latest news
IT之家
IT之家
D
DataBreaches.Net
博客园 - 司徒正美
N
Netflix TechBlog - Medium
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

diss带码

datart系列04:基于threejs自定义插件3D-MAP datart系列03:图表插件开发 datart系列02:图表插件开发作品 datart系列01:图表插件开发作品大赛 我的2021年新Mac设置 小程序:mqtt+webview控制显示内容 小程序:webview + PDF预览 小程序:数十年Lite 验证码:五福临门 开源论坛:社区选择Discourse 牛年开篇:网站拜年 github自定义主页秀 Davinci-二次开发系列08:mongoDB(JDBC查询)四种解决方案 Davinci-二次开发系列07:BI新元素尝试 Davinci-二次开发系列06:导出excel合并单元格 Metabase-BI系列12:0.35版本表达式是真的香 Davinci-二次开发系列05:echarts-gl map3D扩展 Davinci-二次开发系列04:自定义水印扩展 Davinci-二次开发系列03:区域地图下钻与选择
小程序:Painter画布
dumplingbao · 2021-08-03 · via diss带码

发表于 | 分类于 小程序 微信 | |

Painter这个小程序画布组件应该很多人在用,github上超3K的star就已经说明这个组件的强大了。这里我们用这个组件实现短讯(如24小时动态)的分享和海报生成。

效果

p001

图二生成的图片,也是分享出去的效果,可以点击分享跳转到短讯的详情即可,分享到群如下:

p002

介绍

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

可以通过源代码看一下组件的实现方式,其实Painter的readMe里面已经把组件的实现方式描述的很详细了,组件接收json格式,然后通过pen.js(画笔)画出json格式不同类型(文本、图片、矩形、qrcode )的view绘制,这种方式设计巧妙,对于很多复杂的情况需求都能满足。而且代码完善,优化调整也很方便。

Painter提供的工具能够将json数据直接转换效果,方便调试,链接地址:

链接1:https://painterjs.github.io/

链接2:https://lingxiaoyi.github.io/painter-custom-poster/

我们上面短讯的效果,只需利用Painter封装两个组件,一个用于分享,一个用于生成海报,控制两个组件显示隐藏即可。通过按钮传递标题、时间、标签、内容等信息,并通过组件接收,然后拼装json文件传递给Painter组件。

1
2
3
4
5
<!-- 分享绘图组件 -->
<share-box wx:if="{{isCanDraw}}" isCanDraw="{{isCanDraw}}" time="{{timeShare}}" source="{{sourceShare}}" id="{{idShare}}" title="{{titleShare}}" content="{{contentShare}}" bind:close="handleClose" bind:initData="initData" bind:createPoster="createPoster"/>

<!-- 海报组件 -->
<poster-box isPoster="{{isPoster}}" time="{{timeShare}}" source="{{sourceShare}}" id="{{idShare}}" title="{{titleShare}}" content="{{contentShare}}" bind:closePoster="handleClosePoster"/>

此外,我们利用lin-ui实现了日期的吸顶效果(备:lin-ui对于吸顶效果的封装很易用,可以尝试一下)、内容展示的卡片效果,不再赘述,详细实现可直接查看下面的代码地址。

代码

diss

已提交github,扫码关注公众号(diss带码),回复:webview,获得源码github地址