提交 c7338bc1 编写于 作者: D devil_gong

头条小程序附件上传权限优化

上级 e708071d
......@@ -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("授权校验失败");
}
});
},
});
\ No newline at end of file
......@@ -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');
},
// 文件上传处理
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册