{
load_activity: function () {
var that = this;
wx.showLoading({
title: '图片生成中',
})
wx.request({
url: app.globalData.webservice_url + 'biz/activity/saveSharePic',
data: JSON.stringify(app.encode({
activityId: that.data.activityid,
width: that.data.width,
height: that.data.height
})),
header: {
'X-Token': wx.getStorageSync('token')
},
method: 'POST',
success: function (res) {
if (res.data.code === 1) {
if (res.data.data) {
that.setData({
activity: res.data.data
}, function () {
that.timer_helper(res.data.data.shareActivityPath);
})
} else {
app.showModal('提示', res.data.desc);
}
} else {
app.showModal('提示', res.data.desc);
}
},
fail: function (res) {
app.showModal('提示', res.errMsg);
},
complete: function (res) {
console.log(res);
}
})
},
timer_helper: function (path) {
var that = this;
app.globalData.timer_canvas = setInterval(function () {
clearInterval(app.globalData.timer_canvas);
wx.getImageInfo({
src: app.globalData.file_url_server + path,
success(res1) {
that.setData({
path: res1.path
}, function () {
wx.saveImageToPhotosAlbum({
filePath: res1.path,
success(res) {
wx.showToast({
title: '已保存到本地相册',
})
}
})
})
},
fail(res1) {
that.timer_helper(path);
},
complete(res1) {
}
})
}, 2000)
}
}
网友评论