阿里云个人网站备案做淘客,企业所得税避税方法,南通有哪些网站,国家企业信息公示系统官网官获得后缀名判断类型,如果是图片用ex.previewImage(),如果是视频,用uni.previewMedia(),如果是word文档这些的,用 uni.downloadFile来下载资源后用 uni.saveFile来保存到本地,uni.openDocument来打开新的网页,如果打不开的话则返回说到PC端去打开 const lookFile (url) {l…获得后缀名判断类型,如果是图片用ex.previewImage(),如果是视频,用uni.previewMedia(),如果是word文档这些的,用 uni.downloadFile来下载资源后用 uni.saveFile来保存到本地,uni.openDocument来打开新的网页,如果打不开的话则返回说到PC端去打开 const lookFile (url) {let index url.lastIndexOf(.);let filttype url.slice(index 1);if (url.includes(?token)) {filttype url.split(?token)[0].split(.).slice(-1);}uni.showLoading({title: 加载中,mask: true,});if ([bmp, jpg, jpeg, png, gif, image].some((item) item filttype)) {uni.previewImage({current: url, // 当前显示图片的 http 链接urls: [url], // 需要预览的图片 http 链接列表success() {uni.hideLoading();},});} else if ([mp4, avi].some((item) item filttype)) {uni.previewMedia({sources: [{url,type: video,},], // 需要预览的资源列表current: 1, // 当前显示的资源序号,success() {uni.hideLoading();},fail: function (err) {uni.showToast({title: 播放失败,icon: none,});console.log(err);},});} else if ([zip, rar].some((item) item filttype)) {uni.showToast({title: 暂不支持预览,icon: none,});} else {uni.downloadFile({//下载url, // 从后端获取的url地址赋值在标签的data属性上header: {token: uni.getStorageSync(token),content-type: application/x-www-form-urlencoded;charsetUTF-8,},success: function (res) {const tempFilePath res.tempFilePath;uni.openDocument({//新开页面打开文档filePath: tempFilePath,showMenu: true,fileType: filttype,success: function (res) {console.log(打开文档成功);},fail: function (err) {console.log(打开文档失败, err);},complete: () {uni.hideLoading();},});/* uni.saveFile({//保存文件到本地tempFilePath,success(res) {const savedFilePath res.savedFilePath;const filttypeName filttype;uni.openDocument({//新开页面打开文档filePath: savedFilePath,showMenu: true,fileType: filttypeName,success: function (res) {console.log(打开文档成功);},fail: function (err) {console.log(打开文档失败, err);},complete: () {uni.hideLoading();},});},}); */},fail: function (err) {uni.showToast({title: 下载失败,icon: none,});console.log(err);},});}
};