//处理头像名称
export const getUserName = (name) => {
    const leng = name.length;
    const pattern = new RegExp(/[0-9a-z]/i);
    if (pattern.test(name)) {
        return name.substr(leng - 3, 3)
    } else {
        return name.substr(leng - 2, 2)
    }
}

//选择图片文件
export const chooseImage = (count) => {
    return new Promise((resolve) => {
        uni.chooseImage({
            count: count,
            sizeType: ['original'],
            sourceType: ['album', 'camera'],
            success: ({tempFiles}) => {
                resolve(tempFiles);
            },
            fail: () => {
                resolve([]);
            }
        });
    })
}


//选择视频文件
export const chooseVideo = () => {
    return new Promise((resolve) => {
        uni.chooseVideo({
            sourceType: ['camera', 'album'],
            success: (res) => {
                resolve(res);
            },
            fail: () => {
                resolve({});
            }
        });
    })
}
