hookehuyr

海报生成数据正式联调

<!--
* @Date: 2022-09-26 14:36:57
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-27 14:45:09
* @LastEditTime: 2022-10-28 13:11:56
* @FilePath: /swx/src/pages/activityDetail/index.vue
* @Description: 活动详情页
-->
......@@ -149,8 +149,20 @@
import activityBar from '@/components/activity-bar.vue'
import Taro from '@tarojs/taro'
import PosterBuilder from '@/components/PosterBuilder/index.vue';
import { ref, computed } from "vue";
import { ref, onMounted } from "vue";
import * as dayjs from 'dayjs'
import { infoUserAPI } from '@/api/User/index';
import icon_share from '@/images/icon/share.png'
const nickname = ref('');
const avatar = ref('');
onMounted(async () => {
const { code, data } = await infoUserAPI();
if (code) {
nickname.value = data.user.nickname;
avatar.value = data.user.avatar ? data.user.avatar : 'http://gyzs.onwall.cn/tou%402x.png';
}
})
const formatDate = (date) => {
return dayjs(date).format('YYYY-MM-DD HH:mm')
......@@ -159,7 +171,7 @@ const formatDate = (date) => {
const show_share = ref(false);
const share_options = [
{ name: '微信', icon: 'wechat', openType: 'share' },
{ name: '生成海报', icon: 'poster' },
{ name: '生成海报', icon: icon_share },
]
const shareActivity = () => {
show_share.value = true;
......@@ -168,7 +180,6 @@ const onCancelShare = () => {
show_share.value = false;
}
const onSelectShare = ({ detail }) => {
// TODO: 需要完善 分享朋友和生成海报功能
show_share.value = false;
if (detail.name === '生成海报') {
show_post.value = true;
......@@ -184,7 +195,14 @@ const onClickPost = () => {
// 生成海报
const startDraw = ref(false)
const posterPath = ref('')
const base = {
let base = {}
const start = async () => {
const { code, data } = await activityInfoAPI({ i: getCurrentPageParam().id });
if (code) {
data.activity.activity_time = formatDate(data.activity.activity_time);
const activity = data.activity;
base = {
width: 1024,
height: 1334,
backgroundColor: '',
......@@ -214,7 +232,7 @@ const base = {
text: {
x: 0,
y: 0,
text: '2022-08-25 14:00',
text: '',
fontSize: 40,
color: '#222',
opacity: 1,
......@@ -244,7 +262,7 @@ const base = {
text: {
x: 0,
y: 0,
text: '上海市杨浦区军工路100号A座05室',
text: '',
fontSize: 40,
color: '#222',
opacity: 1,
......@@ -268,7 +286,7 @@ const base = {
{
x: 80,
y: 630,
text: '八段锦-智慧没有烦恼',
text: activity.name,
fontSize: 50,
color: '#000',
opacity: 1,
......@@ -284,7 +302,7 @@ const base = {
{
x: 135,
y: 770,
text: '2022-08-25 14:00',
text: activity.activity_time,
fontSize: 40,
color: '#222',
opacity: 1,
......@@ -298,7 +316,7 @@ const base = {
{
x: 135,
y: 870,
text: '上海市杨浦区军工路100号A座05室',
text: activity.address,
fontSize: 40,
color: '#222',
opacity: 1,
......@@ -312,7 +330,7 @@ const base = {
{
x: 300,
y: 1080,
text: '妙净',
text: nickname.value,
fontSize: 50,
color: '#333',
opacity: 1,
......@@ -338,7 +356,7 @@ const base = {
],
images: [
{
url: 'https://tva1.sinaimg.cn/large/5f01a858gy1h6l450x64zj20ku0bq78c.jpg',
url: activity.cover,
width: 950,
height: 500,
x: 40,
......@@ -371,7 +389,7 @@ const base = {
zIndex: 10,
},
{
url: 'https://pic.juncao.cc/cms/images/minapp.jpg',
url: avatar.value,
width: 170,
height: 170,
x: 80,
......@@ -401,10 +419,10 @@ const base = {
color: '#8F9399',
}
]
}
const start = () => {
}
startDraw.value = true;
if (!posterPath.value) Taro.showLoading();
}
}
const drawSuccess = (result) => {
console.warn('绘制好了', result);
......