wl-design-mobile 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/util/jssdk.js +47 -19
package/package.json
CHANGED
package/util/jssdk.js
CHANGED
|
@@ -250,39 +250,67 @@ let JsSDK = (function () {
|
|
|
250
250
|
}
|
|
251
251
|
})
|
|
252
252
|
}
|
|
253
|
-
function takePhoto(){
|
|
253
|
+
function takePhoto({count = 1} = {}){
|
|
254
254
|
return new Promise((resolve, reject) =>{
|
|
255
255
|
if(getAppType() === '30'){
|
|
256
256
|
reject('钉钉不支持此方式拍照')
|
|
257
257
|
}else{
|
|
258
258
|
configWx().then(()=>{
|
|
259
259
|
wx.chooseImage({
|
|
260
|
-
count:
|
|
260
|
+
count: count, // 默认1
|
|
261
261
|
sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
262
262
|
sourceType: ['camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
263
|
-
success: function (res) {
|
|
263
|
+
success: async function (res) {
|
|
264
264
|
let localIds = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
|
|
265
|
-
let localId = localIds[0];
|
|
266
265
|
Toast.loading({
|
|
267
266
|
duration: 0, // 持续展示 toast
|
|
268
267
|
forbidClick: false,
|
|
269
268
|
message: '正在上传',
|
|
270
269
|
});
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
})
|
|
285
|
-
}
|
|
270
|
+
let uploadPromises = localIds.map(localId => {
|
|
271
|
+
return new Promise((resolve, reject) => {
|
|
272
|
+
wx.uploadImage({
|
|
273
|
+
localId: localId, // 需要上传的图片的本地ID,由chooseImage接口获得
|
|
274
|
+
isShowProgressTips: 0, // 默认为1,显示进度提示
|
|
275
|
+
success: function (res) {
|
|
276
|
+
let serverId = res.serverId; // 返回图片的服务器端ID
|
|
277
|
+
resolve(serverId);
|
|
278
|
+
},
|
|
279
|
+
fail: function (error) {
|
|
280
|
+
reject(error);
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
try {
|
|
286
|
+
let serverIds = await Promise.all(uploadPromises);
|
|
287
|
+
console.log('choosePhoto', serverIds)
|
|
288
|
+
Toast.clear()
|
|
289
|
+
resolve({
|
|
290
|
+
appId: sessionStorage.getItem(APP_ID),
|
|
291
|
+
agentId: sessionStorage.getItem(AGENT_ID),
|
|
292
|
+
serverId: serverIds[0],
|
|
293
|
+
serverIds: serverIds
|
|
294
|
+
});
|
|
295
|
+
} catch (error) {
|
|
296
|
+
Toast.clear()
|
|
297
|
+
reject('上传图片失败:' + error);
|
|
298
|
+
}
|
|
299
|
+
// setTimeout(() => {
|
|
300
|
+
// wx.uploadImage({
|
|
301
|
+
// localId: localId, // 需要上传的图片的本地ID,由chooseImage接口获得
|
|
302
|
+
// isShowProgressTips: 0, // 默认为1,显示进度提示
|
|
303
|
+
// success: function (res) {
|
|
304
|
+
// Toast.clear()
|
|
305
|
+
// let serverId = res.serverId; // 返回图片的服务器端ID
|
|
306
|
+
// resolve({
|
|
307
|
+
// appId:sessionStorage.getItem(APP_ID),
|
|
308
|
+
// agentId:sessionStorage.getItem(AGENT_ID),
|
|
309
|
+
// serverId:serverId
|
|
310
|
+
// })
|
|
311
|
+
// }
|
|
312
|
+
// })
|
|
313
|
+
// }, 200);
|
|
286
314
|
},
|
|
287
315
|
cancel:function (){
|
|
288
316
|
reject('取消拍照')
|