diff --git a/src/image-picker/index.js b/src/image-picker/index.js index ff99d9d1..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({ @@ -47,6 +46,11 @@ Component({ type: Number, value: 9 }, + sourceType: { + // 图片和视频选择的来源 + optionalTypes: [Array, String], + value: ['album', 'camera'] + }, sizeType: { // 该写法经测试有效 optionalTypes: [Array, String], @@ -215,17 +219,19 @@ 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; } // 调用微信 api 选择图片 - const chooseImageRes = await promisic(wx.chooseImage)({ + const chooseImage = wx.chooseMedia || wx.chooseImage; + const chooseImageRes = await chooseImage({ count: remainCount, + mediaType: ['image'], sizeType, - sourceType: ['album', 'camera'], + sourceType, }); // 即将被添加的图片的 url 数组 @@ -234,7 +240,8 @@ Component({ const oversizeImageUrlArray = []; chooseImageRes.tempFiles.forEach((tempFile) => { - const {path, size} = tempFile; + const path = wx.chooseMedia ? tempFile.tempFilePath : tempFile.path; + const size = tempFile.size; if (size > maxImageSize && maxImageSize > 0) { oversizeImageUrlArray.push(path); } else { 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,