小程序生成海報插件painter(原生小程序版) - 新聞資訊 - 雲南小程序開發|雲南軟件開發|雲南網站建設-昆明融晨信息技術有限公司

159-8711-8523

雲南網建設/小程序開發/軟件開發

知識

不(bù)管是(shì)網站,軟件還是(shì)小程序,都要(yào / yāo)直接或間接能爲(wéi / wèi)您産生價值,我們在(zài)追求其視覺表現的(de)同時(shí),更側重于(yú)功能的(de)便捷,營銷的(de)便利,運營的(de)高效,讓網站成爲(wéi / wèi)營銷工具,讓軟件能切實提升企業内部管理水平和(hé / huò)效率。優秀的(de)程序爲(wéi / wèi)後期升級提供便捷的(de)支持!

您當前位置>首頁 » 新聞資訊 » 小程序相關 >

小程序生成海報插件painter(原生小程序版)

發表時(shí)間:2020-10-19

發布人(rén):融晨科技

浏覽次數:119

1.先去下載插件github 下載 https://github.com/Kujiale-Mobile/Painter 下載好了(le/liǎo)把painter整個(gè)文件放在(zài)components裏面
在(zài)這(zhè)裏插入圖片描述

index.json

{
  "usingComponents": {
    "painter":"/components/painter/painter"
  }
}

index.wxml

<button open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 獲取頭像昵稱 </button>
<button bind:tap='createPoster'>生成海報</button>
<image class="poster" src="{{imgURL}}" mode="cover"></image>
<painter 
	wx-if="{{showPainter}}"
    palette="{{template}}"
    bind:imgOK="onImgOK" 
    />

index.js

Page({
  data: {
    template: {},
    imgURL:'',
	showPainter:false,
	avatarUrl:''
  },
  createPoster(){
    this.getPattle()
  },
  onImgOK(e) {
    console.log("onImgOK")
    console.log(e.detail.path)
    this.setData({
      imgURL: e.detail.path
    })
  },
  getPattle(){
	  let _this = this
	  _this.setData({
	    template: {
	      width:"750rpx",
	      height:"1624rpx",
	      views:[
	         {
	            type: 'image',
	            url: "https://campaign.uglobal.com.cn/ikea/images/havemedal.jpg",
	            css: {
	              top: '0rpx',
	              left: '0px',
	              width: '750rpx',
	              height: '1624rpx'
	            }
	          },{
	            type: 'image',
	            url: _this.data.avatarUrl,
	            css: {
	              top: '450rpx',
	              left: '270rpx',
	              width: '200rpx',
	              height: '200rpx',
	              borderRadius: '100rpx',
	              borderWidth: "10rpx",
				  borderColor: '#fed931'
	            }
	          }
	      ]
	    },
		showPainter:true
	  })
  },
  getUserInfo: function(e) {
    console.log(e)
    this.setData({
	  avatarUrl:e.detail.userInfo.avatarUrl
    })
  }
})

注意:
網絡圖片真機顯示空白請檢查 微信公衆平台 服務器域名裏面的(de)安全域名有沒有添加
微信頭像顯示空白 請添加 https://thirdwx.qlogo.cn; 添加域名後重新啓動項目就(jiù)可以(yǐ)成功顯示了(le/liǎo)。

在(zài)這(zhè)裏插入圖片描述

相關案例查看更多