123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- const util = require("../../../utils/util.js");
- Page({
- data: {
- showHarpin:true,
- flag:false,
- imgUrl:"",
- buttonFlag:false,
- info:{},
- imgHeight:"",
- imgWidth:"",
- Copyinfo:{
- posters: [],
- },
- qrcode:"",
- title:""
- },
- onLoad(options) {
-
- console.log(this.data.info);
- let info=JSON.parse(JSON.stringify(wx.getStorageSync('info')))
- let title=this.ellipsis(info.title)
- this.setData({
- info:info,
- title:title
- })
- },
- // 生成二维码
- getImage(){
- let obj={
- data:JSON.parse(wx.getStorageSync('liveId')),
- type:"activePhoto"
- }
- let that=this
- util.ajax({
- func: "user/qrcode/applet_code",
- data: obj ,
- method:"POST"
- }, function (res) {
- console.log(res);
- that.data.qrcode=res.data
- that.setData({
- qrcode:that.data.qrcode
- })
-
- });
- },
- // 超出部分显示省略号
- ellipsis(value){
- if (!value) return '';
- if (value.length > 18) {
- return value.slice(0,18) + '...'
- }
- return value
- },
- // 保存图片
- cetaInvite() {
- let title=this.ellipsis(this.data.info.title)
- console.log(title);
- let info=JSON.parse(JSON.stringify(wx.getStorageSync('info')))
- console.log(info);
- let that = this, view = [];
- console.log(info.title);
- wx.showLoading({
- title: '海报生成中'
- });
- let width=this.data.imgWidth
- let height=this.data.imgHeight
- // if(width>height){
- // if(width>800){
- // width=800
- // // height=800
- // }
- // }
- let polHeight=241.8
- let botHeight=296
- view.push(
- {
- type: 'image',
- url: that.data.imgUrl,
- top:polHeight*0.88,
- left: 0,
- width: 1080,
- height:height/width*1080,
- },
- {
- type:"image",
- url:"https://img.bbztx.com/image_test/upload/thumbs/20221010/logo/1665382575784052492.png",
- top:0,
- left:0,
- width:1080,
- height:polHeight
- },{
- type:"image",
- url:"https://img.bbztx.com/image_test/upload/thumbs/20221010/logo/1665382948396029740.png",
- top:20,
- left:30,
- width:150,
- height:40
- },{
- type:"text",
- content:`「${title}」`,
- top:polHeight/5*2,
- left:1080/2,
- fontSize:35,
- breakWord:true,
- MaxLineNumber:104,
- wordBreak:"break-all",
- wordWrap: "break-word",
- whiteSpace:"pre-wrap",
-
- textAlign:"center",
- fontWeight:900
- },{
- type:"text",
- content:`${info.policyName!=null?info.policyName:""} ${info.sname}`,
- top:polHeight/3*2,
- color: '#282828',
- textAlign:"center",
- left:1080/2,
- fontSize:30
- },{
- type: 'image',
- url: "https://img.bbztx.com/image_test/upload/thumbs/20221031/logo/1667201351273024921.png",
- top:height/width*1080+polHeight*0.76,
- width: 1080,
- height:botHeight,
- left:0,
- },{
- type: 'image',
- url: that.data.qrcode, //上线使用的二维码
- // url:"https://img.bbztx.com/applet/code/test/41c3584c894eedbdde42bc4c.png", //测试使用的二维码
- top:height/width*1080+polHeight*0.89,
- width: 1080/6,
- height:1080/6,
- left:1080/12*5,
- },{
- type: 'rect',
- content: '',
- top: polHeight-4,
- left: 1080/2-23,
- width: 60,
- height: 8,
- background:'#EE3A43',
- borderRadius: 50
- },{
- type: 'rect',
- content: '',
- top: height/width*1080+polHeight*0.76-2,
- left: 1080/2-30,
- width: 60,
- height: 9,
- background:'#EE3A43',
- borderRadius: 50
- },
- )
- this.setData({
- painting: {
- width: 1080,
- height: height/width*1080+botHeight+polHeight*0.76,
- clear: true,
- views: view
- }
- });
- },
- eventGetImage(event){
- const { tempFilePath, errMsg } = event.detail
- if (errMsg === 'canvasdrawer:ok') {
- wx.saveImageToPhotosAlbum({
- filePath: tempFilePath,
- success(res) {
- wx.showToast({
- title: '保存图片成功',
- icon: 'success',
- duration: 2000
- })
- }
- });
- wx.hideLoading();
- }
- },
- // 获取上传图片的宽高
- loadSuccess(e){
- console.log(e.detail);
- this.setData({
- imgHeight:e.detail.height,
- imgWidth:e.detail.width
- })
- },
- // 上传图片
- upImage(){
- this.getImage()
- let that=this
- wx.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['album', 'camera'],
- success (res) {
- console.log(res);
- // tempFilePath可以作为img标签的src属性显示图片
- const tempFilePaths = res.tempFilePaths[0]
- that.setData({
- imgUrl:tempFilePaths,
- flag:true,
- buttonFlag:true
- })
- }
- })
- },
- onReady() {
- },
- onShow() {
- },
- onShareAppMessage() {
- }
- })
|