TestRestructureWechatLymark.../dist/pages/applyGoods/sub-common/77c6c00ee9ac4bfa87e3885cb3a9f4ce.js
2023-05-15 16:21:46 +08:00

1 line
3.2 KiB
JavaScript

"use strict";(wx.webpackJsonp=wx.webpackJsonp||[]).push([[3338],{1980:function(e,t,n){var c=n(4165),a=n(5861),o=n(2954),s=n.n(o),r=n(2495),i=n(6189);t.Z=function(){var e=(0,i.C)().fetchData,t=function uploadCDNImg(t,n,o){var i=t.path;return console.log("filetype::",i),function getFileType(e){return!!e&&(RegExp(".?(".concat(["gif","jpeg","jpg","bmp","png"].join("|"),")$"),"i").test(e.toLowerCase())?"image":!!RegExp(".(".concat(["avi","wmv","mkv","mp4","mov","rm","3gp","flv","mpg","rmvb","quicktime"].join("|"),")$"),"i").test(e.toLowerCase())&&"video")}(i)?new Promise((function(o,i){(function getSecret(t,n){return new Promise(function(){var n=(0,a.Z)((0,c.Z)().mark((function _callee(n,a){var o,s,r;return(0,c.Z)().wrap((function _callee$(c){for(;;)switch(c.prev=c.next){case 0:return o="/".concat(t,"/{filemd5}{day}{hour}{min}{sec}{.suffix}"),s={method:"post",save_key:o},c.next=4,e(s);case 4:(r=c.sent).success?n(r.data):a({code:r.code||"9999",msg:r.msg});case 6:case"end":return c.stop()}}),_callee)})));return function(e,t){return n.apply(this,arguments)}}())})(n).then((function(e){var n=e;console.log("bucket",n.bucket);var c={authorization:n.authorization,policy:n.policy},a=s().uploadFile({url:"".concat(r.Fu).concat(n.bucket),formData:c,filePath:t.path,name:"file",success:function success(e){o(JSON.parse("".concat(e.data)))},fail:function fail(e){console.log(e),i(e)}});a.progress((function(e){console.log("上传进度",e.progress),e.progress<100?s().showLoading({title:"上传中..."}):s().hideLoading()}))})).catch((function(e){i(e),s().showToast({title:"获取密钥失败!",icon:"none",duration:3800})}))})):(s().showToast({title:"上传文件类型错误",icon:"none",duration:3800}),!1)};return{uploadCDNImg:t,getWxPhoto:function getWxPhoto(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return new Promise((function(o,r){var i=[];s().chooseImage({count:n,sizeType:["original","compressed"],sourceType:["album","camera"],success:function success(s){return(0,a.Z)((0,c.Z)().mark((function _callee2(){var a,u,l;return(0,c.Z)().wrap((function _callee2$(c){for(;;)switch(c.prev=c.next){case 0:if(c.prev=0,!(n>1)){c.next=14;break}a=0;case 3:if(!(a<s.tempFiles.length)){c.next=11;break}return c.next=6,t(s.tempFiles[a],e);case 6:u=c.sent,i.push(u);case 8:a++,c.next=3;break;case 11:o(i),c.next=18;break;case 14:return c.next=16,t(s.tempFiles[0],e);case 16:l=c.sent,o(l);case 18:c.next=23;break;case 20:c.prev=20,c.t0=c.catch(0),r(c.t0);case 23:case"end":return c.stop()}}),_callee2,null,[[0,20]])})))()}})}))},getChatPhoto:function getChatPhoto(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return new Promise((function(o,r){var i=[];s().chooseMessageFile({count:n,type:"image",success:function success(s){return(0,a.Z)((0,c.Z)().mark((function _callee3(){var a,u,l;return(0,c.Z)().wrap((function _callee3$(c){for(;;)switch(c.prev=c.next){case 0:if(c.prev=0,!(n>1)){c.next=14;break}a=0;case 3:if(!(a<s.tempFiles.length)){c.next=11;break}return c.next=6,t(s.tempFiles[a],e);case 6:u=c.sent,i.push(u);case 8:a++,c.next=3;break;case 11:o(i),c.next=18;break;case 14:return c.next=16,t(s.tempFiles[0],e);case 16:l=c.sent,o(l);case 18:c.next=23;break;case 20:c.prev=20,c.t0=c.catch(0),r(c.t0);case 23:case"end":return c.stop()}}),_callee3,null,[[0,20]])})))()}})}))}}}}}]);