diff --git a/pages.json b/pages.json index ddaad60e032b36c67c58200d12a29f90999a26be..f067a47ccc219e6ed95ca9bc08b834c9e61749e3 100644 --- a/pages.json +++ b/pages.json @@ -615,7 +615,7 @@ { "path": "pages/API/choose-image/choose-image", "style": { - "navigationBarTitleText": "图片" + "navigationBarTitleText": "拍摄图片或从相册中选择图片" } }, // #ifdef APP-ANDROID @@ -635,13 +635,13 @@ }, // #endif // #ifdef APP - // { - // "path" : "pages/API/choose-video/choose-video", - // "style" : - // { - // "navigationBarTitleText" : "拍摄视频或从相册中选择视频" - // } - // }, + { + "path" : "pages/API/choose-video/choose-video", + "style" : + { + "navigationBarTitleText" : "拍摄视频或从相册中选择视频" + } + }, { "path" : "pages/API/save-video-to-photos-album/save-video-to-photos-album", "style" : @@ -658,13 +658,13 @@ "navigationBarTitleText" : "获取视频信息" } }, - // { - // "path" : "pages/API/compress-video/compress-video", - // "style" : - // { - // "navigationBarTitleText" : "压缩视频" - // } - // }, + { + "path" : "pages/API/compress-video/compress-video", + "style" : + { + "navigationBarTitleText" : "压缩视频" + } + }, // #endif { "path": "pages/API/get-network-type/get-network-type", diff --git a/pages/API/choose-image/choose-image.uvue b/pages/API/choose-image/choose-image.uvue index 622eeed59bd9d70cbdc5cef2dcafcc0a13593667..0b208b1ea2d64053bc056ca770c987516b0c99d5 100644 --- a/pages/API/choose-image/choose-image.uvue +++ b/pages/API/choose-image/choose-image.uvue @@ -113,7 +113,7 @@ export default { data() { return { - title: 'choose/previewImage', + title: 'chooseImage', imageList: [] as Array, sourceTypeIndex: 2, sourceType: ['拍照', '相册', '拍照或相册'], diff --git a/pages/API/choose-video/choose-video.uvue b/pages/API/choose-video/choose-video.uvue new file mode 100644 index 0000000000000000000000000000000000000000..553cd674615f030e0504347be64477737a767fa1 --- /dev/null +++ b/pages/API/choose-video/choose-video.uvue @@ -0,0 +1,79 @@ + + + + + diff --git a/pages/API/compress-image/compress-image.uvue b/pages/API/compress-image/compress-image.uvue index 3092d6880ec32167551dc5f4fcba49f0ef6f648f..30ed5370624e32f2132f01c5677069c449ad8dfd 100644 --- a/pages/API/compress-image/compress-image.uvue +++ b/pages/API/compress-image/compress-image.uvue @@ -24,14 +24,12 @@ - - - - - + @confirm="onQualityConfirm"> + + + + + @@ -56,6 +54,16 @@ }, methods: { compressImage() { + if (this.beforeCompressPath == "") { + uni.showToast({ + title: "请先选择图片", + icon: "error" + }); + return; + } + uni.showLoading({ + title: "图片压缩中" + }); uni.compressImage({ src: this.beforeCompressPath, quality: this.quality, @@ -64,24 +72,29 @@ width: this.width, height: this.height, rotate: this.rotate, - success: (_res) => { - this.afterCompressPath = _res.tempFilePath; + success: (res) => { + console.log("compressImage success", JSON.stringify(res)); + this.afterCompressPath = res.tempFilePath; uni.showToast({ title: "压缩成功", icon: null }); uni.getImageInfo({ - src: _res.tempFilePath, - success: (res) => { - this.afterCompressImageInfo = `图片宽度: ${res.width}, 图片高度: ${res.height}`; + src: res.tempFilePath, + success: (_res) => { + this.afterCompressImageInfo = `图片宽度: ${_res.width}, 图片高度: ${_res.height}`; } }); }, fail: (err) => { uni.showModal({ - title: "压缩失败", - content: JSON.stringify(err) - }) + title: "压缩图片失败", + content: JSON.stringify(err), + showCancel: false + }); + }, + complete: (_) => { + uni.hideLoading(); } }) }, @@ -90,33 +103,33 @@ count: 1, sizeType: ["original"], sourceType: ["album"], - success: (_res) => { - this.beforeCompressPath = _res.tempFilePaths[0]; + success: (res) => { + this.beforeCompressPath = res.tempFilePaths[0]; uni.getImageInfo({ - src: _res.tempFilePaths[0], - success: (res) => { - this.beforeCompressImageInfo = `图片宽度: ${res.width}, 图片高度: ${res.height}`; + src: res.tempFilePaths[0], + success: (_res) => { + this.beforeCompressImageInfo = `图片宽度: ${_res.width}, 图片高度: ${_res.height}`; } }); } }); }, - onQualityInputConfirm(value : number) { + onQualityConfirm(value : number) { this.quality = value; }, - onCompressedWidthInputConfirm(value : number) { + onCompressedWidthConfirm(value : number) { this.compressedWidth = value; }, - onCompressedHeightInputConfirm(value : number) { + onCompressedHeightConfirm(value : number) { this.compressedHeight = value; }, - onWidthInputConfirm(value : string) { + onWidthConfirm(value : string) { this.width = value; }, - onHeightInputConfirm(value : string) { + onHeightConfirm(value : string) { this.height = value; }, - onRotateInputConfirm(value : number) { + onRotateConfirm(value : number) { this.rotate = value; } } diff --git a/pages/API/compress-video/compress-video.uvue b/pages/API/compress-video/compress-video.uvue new file mode 100644 index 0000000000000000000000000000000000000000..f81d94ed775f00a09173d01e5b2b5afc70be396d --- /dev/null +++ b/pages/API/compress-video/compress-video.uvue @@ -0,0 +1,132 @@ + + + + + diff --git a/pages/API/get-image-info/get-image-info.uvue b/pages/API/get-image-info/get-image-info.uvue index 152bbd94f34df9025c34a13260283bae8a8787dd..1312188f937c688d358041ae92261fe17ba3ef97 100644 --- a/pages/API/get-image-info/get-image-info.uvue +++ b/pages/API/get-image-info/get-image-info.uvue @@ -45,12 +45,20 @@ chooseImage() { uni.chooseImage({ count: 1, - success: (_res) => { - this.absoluteImagePath = _res.tempFilePaths[0]; + success: (res) => { + this.absoluteImagePath = res.tempFilePaths[0]; uni.getImageInfo({ - src: _res.tempFilePaths[0], - success: (res) => { - this.relativeImageInfo = `图片宽度: ${res.width}\n图片高度: ${res.height}\n图片路径: ${res.path}\n图片方向: ${res.orientation}\n图片格式: ${res.type}`; + src: res.tempFilePaths[0], + success: (_res) => { + console.log("getImageInfo success", JSON.stringify(res)); + this.relativeImageInfo = `图片宽度: ${_res.width}\n图片高度: ${_res.height}\n图片路径: ${_res.path}\n图片方向: ${_res.orientation}\n图片格式: ${_res.type}`; + }, + fail: (err) => { + uni.showModal({ + title: "获取图片信息失败", + content: JSON.stringify(err), + showCancel: false + }); } }); } @@ -61,13 +69,29 @@ uni.getImageInfo({ src: this.relativeImagePath, success: (res) => { + console.log("getImageInfo success", JSON.stringify(res)); this.absoluteImageInfo = `图片宽度: ${res.width}\n图片高度: ${res.height}\n图片路径: ${res.path}\n图片方向: ${res.orientation}\n图片格式: ${res.type}`; + }, + fail: (err) => { + uni.showModal({ + title: "获取图片信息失败", + content: JSON.stringify(err), + showCancel: false + }); } }); uni.getImageInfo({ src: this.remoteImagePath, success: (res) => { + console.log("getImageInfo success", JSON.stringify(res)); this.remoteImageInfo = `图片宽度: ${res.width}\n图片高度: ${res.height}\n图片路径: ${res.path}\n图片方向: ${res.orientation}\n图片格式: ${res.type}`; + }, + fail: (err) => { + uni.showModal({ + title: "获取图片信息失败", + content: JSON.stringify(err), + showCancel: false + }); } }); } diff --git a/pages/API/get-video-info/get-video-info.uvue b/pages/API/get-video-info/get-video-info.uvue index 18095fa9b99cd0d283be6ddafe83ab735ffc5822..972794f612ac6fc78ccec450191a3ded3ac606e3 100644 --- a/pages/API/get-video-info/get-video-info.uvue +++ b/pages/API/get-video-info/get-video-info.uvue @@ -31,12 +31,20 @@ chooseVideo() { uni.chooseVideo({ compressed: false, - success: (_res) => { - this.absoluteVideoPath = _res.tempFilePath; + success: (res) => { + this.absoluteVideoPath = res.tempFilePath; uni.getVideoInfo({ - src: _res.tempFilePath, - success: (res) => { - this.absoluteVideoInfo = `视频画面方向: ${res.orientation}\n视频格式: ${res.type}\n视频长度: ${res.duration}s\n视频大小: ${Math.ceil(res.size / 1024)}kB\n视频宽度: ${res.width}\n视频高度: ${res.height}\n视频帧率: ${res.fps}fps\n视频码率: ${res.bitrate}kbps`; + src: res.tempFilePath, + success: (_res) => { + console.log("getVideoInfo success", JSON.stringify(res)); + this.absoluteVideoInfo = `视频画面方向: ${_res.orientation}\n视频格式: ${_res.type}\n视频长度: ${_res.duration}s\n视频大小: ${Math.ceil(_res.size / 1024)}kB\n视频宽度: ${_res.width}\n视频高度: ${_res.height}\n视频帧率: ${_res.fps}fps\n视频码率: ${_res.bitrate}kbps`; + }, + fail: (err) => { + uni.showModal({ + title: "获取视频信息失败", + content: JSON.stringify(err), + showCancel: false + }); } }); } diff --git a/pages/API/save-image-to-photos-album/save-image-to-photos-album.uvue b/pages/API/save-image-to-photos-album/save-image-to-photos-album.uvue index 69321ff1b08aa6f7921672a47a021cd149c97b60..b6e87e2eac68d75375738d56bb6fd5482414b24b 100644 --- a/pages/API/save-image-to-photos-album/save-image-to-photos-album.uvue +++ b/pages/API/save-image-to-photos-album/save-image-to-photos-album.uvue @@ -23,16 +23,18 @@ saveImage() { uni.saveImageToPhotosAlbum({ filePath: "/static/uni.png", - success() { + success: (res) => { + console.log("saveImageToPhotosAlbum success", JSON.stringify(res)); uni.showToast({ position: "center", icon: "none", title: "图片保存成功,请到手机相册查看" }) }, - fail(e) { + fail: (err) => { uni.showModal({ - content: "保存相册失败,errCode:" + e.errCode + ",errMsg:" + e.errMsg + ",errSubject:" + e.errSubject, + title: "保存图片到相册失败", + content: JSON.stringify(err), showCancel: false }); } diff --git a/pages/API/save-video-to-photos-album/save-video-to-photos-album.uvue b/pages/API/save-video-to-photos-album/save-video-to-photos-album.uvue index 8bc25ff5864cfc4b2bf476b4c9b10b2c519d6bd8..b3be4e604588736bcfb656bc392c96ebf2dda417 100644 --- a/pages/API/save-video-to-photos-album/save-video-to-photos-album.uvue +++ b/pages/API/save-video-to-photos-album/save-video-to-photos-album.uvue @@ -25,15 +25,17 @@ uni.saveVideoToPhotosAlbum({ filePath: this.src, success: (_) => { + console.log("saveVideoToPhotosAlbum success"); uni.showToast({ position: "center", icon: "none", title: "视频保存成功,请到手机相册查看" }); }, - fail: (e) => { + fail: (err) => { uni.showModal({ - content: "保存相册失败,errCode:" + e.errCode + ",errMsg:" + e.errMsg + ",errSubject:" + e.errSubject, + title: "保存视频到相册失败", + content: JSON.stringify(err), showCancel: false }); } diff --git a/pages/tabBar/API.uvue b/pages/tabBar/API.uvue index a122356dc93d3eb0e7b59ef2c3fa8b7b250e0052..fd634ee53e91f6b03c9fc2cfb81e35e6eb553fe2 100644 --- a/pages/tabBar/API.uvue +++ b/pages/tabBar/API.uvue @@ -359,10 +359,10 @@ }, // #endif // #ifdef APP - // { - // name: "拍摄视频或从相册中选择视频", - // url: 'choose-video' - // }, + { + name: "拍摄视频或从相册中选择视频", + url: 'choose-video' + }, { name: "保存视频到相册", url: 'save-video-to-photos-album' @@ -373,10 +373,10 @@ name: "获取视频信息", url: 'get-video-info' }, - // { - // name: "压缩视频", - // url: 'compress-video' - // }, + { + name: "压缩视频", + url: 'compress-video' + }, // #endif /* { name: "图片选择和拍照",