Commit fcf9e283 by liimin

调整生成卡片逻辑

1 parent 93cbfafe
...@@ -217,7 +217,6 @@ Page({ ...@@ -217,7 +217,6 @@ Page({
}; };
}, },
setShareInfo(data = {}) { setShareInfo(data = {}) {
console.log(1111, data)
const canvasWidth = 208, const canvasWidth = 208,
canvasHeight = 166, canvasHeight = 166,
textBaseline = "top"; textBaseline = "top";
...@@ -229,6 +228,9 @@ Page({ ...@@ -229,6 +228,9 @@ Page({
// }); // });
const drawCard = (callBack) => { const drawCard = (callBack) => {
// let index = 0; // let index = 0;
const canvasWidth = 208,
canvasHeight = 166,
textBaseline = "top";
const iconWidth = 9, const iconWidth = 9,
iconHeight = 9, iconHeight = 9,
iconX = 18, iconX = 18,
...@@ -314,8 +316,8 @@ Page({ ...@@ -314,8 +316,8 @@ Page({
lineHeight: 9, lineHeight: 9,
}, },
]; ];
this.setData({ posterConfig: { width: 208, this.setData({ posterConfig: { width: canvasWidth,
height: 166,texts:textList,images:imgList} }, () => { height: canvasHeight,texts:textList,images:imgList} }, () => {
Poster.create(); Poster.create();
}); });
// const drawImages = (callBack) => { // const drawImages = (callBack) => {
...@@ -352,21 +354,14 @@ Page({ ...@@ -352,21 +354,14 @@ Page({
*/ */
onPosterSuccess(src) { onPosterSuccess(src) {
const { detail } = src; const { detail } = src;
// wx.previewImage({
// current: detail,
// urls: [detail]
// })
this.setData({ this.setData({
shareImg: detail, shareImg: detail,
}); },()=>{
wx.hideLoading() wx.hideLoading()
wx.showShareMenu({ wx.showShareMenu({
menus: ['shareAppMessage', 'shareTimeline'] menus: ['shareAppMessage', 'shareTimeline']
}) })
// setData配置数据 });
// this.setData({ posterConfig: {...} }, () => {
// Poster.create();
// });
}, },
// 获取用户昵称 // 获取用户昵称
getUserProfile(e) { getUserProfile(e) {
...@@ -413,10 +408,12 @@ Page({ ...@@ -413,10 +408,12 @@ Page({
duration: 2000 duration: 2000
}) })
} }
const cardInfo = data || this.data.defaultInfo
this.setData({ this.setData({
cardInfo: data || this.data.defaultInfo cardInfo
},()=>{
this.setShareInfo(cardInfo);
}) })
this.setShareInfo(this.data.cardInfo);
}); });
}, },
}); });
...@@ -4,9 +4,7 @@ ...@@ -4,9 +4,7 @@
<import src="../../template/menu/menu.wxml" /> <import src="../../template/menu/menu.wxml" />
<import src="index.skeleton.wxml"/> <import src="index.skeleton.wxml"/>
<template is="skeleton" wx:if="true" /> <template is="skeleton" wx:if="true" />
<poster id="poster" config="{{posterConfig}}" bind:success="onPosterSuccess" bind:fail="onPosterFail"> <poster id="poster" config="{{posterConfig}}" bind:success="onPosterSuccess" bind:fail="onPosterFail"></poster>
<button>点击生成海报</button>
</poster>
<view class="main-box" wx:if="{{cardInfo}}" > <view class="main-box" wx:if="{{cardInfo}}" >
<user-info data-skeleton-hide="cardInfo" shareDisabled="{{shareDisabled}}" cardInfo="{{cardInfo}}"></user-info> <user-info data-skeleton-hide="cardInfo" shareDisabled="{{shareDisabled}}" cardInfo="{{cardInfo}}"></user-info>
<view class="main-bottom"> <view class="main-bottom">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!