Browse Source

海报提示

threedate
Enzo 4 years ago
parent
commit
ac09a2a8d4
  1. 31
      pages/goodsDetail/index.vue

31
pages/goodsDetail/index.vue

@ -172,6 +172,7 @@
wx.getImageInfo({ wx.getImageInfo({
src: img, src: img,
success: function(sres) { success: function(sres) {
uni.showLoading({title:'生成海报中...'})
_this.backgroundImg = sres.path; _this.backgroundImg = sres.path;
_this.isShowButtonCount++; _this.isShowButtonCount++;
resolve(); // resolve(); //
@ -224,6 +225,9 @@
}, },
getWxCode() { getWxCode() {
let that = this; let that = this;
uni.showLoading({
title: '生成海报中...'
})
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const token = that.$shared.createToken({ const token = that.$shared.createToken({
user_id: that.userInfo.id, user_id: that.userInfo.id,
@ -256,6 +260,9 @@
var imgSrc = this.wxCode; //base64 var imgSrc = this.wxCode; //base64
var save = wx.getFileSystemManager(); var save = wx.getFileSystemManager();
var number = Math.random(); var number = Math.random();
uni.showLoading({
title: '生成海报中...'
})
save.writeFile({ save.writeFile({
filePath: wx.env.USER_DATA_PATH + '/pic' + number + '.jpg', filePath: wx.env.USER_DATA_PATH + '/pic' + number + '.jpg',
data: imgSrc, data: imgSrc,
@ -325,7 +332,6 @@
context.draw(); context.draw();
// //
setTimeout(function() { setTimeout(function() {
uni.hideLoading(); // loading
wx.canvasToTempFilePath({ wx.canvasToTempFilePath({
canvasId: 'mycanvas', canvasId: 'mycanvas',
success: function(res) { success: function(res) {
@ -334,7 +340,7 @@
that.canvasHidden = true that.canvasHidden = true
that.maskHidden = true that.maskHidden = true
} }
wx.hideToast()
uni.hideLoading()
console.log('海报生成成功') console.log('海报生成成功')
console.log(res) console.log(res)
console.log('图片链接', that.imagePath) console.log('图片链接', that.imagePath)
@ -370,16 +376,19 @@
}, },
formSubmit() { formSubmit() {
var that = this; var that = this;
wx.showToast({
title: '生成海报中...',
icon: 'loading',
duration: 100000
});
Promise.all([that.getWxCode(), that.getBackground()]).then(res => {
that.createNewImg();
}).catch(err => {
this.$msg('生成失败,请稍后重试!');
uni.showLoading({
title: '生成海报中...'
}) })
if(that.backgroundImg && that.onceCode){
that.createNewImg();
}else {
Promise.all([that.getWxCode(), that.getBackground()]).then(res => {
that.createNewImg();
}).catch(err => {
this.$msg('生成失败,请稍后重试!');
})
}
}, },
// //
getGoodsDetail() { getGoodsDetail() {

Loading…
Cancel
Save