小程序调用图片,视频,相机功能
//调用图片和相机 choosePic() { console.log("table") var _this = this wx.chooseImage({ count: 9, // 最多可以选择的图片张数,默认9 sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有 sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有 success: function (res) { // success console.log(res) _this.setData({ src: res.tempFilePaths }) }, fail: function () { // fail }, complete: function () { // complete } }) }, //调用图片视频 onChoosePic() { console.log("onDoor") wx.getSetting({ success: (res) => { let authStatus = res.authSetting['scope.album'] && res.authSetting['scope.camera']; // 如果没有授权相册 if (!authStatus) { //向用户发起授权请求 wx.authorize({ scope: "scope.camera", success: () => { wx.showActionSheet({ title: '选择上传类型', itemList: ['图片', '视频'], success: res => { console.log(res); if (res.tapIndex == 0) { this.chooseImages(); } else { this.chooseVideo(); } } }); }, fail: () => { wx.showModal({ title: '授权失败', content: '需要从您的相机或相册获取图片,请在设置界面打开相关权限', success: (res) => { if (res.confirm) { wx.openSetting() } } }) } }) } else { wx.showActionSheet({ title: '选择上传类型', itemList: ['图片', '视频'], success: res => { console.log(res); if (res.tapIndex == 0) { this.chooseImages(); } else { this.chooseVideo(); } } }); } } }) },
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用