diff --git a/public/appmini/old/toutiao/app.js b/public/appmini/old/toutiao/app.js index 77d4129f5dc9462effa51f4d2de487f88b4d198e..8ce8eb9aadad4f5fd9d54e3ef1a3823dd9b80e93 100755 --- a/public/appmini/old/toutiao/app.js +++ b/public/appmini/old/toutiao/app.js @@ -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 diff --git a/public/appmini/old/toutiao/pages/user-order-comments/user-order-comments.js b/public/appmini/old/toutiao/pages/user-order-comments/user-order-comments.js index 07f66562bd9e9319e75948563fe448ccc0c4ad19..4b9cdc5e9486ece577e4660aedbb17a8b3af1d52 100644 --- a/public/appmini/old/toutiao/pages/user-order-comments/user-order-comments.js +++ b/public/appmini/old/toutiao/pages/user-order-comments/user-order-comments.js @@ -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); }, // 文件上传处理 diff --git a/public/appmini/old/toutiao/pages/user-orderaftersale-detail/user-orderaftersale-detail.js b/public/appmini/old/toutiao/pages/user-orderaftersale-detail/user-orderaftersale-detail.js index 3997aaf3e1124d68e514f1080c68cf836820f829..7391a0e008a8e1d024b0f55aaa9d3dd1d331b944 100644 --- a/public/appmini/old/toutiao/pages/user-orderaftersale-detail/user-orderaftersale-detail.js +++ b/public/appmini/old/toutiao/pages/user-orderaftersale-detail/user-orderaftersale-detail.js @@ -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'); }, // 文件上传处理