| | |
| | | const app = getApp(); |
| | | import Wxml2Canvas from 'wxml2canvas'; |
| | | import moment from 'moment' |
| | | import { |
| | | getPublicImage |
| | | } from "../../../assets/js/middleGround/tool.js"; |
| | | Page({ |
| | | |
| | | /** |
| | |
| | | closeBtn: false, |
| | | deleteBtn: false, |
| | | images: [], |
| | | pubCertificateHide: false, |
| | | contentData: {}, |
| | | rzzsImg: '' |
| | | }, |
| | | |
| | | /** |
| | |
| | | .then((res) => { |
| | | if (res.datas.length > 0) { |
| | | res.datas.forEach((item) => { |
| | | item.updateDate = item.updateDate.split('T')[0] |
| | | if (item.content) { |
| | | item.productList = JSON.parse(item.content) |
| | | item.productList.updateDate = moment(item.updateDate).format('YYYY年MM月') |
| | | item.productList.userPicture = getPublicImage(item.productList.userPicture, '', '') |
| | | } |
| | | }) |
| | | let dataList = res.datas; |
| | |
| | | goBookDetails(e) { |
| | | let productList = e.currentTarget.dataset.book.productList |
| | | this.setData({ |
| | | images: productList.certificate ? [productList.certificate] : this.data.active === 0 ? ['/static/images/certificate/kczs.jpg'] : ['/static/images/certificate/jczs.jpg'], |
| | | showIndex: true, |
| | | visible: true, |
| | | contentData: productList, |
| | | pubCertificateHide: true, |
| | | }) |
| | | |
| | | this.drawImage1() |
| | | }, |
| | | drawImage1() { |
| | | let that = this; |
| | | let drawMyImage1 = new Wxml2Canvas({ |
| | | width: that.data.imageWidth, |
| | | height: that.data.imageHeight, |
| | | element: 'myCanvas1', |
| | | progress(percent) {}, |
| | | finish(url) { |
| | | wx.getFileSystemManager().readFile({ |
| | | filePath: url, |
| | | encoding: 'base64', |
| | | success: (res) => { |
| | | let MyImageBase641 = 'data:image/jpg;base64,' + res.data |
| | | if (MyImageBase641) { |
| | | that.setData({ |
| | | rzzsImg: MyImageBase641, |
| | | }) |
| | | } |
| | | setTimeout(() => { |
| | | that.setData({ |
| | | pubCertificateHide: false, |
| | | images: [that.data.rzzsImg], |
| | | showIndex: true, |
| | | visible: true, |
| | | }) |
| | | }, 1000) |
| | | }, |
| | | }) |
| | | }, |
| | | error(res) { |
| | | console.log("生成的图片失败", res) |
| | | } |
| | | }, this); |
| | | let data = { |
| | | list: [{ |
| | | type: 'wxml', |
| | | class: '.my_canvas1 .my_draw_canvas1', //.my_draw_canvas每个要绘制元素的类名 |
| | | limit: '.my_canvas1', //my_canvas根元素类名 |
| | | x: 0, |
| | | y: 0 |
| | | }] |
| | | } |
| | | drawMyImage1.draw(data, that); |
| | | }, |
| | | |
| | | onClose(e) { |
| | | const { |
| | | trigger |
| | | } = e.detail; |
| | | this.setData({ |
| | | visible: false, |
| | | images: [], |
| | | }); |
| | | }, |
| | | /** |