From 3bf5efcaf5a3f963b4cba306f7ac93ffab65e154 Mon Sep 17 00:00:00 2001 From: qiushiming Date: Wed, 10 May 2023 13:44:47 +0800 Subject: [PATCH 1/7] =?UTF-8?q?feat(Input):=20type=20property=20options=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20nickname?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/input/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/input/index.js b/src/input/index.js index 378c9ec7..2038b305 100644 --- a/src/input/index.js +++ b/src/input/index.js @@ -32,7 +32,7 @@ Component({ type: { type: String, value: 'text', - options: ['text', 'idcard', 'digit', 'password', 'number'] + options: ['text', 'idcard', 'digit', 'password', 'number', 'nickname'] }, // 输入框的值 value: String, From 6d1bc62ab8d4b337fbd32a3dcf8a136d824f9719 Mon Sep 17 00:00:00 2001 From: Jabin Kong <1059978534@qq.com> Date: Thu, 10 Aug 2023 15:55:30 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20image-picker=EF=BC=8Cw?= =?UTF-8?q?x.chooseImage=E6=9B=BF=E6=8D=A2=E4=B8=BAwx.chooseMedia?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1、由于从基础库 2.21.0 开始 wx.chooseImage 已停止维护 如果基础库支持 wx.chooseMedia,则将 wx.chooseImage 替换为 wx.chooseMedia 2、将 sourceType 修改为参数传入形式,默认值是 ['album', 'camera'],可由用户传入参数自行选择图片来源 --- src/image-picker/index.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/image-picker/index.js b/src/image-picker/index.js index ff99d9d1..21eae159 100644 --- a/src/image-picker/index.js +++ b/src/image-picker/index.js @@ -47,6 +47,11 @@ Component({ type: Number, value: 9 }, + sourceType: { + // 图片和视频选择的来源 + optionalTypes: [Array, String], + value: ['album', 'camera'] + }, sizeType: { // 该写法经测试有效 optionalTypes: [Array, String], @@ -222,11 +227,21 @@ Component({ } // 调用微信 api 选择图片 - const chooseImageRes = await promisic(wx.chooseImage)({ - count: remainCount, - sizeType, - sourceType: ['album', 'camera'], - }); + let chooseImageRes + if (wx.chooseMedia) { + chooseImageRes = await promisic(wx.chooseMedia)({ + count: remainCount, + mediaType: ['image'], + sizeType, + sourceType, + }); + } else { + chooseImageRes = await promisic(wx.chooseImage)({ + count: remainCount, + sizeType, + sourceType, + }); + } // 即将被添加的图片的 url 数组 const addImageUrlArray = []; From 2b3ca7c3f7675acf9bc6c318edbcfd8dff03bcdf Mon Sep 17 00:00:00 2001 From: Jabin Kong <1059978534@qq.com> Date: Thu, 10 Aug 2023 16:14:42 +0800 Subject: [PATCH 3/7] fix image-picker --- src/image-picker/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/image-picker/index.js b/src/image-picker/index.js index 21eae159..f4a2ab09 100644 --- a/src/image-picker/index.js +++ b/src/image-picker/index.js @@ -227,7 +227,7 @@ Component({ } // 调用微信 api 选择图片 - let chooseImageRes + let chooseImageRes; if (wx.chooseMedia) { chooseImageRes = await promisic(wx.chooseMedia)({ count: remainCount, @@ -249,7 +249,15 @@ Component({ const oversizeImageUrlArray = []; chooseImageRes.tempFiles.forEach((tempFile) => { - const {path, size} = tempFile; + let path, size; + if (wx.chooseMedia) { + path = tempFile.tempFilePath; + size = tempFile.size; + } else { + path = tempFile.path; + size = tempFile.size; + } + if (size > maxImageSize && maxImageSize > 0) { oversizeImageUrlArray.push(path); } else { From 9c763e838e64eb19cf2bfaae292fbafb7a493996 Mon Sep 17 00:00:00 2001 From: Jabin Kong <1059978534@qq.com> Date: Thu, 10 Aug 2023 16:50:50 +0800 Subject: [PATCH 4/7] fix image-picker --- src/image-picker/index.js | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/src/image-picker/index.js b/src/image-picker/index.js index f4a2ab09..cbf03edb 100644 --- a/src/image-picker/index.js +++ b/src/image-picker/index.js @@ -227,21 +227,16 @@ Component({ } // 调用微信 api 选择图片 - let chooseImageRes; - if (wx.chooseMedia) { - chooseImageRes = await promisic(wx.chooseMedia)({ - count: remainCount, - mediaType: ['image'], - sizeType, - sourceType, - }); - } else { - chooseImageRes = await promisic(wx.chooseImage)({ - count: remainCount, - sizeType, - sourceType, - }); - } + const chooseImageRes = wx.chooseMedia ? await wx.chooseMedia({ + count: remainCount, + mediaType: ['image'], + sizeType, + sourceType, + }) : await wx.chooseImage({ + count: remainCount, + sizeType, + sourceType, + }); // 即将被添加的图片的 url 数组 const addImageUrlArray = []; @@ -249,15 +244,8 @@ Component({ const oversizeImageUrlArray = []; chooseImageRes.tempFiles.forEach((tempFile) => { - let path, size; - if (wx.chooseMedia) { - path = tempFile.tempFilePath; - size = tempFile.size; - } else { - path = tempFile.path; - size = tempFile.size; - } - + const path = wx.chooseMedia ? tempFile.tempFilePath : tempFile.path; + const size = tempFile.size; if (size > maxImageSize && maxImageSize > 0) { oversizeImageUrlArray.push(path); } else { From 5386334ea0802eb6158201bc5a8220af4fe24852 Mon Sep 17 00:00:00 2001 From: Jabin Kong <1059978534@qq.com> Date: Thu, 10 Aug 2023 17:19:06 +0800 Subject: [PATCH 5/7] =?UTF-8?q?feat(image-picker):=20wx.chooseImage?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=B8=BAwx.chooseMedia=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=8C=96sourceType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/image-picker/index.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/image-picker/index.js b/src/image-picker/index.js index cbf03edb..28e1c034 100644 --- a/src/image-picker/index.js +++ b/src/image-picker/index.js @@ -227,15 +227,12 @@ Component({ } // 调用微信 api 选择图片 - const chooseImageRes = wx.chooseMedia ? await wx.chooseMedia({ + const chooseImage = wx.chooseMedia || wx.chooseImage; + const chooseImageRes = await chooseImage({ count: remainCount, mediaType: ['image'], sizeType, sourceType, - }) : await wx.chooseImage({ - count: remainCount, - sizeType, - sourceType, }); // 即将被添加的图片的 url 数组 From a9ab755d2722debbe9d9b192c471535b1a691409 Mon Sep 17 00:00:00 2001 From: Jabin Kong <1059978534@qq.com> Date: Thu, 10 Aug 2023 17:47:18 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix(image-picker):=20=20#1574=20bug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/image-picker/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image-picker/index.js b/src/image-picker/index.js index 28e1c034..207dd3ad 100644 --- a/src/image-picker/index.js +++ b/src/image-picker/index.js @@ -220,7 +220,7 @@ Component({ * @returns {Promise} */ async onTapAdd() { - let {value, count, sizeType, maxImageSize} = this.data; + let {value, count, sizeType, sourceType, maxImageSize} = this.data; const remainCount = count - value.length; if (value.length >= count || remainCount <= 0) { return; From 0d53a4cc4568a503bfbd53d81a3f8824577b04f6 Mon Sep 17 00:00:00 2001 From: Jabin Kong <1059978534@qq.com> Date: Thu, 10 Aug 2023 18:01:35 +0800 Subject: [PATCH 7/7] =?UTF-8?q?fix(image-picker):=20#1574=20bug=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/image-picker/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/image-picker/index.js b/src/image-picker/index.js index 207dd3ad..424b7368 100644 --- a/src/image-picker/index.js +++ b/src/image-picker/index.js @@ -1,7 +1,6 @@ import nodeUtil from '../core/utils/node-util'; import deviceUtil from '../utils/device-util'; import eventUtil from '../core/utils/event-util'; -import {promisic} from '../utils/util'; Component({