Commit 785ac3e0 authored by lvtz's avatar lvtz

fix

parents 8d4d9c7f 136574b7
{
"requiredBackgroundModes": ["audio"],
"pages": [
"ucenter/index",
"business/pages/webview/index"
......
......@@ -498,9 +498,9 @@ Page({
if (this.data.audioStatus.playStatus == 'no') {
this.recorderManager.start({
duration: 600000,
sampleRate: 8000,
sampleRate: 16000,
numberOfChannels: 1,
encodeBitRate: 20000,
encodeBitRate: 48000,
format: 'aac',
// frameSize: 50
})
......
......@@ -1442,6 +1442,9 @@ Page({
this.setData({
imageUploaded: true
})
if (this.data.tempFilesImgs.length > 0) {
this.data.tempFilesImgs = [];
}
return;
}
imageBox[this.data.currentIndex].status = 'resolving';
......@@ -1683,27 +1686,27 @@ Page({
const that = this;
const imgUrls = filterImage.map((item)=>{return item.src})
this.data.imgInfoList = new Array(imgUrls.length);
const maxImgHeight = this.data.windowHeight - 180;
// const maxImgHeight = this.data.windowHeight - 180;
for(let i=0; i<imgUrls.length; i++){
// const url = imagify(imgUrls[i], 'image/resize,w_800/format,jpg/quality,q_50');
const url = imagify(imgUrls[i]);
wxGetImageInfo({src:url}).then((res)=>{
let imageWidth ='';
let imageHeight = '';
if(res.width > res.height){
imageWidth = this.data.windowWidth;
imageHeight = imageWidth * (res.height/res.width);
}else{
imageHeight = res.height>maxImgHeight ? maxImgHeight : res.height;
imageWidth = imageHeight * (res.width/res.height);
}
// let imageWidth ='';
// let imageHeight = '';
// if(res.width > res.height){
// imageWidth = this.data.windowWidth;
// imageHeight = imageWidth * (res.height/res.width);
// }else{
// imageHeight = res.height>maxImgHeight ? maxImgHeight : res.height;
// imageWidth = imageHeight * (res.width/res.height);
// }
that.data.imgInfoList[i]= {
imageHeight,
imageWidth,
imageHeight: res.height,
imageWidth: res.width,
orientation: res.orientation,
actTemPath: res.path,
src: url
}
}).catch(()=>{
})
}
......
......@@ -48,14 +48,16 @@ Page({
shortCanvas:false,
imgInfoList: [],
initImgInfoList: [],
maxCanvasToTemp: 0
maxCanvasToTemp: 0,
paintBoxWidth: 0,
paintBoxHeight: 0,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.ctx = wx.createCanvasContext('myCanvas');
const {
sid,
imgString,
......@@ -63,12 +65,16 @@ Page({
} = options;
const thisImgs = imgString ? JSON.parse(imgString) : [];
const thisImgInfoList = imgInfoList ? JSON.parse(imgInfoList) : new Array(thisImgs.length);
thisImgInfoList.forEach((ele) => {
ele.copyactTemPath = ele.actTemPath;
})
this.setData({
sid,
imgArr: thisImgs,
imgInfoList: thisImgInfoList
imgInfoList: thisImgInfoList,
paintBoxWidth: this.data.windowWidth,
paintBoxHeight: this.data.windowHeight - 180,
})
console.log(this.data.imgInfoList, 'imgInfoList');
this.data.initImgArr = JSON.parse(JSON.stringify(thisImgs));
this.data.initImgInfoList = JSON.parse(JSON.stringify(thisImgInfoList));
this.getImgInfo();
......@@ -78,7 +84,7 @@ Page({
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
this.ctx = wx.createCanvasContext('myCanvas');
},
/**
......@@ -128,11 +134,10 @@ Page({
if(this.data.AcSubIndex == index){
return;
}
this.saveImg(e,index);
// this.setData({
// AcSubIndex: index
// })
this.getImgInfo();
this.saveImg(e,index);
},
addLine(){
this.setData({
......@@ -237,51 +242,65 @@ Page({
const that = this;
// let url = imagify(imgArr[AcSubIndex], 'image/resize,w_400/format,jpg/quality,q_50');
let url = imagify(imgArr[AcSubIndex]);
const maxImgHeight = this.data.windowHeight - 180;
// let url = imgArr[AcSubIndex];
console.log(this.data.imgInfoList, 'imgInfoList');
const paintBoxRate = this.data.paintBoxWidth / this.data.paintBoxHeight;
const currentImgRate = imgInfoList[AcSubIndex].imageWidth / imgInfoList[AcSubIndex].imageHeight;
if (currentImgRate > paintBoxRate) {
imgInfoList[AcSubIndex].width = this.data.paintBoxWidth;
imgInfoList[AcSubIndex].height = imgInfoList[AcSubIndex].width / currentImgRate;
this.setData({
[`imgInfoList[${AcSubIndex}].width`]: imgInfoList[AcSubIndex].width,
[`imgInfoList[${AcSubIndex}].height`]: imgInfoList[AcSubIndex].height,
})
} else {
imgInfoList[AcSubIndex].width = this.data.paintBoxWidth;
imgInfoList[AcSubIndex].height = imgInfoList[AcSubIndex].width / currentImgRate;
this.setData({
[`imgInfoList[${AcSubIndex}].width`]: imgInfoList[AcSubIndex].width,
[`imgInfoList[${AcSubIndex}].height`]: imgInfoList[AcSubIndex].height,
})
}
if(imgInfoList[AcSubIndex] && imgInfoList[AcSubIndex].actTemPath) {
return;
}
wxGetImageInfo({src:url}).then((res)=>{
let imageWidth ='';
let imageHeight = '';
if(res.width > res.height){
imageWidth = this.data.windowWidth;
imageHeight = imageWidth * (res.height/res.width);
}else{
imageHeight = res.height>maxImgHeight ? maxImgHeight : res.height;
imageWidth = imageHeight * (res.width/res.height);
}
that.setData({
[`imgInfoList[${AcSubIndex}]`]: {
imageHeight: imageHeight,
imageWidth: imageWidth,
actTemPath: res.path,
},
[`initImgInfoList[${AcSubIndex}]`]: {
imageHeight: imageHeight,
imageWidth: imageWidth,
actTemPath: res.path,
},
}, ()=>{
// wx.createSelectorQuery().select('.img-wrapper').boundingClientRect(function(rect){
// rect.height;
// }).exec(function(res){
// that.data.imgwrapperHeight = res[0].height;
// })
})
}).catch(()=>{
that.setData({
imageHeight: that.data.windowWidth
},()=>{
// wx.createSelectorQuery().select('.img-wrapper').boundingClientRect(function(rect){
// rect.height; // 节点高度
// }).exec(function(res){
// that.data.imgwrapperHeight = res[0].height;
// })
})
})
// wxGetImageInfo({src:url}).then((res)=>{
// let imageWidth ='';
// let imageHeight = '';
// if(res.width > res.height){
// imageWidth = this.data.windowWidth;
// imageHeight = imageWidth * (res.height/res.width);
// }else{
// imageHeight = res.height>maxImgHeight ? maxImgHeight : res.height;
// imageWidth = imageHeight * (res.width/res.height);
// }
// that.setData({
// [`imgInfoList[${AcSubIndex}]`]: {
// imageHeight: imageHeight,
// imageWidth: imageWidth,
// actTemPath: res.path,
// },
// [`initImgInfoList[${AcSubIndex}]`]: {
// imageHeight: imageHeight,
// imageWidth: imageWidth,
// actTemPath: res.path,
// },
// }, ()=>{
// // wx.createSelectorQuery().select('.img-wrapper').boundingClientRect(function(rect){
// // rect.height;
// // }).exec(function(res){
// // that.data.imgwrapperHeight = res[0].height;
// // })
// })
// }).catch(()=>{
// that.setData({
// imageHeight: that.data.windowWidth
// },()=>{
// // wx.createSelectorQuery().select('.img-wrapper').boundingClientRect(function(rect){
// // rect.height; // 节点高度
// // }).exec(function(res){
// // that.data.imgwrapperHeight = res[0].height;
// // })
// })
// })
},
textInput(e){
const { value } = e.detail;
......@@ -296,7 +315,6 @@ Page({
[`textArr[${actTextIndex}]`]: textArr[actTextIndex]
})
}
},
showInputBox(e){
const { flag } = e.currentTarget.dataset;
......@@ -313,20 +331,44 @@ Page({
})
return
}
var ctx = wx.createCanvasContext('myCanvas');
// ctx.clearRect(0,0,750, imgInfoList[AcSubIndex].imageHeight);
// ctx.clearRect(0,0,imgInfoList[AcSubIndex].width, imgInfoList[AcSubIndex].height);
// ctx.drawImage(imgInfoList[AcSubIndex].actTemPath, 0, 0, imgInfoList[AcSubIndex].width, imgInfoList[AcSubIndex].height);
// // ctx.drawImage(imgInfoList[AcSubIndex].actTemPath, 0, 0, imgInfoList[AcSubIndex].imageWidth, imgInfoList[AcSubIndex].imageHeight);
// ctx.draw(true);
// // 线条
// for (var i = 0; i < sourceArr.length; i++) {
// this.phArr(sourceArr[i], ctx,4)
// }
// // 文字
// for (var i = 0; i < textArr.length; i++) {
// this.textWrap({
// x: textArr[i].data.left*4,
// y: textArr[i].data.top*4,
// width: 200 * 4,
// height: 14*4,
// line: 10,
// color: '#FA5251',
// size: 14*4,
// align: 'left',
// baseline: 'top',
// text: textArr[i].value,
// bold: false
// },ctx)
// }
// this.ctx.clearRect(0,0,imgInfoList[AcSubIndex].width, imgInfoList[AcSubIndex].height);
// this.ctx.drawImage(imgInfoList[AcSubIndex].actTemPath, 0, 0, imgInfoList[AcSubIndex].width, imgInfoList[AcSubIndex].height);
// this.ctx.draw(true);
wx.canvasToTempFilePath({
x: 0,
y: 0,
// width: imgInfoList[AcSubIndex].imageWidth,
// height: imgInfoList[AcSubIndex].imageHeight,
// destWidth: imgInfoList[AcSubIndex].imageWidth,
// destHeight: imgInfoList[AcSubIndex].imageHeight,
// canvasId: 'myCanvas',
width: imgInfoList[AcSubIndex].imageWidth,
height: imgInfoList[AcSubIndex].imageHeight,
destWidth: imgInfoList[AcSubIndex].imageWidth,
destHeight: imgInfoList[AcSubIndex].imageHeight,
width: imgInfoList[AcSubIndex].width,
height: imgInfoList[AcSubIndex].height,
destWidth: imgInfoList[AcSubIndex].width,
destHeight: imgInfoList[AcSubIndex].height,
canvasId: 'myCanvas',
fileType: 'jpg',
fileType: 'png',
quality: 1,
success(res) {
const tempFilePath = res.tempFilePath;
......@@ -342,7 +384,6 @@ Page({
fail(res){
}
})
},
sureTextInput(){
const { inputFlag, addInputValue, textArr, actTextIndex } = this.data;
......@@ -435,8 +476,8 @@ Page({
}
var ctx = wx.createCanvasContext('tempCanvas');
// ctx.clearRect(0,0,750, imgInfoList[AcSubIndex].imageHeight);
ctx.clearRect(0,0,imgInfoList[AcSubIndex].imageWidth * 4, imgInfoList[AcSubIndex].imageHeight * 4);
ctx.drawImage(imgInfoList[AcSubIndex].actTemPath, 0, 0, imgInfoList[AcSubIndex].imageWidth*4, imgInfoList[AcSubIndex].imageHeight*4);
ctx.clearRect(0,0,imgInfoList[AcSubIndex].width * 4, imgInfoList[AcSubIndex].height * 4);
ctx.drawImage(imgInfoList[AcSubIndex].actTemPath, 0, 0, imgInfoList[AcSubIndex].width*4, imgInfoList[AcSubIndex].height*4);
// ctx.drawImage(imgInfoList[AcSubIndex].actTemPath, 0, 0, imgInfoList[AcSubIndex].imageWidth, imgInfoList[AcSubIndex].imageHeight);
ctx.draw(true);
// 线条
......@@ -495,12 +536,8 @@ Page({
if(imgInfoList[AcSubIndex].isDraw){
this.setData({
[`imgArr[${AcSubIndex}]`]: initImgArr[AcSubIndex],
[`imgInfoList[${AcSubIndex}]`]: {
imageWidth:imgInfoList[AcSubIndex].imageWidth,
imageHeight: imgInfoList[AcSubIndex].imageHeight,
actTemPath: initImgInfoList[AcSubIndex].actTemPath,
isDraw: false
},
[`imgInfoList[${AcSubIndex}].actTemPath`]: imgInfoList[AcSubIndex].copyactTemPath,
[`imgInfoList[${AcSubIndex}].isDraw`]: false
})
}
this.setData({
......@@ -574,14 +611,10 @@ Page({
wx.canvasToTempFilePath({
x: 0,
y: 0,
width: imgInfoList[AcSubIndex].imageWidth*4,
height: imgInfoList[AcSubIndex].imageHeight*4,
destWidth: imgInfoList[AcSubIndex].imageWidth*4,
destHeight: imgInfoList[AcSubIndex].imageHeight*4,
// width: imgInfoList[AcSubIndex].imageWidth,
// height: imgInfoList[AcSubIndex].imageHeight,
// destWidth: imgInfoList[AcSubIndex].imageWidth,
// destHeight: imgInfoList[AcSubIndex].imageHeight,
width: imgInfoList[AcSubIndex].width * 4,
height: imgInfoList[AcSubIndex].height * 4,
destWidth: imgInfoList[AcSubIndex].width * 4,
destHeight: imgInfoList[AcSubIndex].height * 4,
canvasId: 'tempCanvas',
fileType: 'jpg',
quality: 1,
......@@ -594,7 +627,10 @@ Page({
[`imgInfoList[${AcSubIndex}]`]: {
imageWidth:imgInfoList[AcSubIndex].imageWidth,
imageHeight: imgInfoList[AcSubIndex].imageHeight,
width:imgInfoList[AcSubIndex].width,
height: imgInfoList[AcSubIndex].height,
actTemPath: tempFilePath,
copyactTemPath:imgInfoList[AcSubIndex].copyactTemPath,
isDraw: true
},
textArr:[],
......@@ -604,8 +640,8 @@ Page({
})
if(type=="next" || index || index==0){
that.setData({
AcSubIndex:(index || index==0) ? index : that.data.AcSubIndex+=1,
shortCanvas:false,
AcSubIndex: (index || index==0) ? index : that.data.AcSubIndex+=1,
shortCanvas: false,
})
that.getImgInfo();
}else if(type == "back"){
......
......@@ -19,10 +19,36 @@
</view>
</view>
<view class="content-box">
<view class="img-wrapper" style="width: {{imgInfoList[AcSubIndex].imageWidth}}px; height:{{imgInfoList[AcSubIndex].imageHeight}}px">
<image class="myimg" src="{{myimg}}" wx:if="{{shortCanvas && myimg}}" style="height:{{imgInfoList[AcSubIndex].imageHeight}}px" mode="aspectFit|aspectFill|widthFix" lazy-load="false" binderror="" bindload="" />
<image class="cur-img" src="{{imgInfoList[AcSubIndex].isDraw ? imgArr[AcSubIndex] : filter.imagify(imgArr[AcSubIndex], 'image/resize,w_750/format,jpg')}}" style="height:{{imgInfoList[AcSubIndex].imageHeight}}px" mode="aspectFit|aspectFill|widthFix" lazy-load="false" binderror="" bindload="" />
<canvas class="myCanvas {{shortCanvas? 'shortCanvas': ''}}" canvas-id="myCanvas" disable-scroll="true" bindtouchstart="doodleStart" bindtouchend="doodleEnd" bindtouchmove="doodleMove" style="width: {{imgInfoList[AcSubIndex].imageWidth}}px; height:{{imgInfoList[AcSubIndex].imageHeight}}px"></canvas>
<view class="img-wrapper" style="width: {{imgInfoList[AcSubIndex].width}}px; height:{{imgInfoList[AcSubIndex].height}}px">
<image
class="myimg"
src="{{myimg}}"
wx:if="{{shortCanvas && myimg}}"
style="width: {{imgInfoList[AcSubIndex].width}}px; height:{{imgInfoList[AcSubIndex].height}}px"
mode="aspectFit|aspectFill|widthFix"
lazy-load="false"
binderror=""
bindload=""
/>
<image
class="cur-img"
src="{{imgInfoList[AcSubIndex].isDraw ? imgArr[AcSubIndex] : filter.imagify(imgArr[AcSubIndex], 'image/resize,w_750/format,jpg')}}"
style="width: {{imgInfoList[AcSubIndex].width}}px; height:{{imgInfoList[AcSubIndex].height}}px"
mode="aspectFit|aspectFill|widthFix"
lazy-load="false"
binderror=""
bindload=""
/>
<canvas
class="myCanvas {{shortCanvas? 'shortCanvas': ''}}"
canvas-id="myCanvas"
disable-scroll="true"
bindtouchstart="doodleStart"
bindtouchend="doodleEnd"
bindtouchmove="doodleMove"
style="width: {{imgInfoList[AcSubIndex].width}}px; height:{{imgInfoList[AcSubIndex].height}}px"
>
</canvas>
<block wx:if="{{textArr.length>0}}">
<view class="text-box" animation="{{animationData}}" bindtouchstart="textMoveStart" bindtouchmove="textMove" bindtouchend="textMoveEnd" wx:for="{{textArr}}" data-index="{{index}}" wx:key="index" style="left: {{item.data.left}}px; top: {{item.data.top}}px"><view class="close" bindtap="deleteText"><image class="" src="{{imageRoot}}2b/comment/icon_cancal.png" mode="aspectFit|aspectFill|widthFix" lazy-load="false" binderror="" bindload="" /></view>{{item.value}}</view>
</block>
......@@ -48,5 +74,5 @@
</view>
<!-- <canvas canvas-id="tempCanvas" disable-scroll="true" style="width:200%; height:{{imgInfoList[AcSubIndex].imageHeight*2}}px; position:absolute;left:-999999px"></canvas> -->
<canvas canvas-id="tempCanvas" disable-scroll="true" style="width: {{imgInfoList[AcSubIndex].imageWidth * 4}}px; height:{{imgInfoList[AcSubIndex].imageHeight * 4}}px; position:absolute;left:-999999px"></canvas>
<canvas canvas-id="tempCanvas" disable-scroll="true" style="width: {{imgInfoList[AcSubIndex].width * 4}}px; height:{{imgInfoList[AcSubIndex].height * 4}}px; position:absolute;left:-999999px"></canvas>
<!-- style="width: {{imgInfoList[AcSubIndex].imageWidth}}px; height:{{imgInfoList[AcSubIndex].imageHeight}}px" -->
\ No newline at end of file
export default {
imageRoot: 'https://cdn.img.shangjiadao.cn/qingxiao/dakav2/images/',
host: 'https://qxapi.qingxiao.online/daka',
host2: 'https://wx.m.shangjiadao.cn',
// host: 'https://qxapi.qingxiao.online/daka',
// host2: 'https://wx.m.shangjiadao.cn',
storageVersion: '5.0',
imageVersion: '20200420',
// host: 'https://clock.wp53.cn',
// host2: 'https://test.wp53.cn',
host: 'https://clock.wp53.cn',
host2: 'https://test.wp53.cn',
appId: 'wxc1246ea029394785',
miniProgram: {
clock: 'wxdeee20e52a1fd7ee'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment