Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: update master code #1576

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
17 changes: 12 additions & 5 deletions src/image-picker/index.js
Original file line number Diff line number Diff line change
@@ -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({

Expand Down Expand Up @@ -47,6 +46,11 @@ Component({
type: Number,
value: 9
},
sourceType: {
// 图片和视频选择的来源
optionalTypes: [Array, String],
value: ['album', 'camera']
},
sizeType: {
// 该写法经测试有效
optionalTypes: [Array, String],
Expand Down Expand Up @@ -215,17 +219,19 @@ Component({
* @returns {Promise<void>}
*/
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 数组
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down