From c7338bc182b954e8f94ebc8a9a0727e2c9197835 Mon Sep 17 00:00:00 2001 From: devil_gong Date: Wed, 30 Oct 2019 10:10:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=B4=E6=9D=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E9=99=84=E4=BB=B6=E4=B8=8A=E4=BC=A0=E6=9D=83=E9=99=90=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/appmini/old/toutiao/app.js | 63 ++++++++++++++++++- .../user-order-comments.js | 53 +--------------- .../user-orderaftersale-detail.js | 53 +--------------- 3 files changed, 66 insertions(+), 103 deletions(-) diff --git a/public/appmini/old/toutiao/app.js b/public/appmini/old/toutiao/app.js index 77d4129f5..8ce8eb9aa 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 07f66562b..4b9cdc5e9 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 3997aaf3e..7391a0e00 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'); }, // 文件上传处理