Przeglądaj źródła

bug修复

master
suizhijia 5 lat temu
rodzic
commit
4b1118784e
1 zmienionych plików z 8 dodań i 8 usunięć
  1. +8
    -8
      496_dongfengqichen/pages/poster/poster.js

+ 8
- 8
496_dongfengqichen/pages/poster/poster.js Wyświetl plik

@@ -41,11 +41,13 @@ Page({
onLoad: function (options) {
app.globalData.nowPage = 2;
},

/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
_totalDownloadTask = 6;
_currentSuccessDownloadTask = 0;
_saveImg = false;
if(app.globalData.userInfoData && app.globalData.userInfoData.avatarUrl){
this.data.userHead = app.globalData.userInfoData.avatarUrl;
this.setData({
@@ -62,6 +64,7 @@ Page({
}
},
cacheFun:function(){
// _saveImg = true;
wx.getSystemInfo({
success: option => {
this.data.windowScale = option.windowWidth / 750;
@@ -163,9 +166,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
_totalDownloadTask = 6;
_currentSuccessDownloadTask = 0;
_saveImg = false;

},

/**
@@ -208,21 +209,19 @@ Page({
}
},
saveImg: function () {//保存到手机
console.log(this.data.posterUrl);
if (!this.data.posterUrl[this.data.swiperCurrent]){
wx.showLoading({
title: '海报合成中',
mask:true
})
console.log("swiperCurrent = " + this.data.swiperCurrent)
_saveImg = true;
// console.log("值1:"+_currentSuccessDownloadTask);
this.posterDrawing(this.data.swiperCurrent + 1);
}else{
this.savePic();
}
},
savePic: function () {
wx.hideLoading();
wx.saveImageToPhotosAlbum({
filePath: this.data.posterUrl[this.data.swiperCurrent],
success(res) {
@@ -276,6 +275,7 @@ Page({
// console.log("_totalDownloadTask = " + _totalDownloadTask)
// console.log("_currentSuccessDownloadTask = " + _currentSuccessDownloadTask)
//图片尚未下载完成,禁止绘制
// console.log("值2:"+_currentSuccessDownloadTask);
if(_currentSuccessDownloadTask < _totalDownloadTask || !_saveImg){
return;
}
@@ -290,7 +290,6 @@ Page({
//先画个圆 前两个参数确定了圆心 (x,y) 坐标 第三个参数是圆的半径 四参数是绘图方向 默认是false,即顺时针
ctx.arc(scale * 50 / 2 + scale * 121, scale * 50 / 2 + scale * 62, scale * 50 / 2, 0, Math.PI * 2, false);
ctx.clip(); //剪切
console.log(this.data.userHead)
ctx.drawImage(this.data.userHead, scale * 121, scale * 62, scale * 50, scale * 50); //头像
ctx.restore(); //恢复之前保存的绘图上下文
//名称
@@ -323,6 +322,7 @@ Page({
canvasId: 'myCanvas',
success: res => {
this.data.posterUrl[this.data.swiperCurrent] = res.tempFilePath;
wx.hideLoading();
this.savePic();
}
})

Ładowanie…
Anuluj
Zapisz