Commit 316ebea1352ba44291fdcba4177ff6f5ce1c844a
1 parent
ae62962a
使用同步,保证图片获取成功
Showing
1 changed file
with
47 additions
and
33 deletions
packageA/pages/liveStreamDetails/liveStreamDetails.js
... | ... | @@ -9,6 +9,7 @@ var t = require("../../../utils/util.js"), |
9 | 9 | oo = s.globalData, |
10 | 10 | o = s.globalData.setting, |
11 | 11 | os = o; |
12 | +var regeneratorRuntime = require('../../../utils/runtime.js'); | |
12 | 13 | |
13 | 14 | const app = getApp(); |
14 | 15 | |
... | ... | @@ -148,15 +149,59 @@ drawText: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, un |
148 | 149 | }, |
149 | 150 | |
150 | 151 | // 生成海报 |
151 | - drawPlaybill: function () { | |
152 | + drawPlaybill: async function () { | |
153 | + | |
154 | + var that=this; | |
152 | 155 | // wx.showLoading({ |
153 | 156 | // title: '正在生成海报...' |
154 | 157 | // }); |
158 | + | |
159 | + | |
160 | + if(!this.data.coverImg) { | |
161 | + | |
162 | + // 请求主图 | |
163 | + await that.getImageInfo(that.data.details['share_img']).then(res => { | |
164 | + that.setData({ | |
165 | + coverImg: res.path, | |
166 | + coverImgWidth: res.width, | |
167 | + coverImgHeight: res.height, | |
168 | + coverImgSize: that.imageResize(res.width, res.height), | |
169 | + // coverImgHeight: res.height, | |
170 | + }); | |
171 | + // console.log('主图加载成功~', that.data.coverImgSize); | |
172 | + }); | |
173 | + } | |
174 | + | |
175 | + if(!this.data.avatarUrl) { | |
176 | + | |
177 | + // 请求头像 | |
178 | + await that.getImageInfo(app.globalData.userInfo['head_pic']).then(res => { | |
179 | + that.setData({ | |
180 | + avatarUrl: res.path | |
181 | + }); | |
182 | + console.log('头像加载成功~') | |
183 | + }); | |
184 | + } | |
185 | + | |
186 | + // 请求二维码 | |
187 | + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + | |
188 | + os.stoid + "?sceneValue=1012" + "&pageValue=pages/goods/goodsInfo/goodsInfo"; | |
189 | + | |
190 | + if(!this.data.ewm) { | |
191 | + | |
192 | + await that.getImageInfo(path3).then(res => { | |
193 | + that.setData({ | |
194 | + ewm: res.path | |
195 | + }); | |
196 | + console.log('二维码加载成功~') | |
197 | + }); | |
198 | + } | |
199 | + | |
200 | + | |
155 | 201 | |
156 | 202 | // 数据准备 |
157 | 203 | const title = this.data.details.name; |
158 | 204 | // const headImg = app.globalData.userInfo['head_pic']; |
159 | - const that = this; | |
160 | 205 | |
161 | 206 | // console.log('----------------v', headImg); |
162 | 207 | |
... | ... | @@ -479,37 +524,6 @@ drawText: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, un |
479 | 524 | } |
480 | 525 | |
481 | 526 | |
482 | - | |
483 | - // 请求主图 | |
484 | - that.getImageInfo(that.data.details['share_img']).then(res => { | |
485 | - that.setData({ | |
486 | - coverImg: res.path, | |
487 | - coverImgWidth: res.width, | |
488 | - coverImgHeight: res.height, | |
489 | - coverImgSize: that.imageResize(res.width, res.height), | |
490 | - // coverImgHeight: res.height, | |
491 | - }); | |
492 | - // console.log('主图加载成功~', that.data.coverImgSize); | |
493 | - }); | |
494 | - | |
495 | - // 请求头像 | |
496 | - that.getImageInfo(app.globalData.userInfo['head_pic']).then(res => { | |
497 | - that.setData({ | |
498 | - avatarUrl: res.path | |
499 | - }); | |
500 | - console.log('头像加载成功~') | |
501 | - }); | |
502 | - | |
503 | - // 请求二维码 | |
504 | - var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + | |
505 | - os.stoid + "?sceneValue=1012" + "&pageValue=pages/goods/goodsInfo/goodsInfo"; | |
506 | - that.getImageInfo(path3).then(res => { | |
507 | - that.setData({ | |
508 | - ewm: res.path | |
509 | - }); | |
510 | - console.log('二维码加载成功~') | |
511 | - }); | |
512 | - | |
513 | 527 | } |
514 | 528 | }) |
515 | 529 | ... | ... |