Commit c76098d7 by zhangxw

需求变更

1 parent 51a0b8b4
......@@ -76,7 +76,7 @@ class ActivityApi {
// 获取当前活动的海报
getActivityPosters(data) {
return api.post({
method: `scrm.api.assistant.activity.poster`,
method: `scrm.api.assistant.crowdFunding.poster`,
...data
})
}
......
// components/sharePopup/sharePopup.js
import {imgUrlMixin} from '~/mixins/index'
import index_const from "~/pages/tab/index/index_const"
import { IMG_URL } from '~/utils/constantData'
import Draw from '~/utils/Draw'
Component({
/**
......@@ -8,45 +9,34 @@ Component({
*/
behaviors: [imgUrlMixin],
properties: {
show: {
type: Boolean,
observer(value) {
if (value) {
wx.$util.getViewInfo('.user-box', res => {
this.setData({
boxImageHeight: res.height,
})
}, this)
// 计算弹窗图片区域最大高度
wx.$util.getViewInfo('.layout', res => {
this.setData({
postersBoxHeight: res.height * 0.7,
})
})
}
}
},
data: {
type: Object,
observer(val) {
let thisPage = wx.$router.getPageInstance()
this.setData({
navHeight: thisPage.data.navHeight
})
let imgurl = `${this.data.IMGURL}scene/scene12.png`
// 计算海报图片高度
wx.getImageInfo({
src: imgurl,
success:(res)=> {
val.postersImageHeight = (494 / 750) * res.height
this.setData({
postersImageHeight: (494 / 750) * res.height
})
}
})
// setTimeout(() => {
this.init(val)
// }, 1000)
})
if (val.showSharePopup) {
wx.$util.getViewInfo('.user-box', res => {
this.setData({
boxImageHeight: res.height,
})
val.boxImageHeight = res.height
// 计算弹窗图片区域最大高度
wx.$util.getViewInfo('.layout', res => {
this.setData({
postersBoxHeight: res.height * 0.7,
postersImageHeight: res.height * 0.7 - this.data.boxImageHeight - 20
})
val.postersBoxHeight = res.height * 0.7,
val.postersImageHeight = res.height * 0.7 - this.data.boxImageHeight - 20
this.init(val)
// this.init(val)
})
}, this)
}
}
}
},
......@@ -64,41 +54,39 @@ Component({
*/
methods: {
async init(n) {
console.log(n)
wx.$api.showLoading()
wx.$api.showLoading()
const drawfun = new Draw({
width: 279,
height: 554
width: 280,
height: 560 + n.boxImageHeight
}, this),
{
userInfo
} = wx.$storage.get(),
merchantName = userInfo.merchantName.length > 12 ? `${userInfo.merchantName.substring(0, 12)}...` : userInfo.merchantName,
res = await drawfun.begin({
imageList: [{
x: 0,
y: 0,
width: 279,
height: 66,
height: n.boxImageHeight,
url: `${this.data.IMGURL}taskDetail_bg.png`
},
{
x: 12,
y: 12,
width: 20,
height: 20,
url: `${userInfo.weChatAvatarUrl ? userInfo.weChatAvatarUrl : this.data.IMGURL}order_person_default.png`
},
// {
// x: 12,
// y: 12,
// width: 20,
// height: 20,
// url: `${userInfo.weChatAvatarUrl ? userInfo.weChatAvatarUrl : this.data.IMGURL}order_person_default.png`
// },
{
x: 16,
y: 80,
y: n.boxImageHeight + 10,
width: 247,
height: n.postersImageHeight / 2 + 80,
height: 500,
url: n.posterImg
},
// {
// x: 204,
// y: n.postersImageHeight / 2 + 170,
// y: n.postersImageHeight / 2 + boxImageHeight + 20,
// width: 60,
// height: 60,
// url: n.imagePath
......@@ -113,7 +101,7 @@ Component({
textBaseline: 'top'
},
{
x: 16 + drawfun.getTextWidth(merchantName, 14),
x: 44 + drawfun.getTextWidth(userInfo.name, 14),
y: 15,
fontSize: 12,
color: '#6E6E7A',
......@@ -130,7 +118,7 @@ Component({
fontWeight: 500
},
{
x: 14 + drawfun.getTextWidth(n.activityName, 14) + 9,
x: 44 + drawfun.getTextWidth(n.activityName, 14) + 9,
y: 39,
fontSize: 10,
color: '#4466F0',
......@@ -144,21 +132,22 @@ Component({
},
// {
// x: 16,
// y: n.postersImageHeight / 2 + 170,
// y: (n.postersImageHeight / 2) + boxImageHeight + 30,
// fontSize: 13,
// color: '#1B233D',
// text: userInfo.merchantName
// },
// {
// x: 16,
// y: n.postersImageHeight / 2 + 195,
// y: n.postersImageHeight / 2 + boxImageHeight + 50,
// fontSize: 11,
// color: '#6E6E7A',
// text: n.address
// text: n.address,
// lineNum: 3,
// width: 193
// }
],
})
console.log(res)
})
wx.hideLoading()
this.setData({
poster: res.path
......@@ -173,9 +162,8 @@ Component({
})
},
saveImage(e) {
console.log(e)
const filePath = this.data.poster,
_this = this
_this = this
wx.saveImageToPhotosAlbum({
filePath,
success(){
......
......@@ -86,8 +86,8 @@
}
}
.content-box{
padding: 32rpx;
width: 100%;
padding: 32rpx 32rpx 0 32rpx;
box-sizing: border-box;
.posters_img{
margin: 0 auto;
......@@ -137,9 +137,8 @@
}
.canvas-box {
position: absolute;
// left: -9999rpx;
// top: -9999rpx;
z-index: 10000;
left: -9999rpx;
top: -9999rpx;
width: 750rpx;
height: 750rpx;
}
......
<!--components/sharePopup/sharePopup.wxml-->
<view class="share-popup" wx:if="{{show}}" catchtouchmove="noScroll">
<view class="share-popup" wx:if="{{data.showSharePopup}}" catchtouchmove="noScroll">
<view class="share-popup-bg" />
<view class="share-box" style="transform: translate(-50%, calc(-50% + {{navHeight / 2}}px));">
<view class="close-box">
......@@ -7,7 +7,7 @@
<image webp src="{{IMGURL}}popup_close_btn.png"></image>
</view>
</view>
<view class="share-popup-content" style="max-height: {{postersBoxHeight}}px;">
<view class="share-popup-content" style="height: {{postersBoxHeight}}px;">
<!-- 用户活动信息 -->
<block>
<image class="bg" style="height: {{boxImageHeight}}px;" webp src="{{IMGURL}}taskDetail_bg.png"></image>
......@@ -22,8 +22,8 @@
<!-- 海报 -->
<block>
<view class="content-box">
<image class="posters_img" style="height: {{postersImageHeight}}rpx;" src="{{data.posterImg}}"></image>
<view class="merchant_box">
<image class="posters_img" style="height: {{postersImageHeight}}px;" mode="aspectFit" src="{{data.posterImg}}"></image>
<!-- <view class="merchant_box">
<view class="merchant_message">
<view class="name">{{USERINFO.merchantName}}</view>
<view class="address">{{data.address}}</view>
......@@ -31,7 +31,7 @@
<view class="qrcode">
<image src="{{data.imagePath}}"></image>
</view>
</view>
</view> -->
</view>
</block>
<!-- 保存 -->
......
......@@ -133,16 +133,18 @@ Page({
})
})
} else {
let item = this.data.detailInfo
console.log(item)
this.setData({
sharePopupData: {
imagePath: QR.createQrCodeImg(`${item.linkUrl}`),
activityName: item.activityName,
showSharePopup: true
},
let item = this.data.detailInfo
wx.$api.showLoading()
ActivityApi.getActivityPosters({id: item.activityId}).then(res => {
this.setData({
sharePopupData: {
posterImg: res,
activityName: item.activityName,
showSharePopup: true
},
})
})
}
}
},
// 复制文案
......
/* packageActivity/pages/taskDetail/taskDetail.wxss */
.layout{
height: 100vh;;
}
.task-detail-box{
padding: 32rpx 24rpx;
box-sizing: border-box;
overflow-y: auto;
.title{
margin: 0 0 24rpx 16rpx;
font-weight: 600;
......@@ -206,4 +210,11 @@
color: #fff;
}
}
.canvas-box {
position: absolute;
left: -9999rpx;
top: -9999rpx;
width: 750rpx;
height: 750rpx;
}
}
\ No newline at end of file
......@@ -5,7 +5,7 @@
}
module.exports.indexOf = indexOf
</wxs>
<view class="task-detail-box">
<view class="task-detail-box layout">
<view class="title">任务</view>
<view class="task-box">
<view class="left">
......@@ -72,4 +72,9 @@
<view class="btn-box">
<view class="btn primary" bind:tap="shareEvent">分享<van-loading wx:if="{{isloading}}" size="30rpx" style="margin-left: 20rpx;" type="spinner" /></view>
</view>
<!-- 分享活动弹窗 -->
<share-popup show="{{sharePopupData.showSharePopup}}" data="{{sharePopupData}}"></share-popup>
<view class="canvas-box">
<canvas style="width: 352rpx;height: 352rpx;" canvas-id="mycanvas" />
</view>
</view>
......@@ -142,32 +142,39 @@ Component({
copyActivityUrl(e) {
let { item } = e.currentTarget.dataset
let thisPage = wx.$router.getPageInstance()
ActivityApi.getActivityPosters({activityId: item.id}).then(res => {
var code= QR.createQrCodeImg(res.activityUrl);
/*code是指图片base64格式数据*/
//声明文件系统
const fs = wx.getFileSystemManager();
//随机定义路径名称
var times = new Date().getTime();
var codeimg = wx.env.USER_DATA_PATH + '/' + times + '.png';
//将base64图片写入
fs.writeFile({
filePath: codeimg,
data: code.slice(22),
encoding: 'base64',
success: () => {
thisPage.setData({
sharePopupData: {
imagePath: codeimg,
activityName: res.activityName,
address: res.activityAddressDetailName,
posterImg: res.posterImg,
showSharePopup: true
},
})
}
});
wx.$api.showLoading()
ActivityApi.getActivityPosters({id: item.id}).then(res => {
// var code= QR.createQrCodeImg(res.activityUrl);
// /*code是指图片base64格式数据*/
// //声明文件系统
// const fs = wx.getFileSystemManager();
// //随机定义路径名称
// var times = new Date().getTime();
// var codeimg = wx.env.USER_DATA_PATH + '/' + times + '.png';
// //将base64图片写入
// fs.writeFile({
// filePath: codeimg,
// data: code.slice(22),
// encoding: 'base64',
// success: () => {
// thisPage.setData({
// sharePopupData: {
// imagePath: codeimg,
// activityName: res.activityName,
// address: res.activityAddressDetailName,
// posterImg: res.posterImg,
// showSharePopup: true
// },
// })
// }
// });
thisPage.setData({
sharePopupData: {
posterImg: res,
activityName: item.activityName,
showSharePopup: true
},
})
})
},
// 活动详情
......
......@@ -39,7 +39,7 @@
<!-- 预约安装弹窗 -->
<install-popup show="{{showPopup}}" data="{{installItem}}" bind:hidePopup="hidePopup"></install-popup>
<!-- 分享活动弹窗 -->
<share-popup show="{{sharePopupData.showSharePopup}}" data="{{sharePopupData}}"></share-popup>
<share-popup data="{{sharePopupData}}"></share-popup>
<!-- <van-popup show="{{ showSharePopup }}" round bind:close="onClose">
<image style="width: 352rpx; height: 352rpx;" src="{{imagePath}}"></image>
</van-popup> -->
......
......@@ -16,7 +16,7 @@ class Draw {
type: '2d',
width,
height,
compInst:isCompInst
compInst: isCompInst
}),
ctx = canvas.getContext('2d')
this[_canvas_] = canvas
......@@ -58,6 +58,7 @@ class Draw {
}
let image = this[_canvas_].createImage()
image.src = `${url}?v=${Date.now()}`
console.log(image.src)
return new Promise(resolve => {
image.onload = () => {
this[_ctx_].drawImage(image, x, y, width, height)
......@@ -65,6 +66,14 @@ class Draw {
if (callback) callback()
resolve(imageParams)
}
image.onerror = err => {
console.log(image.src)
wx.hideLoading()
wx.showToast({
title: '图片加载失败',
icon: 'error'
})
}
})
}
toRpx(val) {
......@@ -133,44 +142,10 @@ class Draw {
this[_ctx_].globalAlpha = opacity
this[_ctx_].font = `${fontWeight || 400} ${fontSize}px${font}`
this[_ctx_].fillStyle = color || '#000'
this[_ctx_].strokeStyle = color || '#000'
this[_ctx_].textBaseline = textBaseline
this[_ctx_].textAlign = textAlign
this[_ctx_].lineWidth = this.toRpx(2)
let text_width = this.getTextWidth(text)
if (textParams.border) {
let boxX = this.toRpx(textParams.x - 4.5),
boxY = this.toRpx(textParams.y - 0.5),
boxWidth = text_width + this.toRpx(9),
boxHeight = lineHeight + this.toRpx(4)
if (boxWidth > width - fontX - this.getTextWidth('…') - fontSize) {
boxWidth = width - boxX + this.toRpx(9)
}
this.drawFill({
x: boxX,
y: boxY,
width: boxWidth,
height: boxHeight,
color: textParams.border
})
}
if (textParams.background) {
let boxX = this.toRpx(textParams.x - 4),
boxY = this.toRpx(textParams.y),
boxWidth = text_width + this.toRpx(8),
boxHeight = lineHeight + this.toRpx(3)
if (boxWidth > width - fontX - this.getTextWidth('…') - fontSize) {
boxWidth = width - boxX + this.toRpx(8)
}
this.drawFill({
x: boxX,
y: boxY,
width: boxWidth,
height: boxHeight,
color: textParams.background
})
}
const drawOneLineText = () => {
let textArr = text.toString().split(''),
newText = '',
......@@ -249,11 +224,112 @@ class Draw {
drawOneLineText()
}
} else drawOneLineText()
if (textParams.border) this.drawBorder({
text,
x: textParams.x,
y: textParams.y,
fontSize: textParams.fontSize || 12,
...textParams.border
})
this[_ctx_].stroke()
}
drawBorder(params) {
let {
x,
y,
text,
color,
width,
radius,
opacity,
padding,
fontSize
} = params,
paddingX = 0,
paddingY = 0
if (padding && padding.length) {
paddingX = this.toRpx(padding[0])
paddingY = this.toRpx(padding[0])
if (padding.length > 1) paddingX = this.toRpx(padding[1])
}
let startX = this.toRpx(x) - paddingX,
endX = this.toRpx(x) + this.getTextWidth(text) + paddingX,
startY = this.toRpx(y) - paddingY,
endY = this.toRpx(y + fontSize) + paddingY / 2,
arr = [{
x: startX,
y: startY,
width: endX
},
{
x: endX,
y: startY,
height: endY
},
{
x: startX,
y: endY,
width: endX
},
{
x: startX,
y: startY,
height: endY
}
]
console.log(this.toRpx(y) , paddingY)
this[_ctx_].beginPath()
this[_ctx_].globalAlpha = typeof opacity === 'number' ? opacity : 1
this[_ctx_].lineWidth = width || this.toRpx(1)
if (radius) {
radius = this.toRpx(radius)
let arcArr = [{
moveTo: [startX, startY + radius],
arcTo: [startX, startY, startX + radius, startY],
}, {
moveTo: [endX - radius, startY],
arcTo: [endX, startY, endX, startY + radius],
},
{
moveTo: [startX, endY - radius],
arcTo: [startX, endY, startX + radius, endY],
},
{
moveTo: [endX, endY - radius],
arcTo: [endX, endY, endX - radius, endY],
}
]
arr.map((e,index) =>{
if(index == 0 || index == 2) {
e.x += radius
e.width -= radius
} else{
e.y += radius
e.height -= radius
}
})
arcArr.map((e, index) => {
this[_ctx_].moveTo(...e.moveTo)
this[_ctx_].arcTo(...e.arcTo, radius)
this[_ctx_].stroke()
this[_ctx_].restore()
this[_ctx_].save()
})
}
arr.map((e, index) => {
this[_ctx_].moveTo(e.x, e.y)
this[_ctx_].lineTo(e.width ? e.width : e.x, e.height ? e.height : e.y)
this[_ctx_].stroke()
this[_ctx_].restore()
this[_ctx_].strokeStyle = color || '#000'
this[_ctx_].save()
})
}
drawLine(lineParams, callback) {
this[_ctx_].beginPath()
let {
noTransition,
opacity,
startX,
startY,
......@@ -262,18 +338,20 @@ class Draw {
endX,
endY
} = lineParams
startX = this.toRpx(startX)
startY = this.toRpx(startY)
width = this.toRpx(width)
endX = this.toRpx(endX)
endY = this.toRpx(endY)
if (!noTransition) {
startX = this.toRpx(startX)
startY = this.toRpx(startY)
width = this.toRpx(width)
endX = this.toRpx(endX)
endY = this.toRpx(endY)
}
this[_ctx_].globalAlpha = typeof opacity === 'number' ? opacity : 1
this[_ctx_].strokeStyle = color || '#000'
this[_ctx_].lineWidth = width || this.toRpx(1)
this[_ctx_].moveTo(startX, startY)
this[_ctx_].lineTo(endX, endY)
this[_ctx_].stroke()
this[_ctx_].restore()
this[_ctx_].strokeStyle = color || '#000'
this[_ctx_].save()
if (callback) callback()
}
......@@ -411,7 +489,7 @@ class Draw {
if (index == data.imageList.length - 1) drawFun()
}
else drawFun()
}
} else drawFun()
})
}
}
......
......@@ -6,7 +6,7 @@ const target = ['ip', 'dev', 'uat', 'prod']
2测试
3生产
*/
const index = 1
const index = 2
const secretKey = {
ip: {},
dev: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!