From 8fbaf73ea6fe5ef9c614be3300b05383443b5e42 Mon Sep 17 00:00:00 2001 From: chen <2659004835@qq.com> Date: Thu, 12 May 2022 15:28:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=89=AA=E5=88=87=E3=80=81=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E5=AD=97=E5=8A=A8=E7=94=BB=E3=80=81=E6=96=B0?= =?UTF-8?q?=E5=A2=9Eapp=E6=9D=83=E9=99=90=E6=A3=80=E6=B5=8B=E4=B8=8E?= =?UTF-8?q?=E6=89=93=E5=BC=80=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../count-one/requestAnimationFrame.js | 46 - .../count-animate/count-one/vue-countTo.vue | 191 ----- .../uni-segmented-control.vue | 134 +++ js_sdk/wa-permission/permission.js | 272 ++++++ pages.json | 27 +- pages/tabbar/my/my.vue | 4 +- pagesA/count-to/count-to.vue | 126 --- pagesA/my-address/my-address.vue | 4 - pagesA/picture-cut/picture-cut.vue | 806 ------------------ pagesB/permission/permission.vue | 182 ++++ pagesB/set-up/set-up.vue | 41 +- 11 files changed, 613 insertions(+), 1220 deletions(-) delete mode 100644 components/count-animate/count-one/requestAnimationFrame.js delete mode 100644 components/count-animate/count-one/vue-countTo.vue create mode 100644 components/uni-segmented-control/uni-segmented-control.vue create mode 100644 js_sdk/wa-permission/permission.js delete mode 100644 pagesA/count-to/count-to.vue delete mode 100644 pagesA/picture-cut/picture-cut.vue create mode 100644 pagesB/permission/permission.vue diff --git a/components/count-animate/count-one/requestAnimationFrame.js b/components/count-animate/count-one/requestAnimationFrame.js deleted file mode 100644 index 90d0954..0000000 --- a/components/count-animate/count-one/requestAnimationFrame.js +++ /dev/null @@ -1,46 +0,0 @@ -let lastTime = 0 -const prefixes = 'webkit moz ms o'.split(' ') // 各浏览器前缀 - -let requestAnimationFrame -let cancelAnimationFrame - -const isServer = typeof window === 'undefined' -if (isServer) { - requestAnimationFrame = function() { - return - } - cancelAnimationFrame = function() { - return - } -} else { - requestAnimationFrame = window.requestAnimationFrame - cancelAnimationFrame = window.cancelAnimationFrame - let prefix - // 通过遍历各浏览器前缀,来得到requestAnimationFrame和cancelAnimationFrame在当前浏览器的实现形式 - for (let i = 0; i < prefixes.length; i++) { - if (requestAnimationFrame && cancelAnimationFrame) { break } - prefix = prefixes[i] - requestAnimationFrame = requestAnimationFrame || window[prefix + 'RequestAnimationFrame'] - cancelAnimationFrame = cancelAnimationFrame || window[prefix + 'CancelAnimationFrame'] || window[prefix + 'CancelRequestAnimationFrame'] - } - - // 如果当前浏览器不支持requestAnimationFrame和cancelAnimationFrame,则会退到setTimeout - if (!requestAnimationFrame || !cancelAnimationFrame) { - requestAnimationFrame = function(callback) { - const currTime = new Date().getTime() - // 为了使setTimteout的尽可能的接近每秒60帧的效果 - const timeToCall = Math.max(0, 16 - (currTime - lastTime)) - const id = window.setTimeout(() => { - callback(currTime + timeToCall) - }, timeToCall) - lastTime = currTime + timeToCall - return id - } - - cancelAnimationFrame = function(id) { - window.clearTimeout(id) - } - } -} - -export { requestAnimationFrame, cancelAnimationFrame } diff --git a/components/count-animate/count-one/vue-countTo.vue b/components/count-animate/count-one/vue-countTo.vue deleted file mode 100644 index f33f880..0000000 --- a/components/count-animate/count-one/vue-countTo.vue +++ /dev/null @@ -1,191 +0,0 @@ - - diff --git a/components/uni-segmented-control/uni-segmented-control.vue b/components/uni-segmented-control/uni-segmented-control.vue new file mode 100644 index 0000000..0ccd91f --- /dev/null +++ b/components/uni-segmented-control/uni-segmented-control.vue @@ -0,0 +1,134 @@ + + + + + diff --git a/js_sdk/wa-permission/permission.js b/js_sdk/wa-permission/permission.js new file mode 100644 index 0000000..9981504 --- /dev/null +++ b/js_sdk/wa-permission/permission.js @@ -0,0 +1,272 @@ +/** + * 本模块封装了Android、iOS的应用权限判断、打开应用权限设置界面、以及位置系统服务是否开启 + */ + +var isIos +// #ifdef APP-PLUS +isIos = (plus.os.name == "iOS") +// #endif + +// 判断推送权限是否开启 +function judgeIosPermissionPush() { + var result = false; + var UIApplication = plus.ios.import("UIApplication"); + var app = UIApplication.sharedApplication(); + var enabledTypes = 0; + if (app.currentUserNotificationSettings) { + var settings = app.currentUserNotificationSettings(); + enabledTypes = settings.plusGetAttribute("types"); + console.log("enabledTypes1:" + enabledTypes); + if (enabledTypes == 0) { + console.log("推送权限没有开启"); + } else { + result = true; + console.log("已经开启推送功能!") + } + plus.ios.deleteObject(settings); + } else { + enabledTypes = app.enabledRemoteNotificationTypes(); + if (enabledTypes == 0) { + console.log("推送权限没有开启!"); + } else { + result = true; + console.log("已经开启推送功能!") + } + console.log("enabledTypes2:" + enabledTypes); + } + plus.ios.deleteObject(app); + plus.ios.deleteObject(UIApplication); + return result; +} + +// 判断定位权限是否开启 +function judgeIosPermissionLocation() { + var result = false; + var cllocationManger = plus.ios.import("CLLocationManager"); + var status = cllocationManger.authorizationStatus(); + result = (status != 2) + console.log("定位权限开启:" + result); + // 以下代码判断了手机设备的定位是否关闭,推荐另行使用方法 checkSystemEnableLocation + /* var enable = cllocationManger.locationServicesEnabled(); + var status = cllocationManger.authorizationStatus(); + console.log("enable:" + enable); + console.log("status:" + status); + if (enable && status != 2) { + result = true; + console.log("手机定位服务已开启且已授予定位权限"); + } else { + console.log("手机系统的定位没有打开或未给予定位权限"); + } */ + plus.ios.deleteObject(cllocationManger); + return result; +} + +// 判断麦克风权限是否开启 +function judgeIosPermissionRecord() { + var result = false; + var avaudiosession = plus.ios.import("AVAudioSession"); + var avaudio = avaudiosession.sharedInstance(); + var permissionStatus = avaudio.recordPermission(); + console.log("permissionStatus:" + permissionStatus); + if (permissionStatus == 1684369017 || permissionStatus == 1970168948) { + console.log("麦克风权限没有开启"); + } else { + result = true; + console.log("麦克风权限已经开启"); + } + plus.ios.deleteObject(avaudiosession); + return result; +} + +// 判断相机权限是否开启 +function judgeIosPermissionCamera() { + var result = false; + var AVCaptureDevice = plus.ios.import("AVCaptureDevice"); + var authStatus = AVCaptureDevice.authorizationStatusForMediaType('vide'); + console.log("authStatus:" + authStatus); + if (authStatus == 3) { + result = true; + console.log("相机权限已经开启"); + } else { + console.log("相机权限没有开启"); + } + plus.ios.deleteObject(AVCaptureDevice); + return result; +} + +// 判断相册权限是否开启 +function judgeIosPermissionPhotoLibrary() { + var result = false; + var PHPhotoLibrary = plus.ios.import("PHPhotoLibrary"); + var authStatus = PHPhotoLibrary.authorizationStatus(); + console.log("authStatus:" + authStatus); + if (authStatus == 3) { + result = true; + console.log("相册权限已经开启"); + } else { + console.log("相册权限没有开启"); + } + plus.ios.deleteObject(PHPhotoLibrary); + return result; +} + +// 判断通讯录权限是否开启 +function judgeIosPermissionContact() { + var result = false; + var CNContactStore = plus.ios.import("CNContactStore"); + var cnAuthStatus = CNContactStore.authorizationStatusForEntityType(0); + if (cnAuthStatus == 3) { + result = true; + console.log("通讯录权限已经开启"); + } else { + console.log("通讯录权限没有开启"); + } + plus.ios.deleteObject(CNContactStore); + return result; +} + +// 判断日历权限是否开启 +function judgeIosPermissionCalendar() { + var result = false; + var EKEventStore = plus.ios.import("EKEventStore"); + var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(0); + if (ekAuthStatus == 3) { + result = true; + console.log("日历权限已经开启"); + } else { + console.log("日历权限没有开启"); + } + plus.ios.deleteObject(EKEventStore); + return result; +} + +// 判断备忘录权限是否开启 +function judgeIosPermissionMemo() { + var result = false; + var EKEventStore = plus.ios.import("EKEventStore"); + var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(1); + if (ekAuthStatus == 3) { + result = true; + console.log("备忘录权限已经开启"); + } else { + console.log("备忘录权限没有开启"); + } + plus.ios.deleteObject(EKEventStore); + return result; +} + +// Android权限查询 +function requestAndroidPermission(permissionID) { + return new Promise((resolve, reject) => { + plus.android.requestPermissions( + [permissionID], // 理论上支持多个权限同时查询,但实际上本函数封装只处理了一个权限的情况。有需要的可自行扩展封装 + function(resultObj) { + var result = 0; + for (var i = 0; i < resultObj.granted.length; i++) { + var grantedPermission = resultObj.granted[i]; + console.log('已获取的权限:' + grantedPermission); + result = 1 + } + for (var i = 0; i < resultObj.deniedPresent.length; i++) { + var deniedPresentPermission = resultObj.deniedPresent[i]; + console.log('拒绝本次申请的权限:' + deniedPresentPermission); + result = 0 + } + for (var i = 0; i < resultObj.deniedAlways.length; i++) { + var deniedAlwaysPermission = resultObj.deniedAlways[i]; + console.log('永久拒绝申请的权限:' + deniedAlwaysPermission); + result = -1 + } + resolve(result); + // 若所需权限被拒绝,则打开APP设置界面,可以在APP设置界面打开相应权限 + // if (result != 1) { + // gotoAppPermissionSetting() + // } + }, + function(error) { + console.log('申请权限错误:' + error.code + " = " + error.message); + resolve({ + code: error.code, + message: error.message + }); + } + ); + }); +} + +// 使用一个方法,根据参数判断权限 +function judgeIosPermission(permissionID) { + if (permissionID == "location") { + return judgeIosPermissionLocation() + } else if (permissionID == "camera") { + return judgeIosPermissionCamera() + } else if (permissionID == "photoLibrary") { + return judgeIosPermissionPhotoLibrary() + } else if (permissionID == "record") { + return judgeIosPermissionRecord() + } else if (permissionID == "push") { + return judgeIosPermissionPush() + } else if (permissionID == "contact") { + return judgeIosPermissionContact() + } else if (permissionID == "calendar") { + return judgeIosPermissionCalendar() + } else if (permissionID == "memo") { + return judgeIosPermissionMemo() + } + return false; +} + +// 跳转到**应用**的权限页面 +function gotoAppPermissionSetting() { + if (isIos) { + var UIApplication = plus.ios.import("UIApplication"); + var application2 = UIApplication.sharedApplication(); + var NSURL2 = plus.ios.import("NSURL"); + // var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES"); + var setting2 = NSURL2.URLWithString("app-settings:"); + application2.openURL(setting2); + + plus.ios.deleteObject(setting2); + plus.ios.deleteObject(NSURL2); + plus.ios.deleteObject(application2); + } else { + // console.log(plus.device.vendor); + var Intent = plus.android.importClass("android.content.Intent"); + var Settings = plus.android.importClass("android.provider.Settings"); + var Uri = plus.android.importClass("android.net.Uri"); + var mainActivity = plus.android.runtimeMainActivity(); + var intent = new Intent(); + intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + var uri = Uri.fromParts("package", mainActivity.getPackageName(), null); + intent.setData(uri); + mainActivity.startActivity(intent); + } +} + +// 检查系统的设备服务是否开启 +// var checkSystemEnableLocation = async function () { +function checkSystemEnableLocation() { + if (isIos) { + var result = false; + var cllocationManger = plus.ios.import("CLLocationManager"); + var result = cllocationManger.locationServicesEnabled(); + console.log("系统定位开启:" + result); + plus.ios.deleteObject(cllocationManger); + return result; + } else { + var context = plus.android.importClass("android.content.Context"); + var locationManager = plus.android.importClass("android.location.LocationManager"); + var main = plus.android.runtimeMainActivity(); + var mainSvr = main.getSystemService(context.LOCATION_SERVICE); + var result = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER); + console.log("系统定位开启:" + result); + return result + } +} + +module.exports = { + judgeIosPermission: judgeIosPermission, + requestAndroidPermission: requestAndroidPermission, + checkSystemEnableLocation: checkSystemEnableLocation, + gotoAppPermissionSetting: gotoAppPermissionSetting +} diff --git a/pages.json b/pages.json index d40bb94..e6d094d 100644 --- a/pages.json +++ b/pages.json @@ -88,24 +88,6 @@ "enablePullDownRefresh": false } } - ,{ - "path" : "picture-cut/picture-cut", - "style" : - { - "navigationBarTitleText": "", - "enablePullDownRefresh": false - } - - } - ,{ - "path" : "count-to/count-to", - "style" : - { - "navigationBarTitleText": "", - "enablePullDownRefresh": false - } - - } ] }, { //B包 @@ -158,6 +140,15 @@ "enablePullDownRefresh": false } + } + ,{ + "path" : "permission/permission", + "style" : + { + "navigationBarTitleText": "", + "enablePullDownRefresh": false + } + } ] } diff --git a/pages/tabbar/my/my.vue b/pages/tabbar/my/my.vue index 3ca224f..525c066 100644 --- a/pages/tabbar/my/my.vue +++ b/pages/tabbar/my/my.vue @@ -95,7 +95,7 @@ ], gridList:[ {imgsrc:'/static/public/icon-my-information.png',title:'个人信息'}, - {imgsrc:'/static/public/icon-my-certificates.png',title:'电子证件'}, + {imgsrc:'/static/public/icon-my-certificates.png',title:'地址选择'}, {imgsrc:'/static/public/icon-my-service.png',title:'服务范围'}, {imgsrc:'/static/public/icon-my-evaluate.png',title:'我要评价'}, {imgsrc:'/static/public/icon-my-account.png',title:'我的账户'}, @@ -158,7 +158,7 @@ chooseGridEv(index){ let urls = [ '/pagesB/personal-information/personal-information', - '/pagesA/picture-cut/picture-cut', + '/pagesA/my-address/my-address', '/pagesB/service-range/service-range', '/pagesB/i-want-evaluate/i-want-evaluate', '/pagesB/my-account/my-account', diff --git a/pagesA/count-to/count-to.vue b/pagesA/count-to/count-to.vue deleted file mode 100644 index c61dd24..0000000 --- a/pagesA/count-to/count-to.vue +++ /dev/null @@ -1,126 +0,0 @@ - - - - - diff --git a/pagesA/my-address/my-address.vue b/pagesA/my-address/my-address.vue index 1735b54..c5b5656 100644 --- a/pagesA/my-address/my-address.vue +++ b/pagesA/my-address/my-address.vue @@ -64,8 +64,6 @@ import addressTwo from '@/components/choose-address/address-two/address-two.vue'; import addressThree from '@/components/choose-address/address-three/address-three.vue'; import addressFour from '@/components/choose-address/address-four/address-four.vue'; - import yayaMap from '@/jsFile/map/yaya-map.js'; - import yayaTime from '@/jsFile/time/yaya-time.js'; import statusContainer from '@/components/containers/status-container.vue'; export default { components:{ @@ -100,8 +98,6 @@ }, mounted() { this.getDistrict(); - yayaMap.getAddressH5(); - yayaTime.weekDate(); }, computed:{ regionName(){ diff --git a/pagesA/picture-cut/picture-cut.vue b/pagesA/picture-cut/picture-cut.vue deleted file mode 100644 index 213d42f..0000000 --- a/pagesA/picture-cut/picture-cut.vue +++ /dev/null @@ -1,806 +0,0 @@ - - - - - diff --git a/pagesB/permission/permission.vue b/pagesB/permission/permission.vue new file mode 100644 index 0000000..73f466c --- /dev/null +++ b/pagesB/permission/permission.vue @@ -0,0 +1,182 @@ + + + + + diff --git a/pagesB/set-up/set-up.vue b/pagesB/set-up/set-up.vue index 3cc78eb..18e0d00 100644 --- a/pagesB/set-up/set-up.vue +++ b/pagesB/set-up/set-up.vue @@ -23,34 +23,10 @@ {{cacheSize}} - - 上门服务条款 + + {{item.title}} - V3.0 - - - - 用户服务协议 - - V1.1 - - - - 飞猴云服务隐私政策 - - V1.2 - - - - 技术服务合作协议 - - V1.1 - - - - 关于飞猴云服务 - - V1.1 + @@ -75,6 +51,9 @@ voiceStatus:false,//是否开启语音提醒 newsStatus:false,//是否开启接受新消息通知 cacheSize:'754.72 KB',//缓存数据大小 + dataList:[ + {title:'ios/android的权限判断和提示'}, + ] } }, onLoad() { @@ -130,6 +109,14 @@ // 检测版本事件 checkEdition(){ console.log('检测版本事件'); + }, + chooseEv(index){ + let arr = [ + '/pagesB/permission/permission', + ] + uni.navigateTo({ + url:arr[index] + }) } } }