头条小程序附件上传权限优化
parent
e708071d24
commit
c7338bc182
|
|
@ -518,6 +518,67 @@ App({
|
|||
}
|
||||
}
|
||||
return json;
|
||||
}
|
||||
},
|
||||
|
||||
// 文件上传权限获取
|
||||
file_upload_authorize(object, method, params) {
|
||||
var self = this;
|
||||
tt.getSetting({
|
||||
success(res) {
|
||||
if (!res.authSetting['scope.camera']) {
|
||||
tt.authorize({
|
||||
scope: 'scope.camera',
|
||||
success (res) {
|
||||
tt.authorize({
|
||||
scope: 'scope.camera',
|
||||
success (res) {
|
||||
if (typeof object === 'object' && (method || null) != null) {
|
||||
object[method](params);
|
||||
}
|
||||
},
|
||||
fail (res) {
|
||||
tt.openSetting();
|
||||
self.showToast('请同意相册授权');
|
||||
}
|
||||
});
|
||||
},
|
||||
fail (res) {
|
||||
tt.openSetting();
|
||||
self.showToast('请同意相机授权');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if(!res.authSetting['scope.album'])
|
||||
{
|
||||
if(res.authSetting['scope.album'] == undefined)
|
||||
{
|
||||
tt.authorize({
|
||||
scope: 'scope.camera',
|
||||
success (res) {
|
||||
if (typeof object === 'object' && (method || null) != null) {
|
||||
object[method](params);
|
||||
}
|
||||
},
|
||||
fail (res) {
|
||||
tt.openSetting();
|
||||
self.showToast('请同意相册授权');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
tt.openSetting();
|
||||
self.showToast('请同意相册授权');
|
||||
}
|
||||
} else {
|
||||
if (typeof object === 'object' && (method || null) != null) {
|
||||
object[method](params);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: (e) => {
|
||||
self.showToast("授权校验失败");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
|
|
@ -114,57 +114,8 @@ Page({
|
|||
}
|
||||
this.setData({ form_images_list: temp_list});
|
||||
|
||||
var self = this;
|
||||
tt.getSetting({
|
||||
success(res) {
|
||||
if (!res.authSetting['scope.camera']) {
|
||||
tt.authorize({
|
||||
scope: 'scope.camera',
|
||||
success (res) {
|
||||
tt.authorize({
|
||||
scope: 'scope.camera',
|
||||
success (res) {
|
||||
self.file_upload_handle(index);
|
||||
},
|
||||
fail (res) {
|
||||
tt.openSetting();
|
||||
app.showToast('请同意相册授权');
|
||||
}
|
||||
});
|
||||
},
|
||||
fail (res) {
|
||||
tt.openSetting();
|
||||
app.showToast('请同意相机授权');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if(!res.authSetting['scope.album'])
|
||||
{
|
||||
if(res.authSetting['scope.album'] == undefined)
|
||||
{
|
||||
tt.authorize({
|
||||
scope: 'scope.camera',
|
||||
success (res) {
|
||||
self.file_upload_handle(index);
|
||||
},
|
||||
fail (res) {
|
||||
tt.openSetting();
|
||||
app.showToast('请同意相册授权');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
tt.openSetting();
|
||||
app.showToast('请同意相册授权');
|
||||
}
|
||||
} else {
|
||||
self.file_upload_handle(index);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: (e) => {
|
||||
app.showToast("授权校验失败");
|
||||
}
|
||||
});
|
||||
// 调用相机、相册权限
|
||||
app.file_upload_authorize(this, 'file_upload_handle', index);
|
||||
},
|
||||
|
||||
// 文件上传处理
|
||||
|
|
|
|||
|
|
@ -264,57 +264,8 @@ Page({
|
|||
|
||||
// 文件上传
|
||||
file_upload_event(e) {
|
||||
var self = this;
|
||||
tt.getSetting({
|
||||
success(res) {
|
||||
if (!res.authSetting['scope.camera']) {
|
||||
tt.authorize({
|
||||
scope: 'scope.camera',
|
||||
success (res) {
|
||||
tt.authorize({
|
||||
scope: 'scope.camera',
|
||||
success (res) {
|
||||
self.file_upload_handle();
|
||||
},
|
||||
fail (res) {
|
||||
tt.openSetting();
|
||||
app.showToast('请同意相册授权');
|
||||
}
|
||||
});
|
||||
},
|
||||
fail (res) {
|
||||
tt.openSetting();
|
||||
app.showToast('请同意相机授权');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if(!res.authSetting['scope.album'])
|
||||
{
|
||||
if(res.authSetting['scope.album'] == undefined)
|
||||
{
|
||||
tt.authorize({
|
||||
scope: 'scope.camera',
|
||||
success (res) {
|
||||
self.file_upload_handle();
|
||||
},
|
||||
fail (res) {
|
||||
tt.openSetting();
|
||||
app.showToast('请同意相册授权');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
tt.openSetting();
|
||||
app.showToast('请同意相册授权');
|
||||
}
|
||||
} else {
|
||||
self.file_upload_handle();
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: (e) => {
|
||||
app.showToast("授权校验失败");
|
||||
}
|
||||
});
|
||||
// 调用相机、相册权限
|
||||
app.file_upload_authorize(this, 'file_upload_handle');
|
||||
},
|
||||
|
||||
// 文件上传处理
|
||||
|
|
|
|||
Loading…
Reference in New Issue