Commit c76098d7 by zhangxw

需求变更

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