Ui
yfx
2026-03-13 51f9d68a26870672d6e516d740651665f9e7f386
Ui
4 files added
951 ■■■■■ changed files
components/agreePup/agreePup.vue 180 ●●●●● patch | view | raw | blame | history
components/u-pdf/u-pdf.vue 168 ●●●●● patch | view | raw | blame | history
components/yk-authpup/yk-authpup.vue 331 ●●●●● patch | view | raw | blame | history
js_sdk/wa-permission/permission.js 272 ●●●●● patch | view | raw | blame | history
components/agreePup/agreePup.vue
New file
@@ -0,0 +1,180 @@
<template>
    <view>
        <view class="agreePup" v-if="dialog">
            <view class="msk"></view>
            <view class="agreeMain">
                <view class="pop-title" v-if="gp == 6" style="height: 15px !important;line-height: 15px !important">{{title}}</view>
                <view class="pop-title" v-else>{{title}}</view>
                <view class="popup-content">
                    <view class="content" v-html="content"></view>
                    <view class="popBtn" @tap="popClose">确定</view>
                </view>
            </view>
        </view>
    </view>
</template>
<script>
    export default {
        name: 'agree-pup',
        props: {
            gp: {
                type: Number,
                default: 0,
            },
            title: {
                type: String,
                default: '',
            },
            addrId : {
                type: Number,
                default: 0,
            },
            cartsIds: {
                type: String,
                default: '',
            },
            userid: {
                type: Number,
                default: 0,
            },
            yz: {
                type: Number,
                default: 0,
            }
        },
        data() {
            return {
                userInfo: null,
                dialog: false,
                content: '',
            }
        },
        watch: {
            dialog () {
                if(this.dialog) {
                    //this.$refs.popup.open()
                }
            }
        },
        created() {
            this.userInfo = this.$util.getUserInfo()
            this.getContent()
        },
        methods: {
            popClose () {
                this.dialog = false
            },
            getContent () {
                let t = this
                let param = {gp: this.gp}
                if(t.gp == 6) {
                    param = {
                        sn: '',
                        gp: this.gp,
                        userid: this.userInfo.id,
                        cartsIds: this.cartsIds,
                        addrId: this.addrId,
                        yz: this.yz,
                    }
                }
                t.$util.post('Index/getAgree', param).then(res => {
                    if(res.code == 1){
                        this.content = res.data.replace(/\<p/gi, '<p style="width:100%;word-wrap: break-word;margin-bottom: 10px"')
                        let userInfo = null
                        let userStr = uni.getStorageSync('user-info') ? uni.getStorageSync('user-info') : null
                        if(userStr != null) {
                            userInfo = JSON.parse(userStr)
                        }
                        if(userInfo != null){
                            this.content = this.content.replace(/NAME/g, userInfo.realname)
                            this.content = this.content.replace(/IDCARD/g, userInfo.idcard)
                            this.content = this.content.replace(/PHONE/g, userInfo.phone)
                        }
                        const today = new Date();
                        const year = today.getFullYear();
                        const month = String(today.getMonth() + 1).padStart(2, '0'); // 月份是从0开始的,所以要加1,并且需要补零
                        const day = String(today.getDate()).padStart(2, '0');
                        this.content = this.content.replace(/YYYY/g, year)
                        this.content = this.content.replace(/MM/g, month)
                        this.content = this.content.replace(/DD/g, day)
                    }
                })
            }
        }
    }
</script>
<style lang="scss">
    .agreePup{
        width: 100%;
        left: 0;
        top: 0;
        z-index: 999999;
        height: 100%;
        position: fixed;
    }
    .agreePup .msk{
        width: 100%;
        height: 100%;
        z-index: 99;
        background-color: #000000;
        position: absolute;
        left: 0;
        top: 0;
        opacity: .5;
    }
    .agreeMain{
        width: 90%;
        position: absolute;
        left: 5%;
        top: 10%;
        background: #ffffff;
        border-radius: 10upx;
        height: 70%;
        z-index: 999999;
    }
    .pop-title{
        width: 100%;
        height: 90upx;
        border-bottom: 1px solid #eeeeee;
        text-align: center;
        line-height: 90upx;
        font-size: 28upx;
        font-weight: 700;
    }
    .popup-content{
        width: 100%;
        margin: 0%;
        border-radius: 10upx;
        padding-bottom: 20upx;
        overflow-y: auto;
        height: 90%;
    }
    .content{
        padding: 30upx;
        height: 80%;
        word-wrap: break-word;
        overflow-y: auto;
        overflow-x: hidden;
    }
    p{
        width: 100%;
        padding: 0;
        margin-block-start: 0em;
        margin-block-end: 0em;
        word-wrap: break-word;
        line-height: 40px;
    }
    .popBtn{
        width: 200upx;
        height: 76upx;
        margin: 30upx auto 0;
        text-align: center;
        line-height: 76upx;
        border-radius: 20upx;
        border: 1px solid #dddddd;
    }
</style>
components/u-pdf/u-pdf.vue
New file
@@ -0,0 +1,168 @@
<template>
  <view class="pdf-page">
    <view class="pdf-wrap" :style="{'height':viewHeight}">
      <view ref="pdfRef" id="pdfView"></view>
    </view>
    <view v-if="showBottom" class="pdf-btn-group">
      <slot>
        <button class="btn-readed" size="mini" @click="handleComplete"
            :disabled="btnDisabled">{{showTimer ? countTimer<=1 ? '':'('+countTimer+'s)':''}}我已阅读</button>
      </slot>
    </view>
  </view>
</template>
<script>
  import Pdfh5 from "pdfh5";
  import "pdfh5/css/pdfh5.css";
  export default {
    name: "u-pdf",
    props: {
      url: {
        type: String,
        require: true
      },
      viewHeight: {
        type: String,
        default: "100%"
      },
      showBottom: {
        type: Boolean,
        default: true
      },
      options: {
        type: Object,
        default: () => ({
          cMapUrl: "https://unpkg.com/pdfjs-dist@3.8.162/cmaps/",
          lazy: false,
          withCredentials: true,
          // pdfLoaded:false,
          renderType: "svg",
          maxZoom: 3, //手势缩放最大倍数 默认3
          scrollEnable: true, //是否允许pdf滚动
          zoomEnable: true //是否允许pdf手势缩放
        })
      },
      disabled:{
        type:Boolean,
        default:true
      },
      showTimer:Boolean
    },
    data() {
      return {
        totalNum: 0,
        pdfh5: undefined,
        countTimer:10,
        timer:undefined,
        btnDisabled:true
      }
    },
    watch:{
      disabled(n,o){
        this.btnDisabled = this.disabled
      },
      showTimer(n,o){
        console.log("showTimer ",n);
        if(this.showTimer){
          this.startCountDownTimer()
        }
      }
    },
    mounted() {
      this.$nextTick(() => {
        this.loadPdf()
      })
    },
    // onPageScroll(scroll) {
    //   console.log(`onPageScroll ${scroll}`,scroll);
    // },
    // onReachBottom(scroll) {
    //   console.log(`onReachBottom 滚动到底部`);
    // },
    methods: {
      handleComplete(){
        this.$emit("onClickReader")
      },
      startCountDownTimer(){
        this.timer= setInterval(()=>{
          if(this.countTimer<=1){
            this.btnDisabled=false
            clearInterval(this.timer)
          }else{
            this.countTimer--
          }
        },1000)
      },
      loadPdf() {
        if (!this.url) {
          console.error("pdf url is null ");
          return;
        }
        const opts = {
          pdfurl: this.url,
          ...this.options
        }
        console.log(opts);
        this.pdfh5 = new Pdfh5('#pdfView', opts);
        // 准备加载pdf
        this.pdfh5.on("ready", () => {
          this.$emit("ready")
        })
        //pdf 监听完成事件
        this.pdfh5.on("complete", (status, msg, time) => {
          console.log(`PDF complete status=${status}, msg =${msg}`);
          this.$emit("complete", { status, msg })
        });
        // pdf 滚动事件 Svg 方式不会执行此方法, 需要在page中监听 onReachBottom,onPageScroll
        this.pdfh5.on("scroll", (scrollTop, currentNum) => {
          console.log(`pdf scrollTop =${scrollTop} , currentNum =${currentNum}`);
          this.$emit("scroll", { scrollTop, currentNum })
        });
      }
    }
  }
</script>
<style scoped>
  @import 'pdfh5/css/pdfh5.css';
  .pdf-page {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .pdf-wrap {
    width: 100%;
    flex: 1;
  }
  .pdf-btn-group {
    width: 100%;
    border-top: 2rpx solid #F8F9FC;
    height: 8%;
    position: fixed;
    bottom: -1rpx;
    z-index: 999;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .btn-readed {
    background: #4E70F6;
    color: #ffffff;
    font-size: 32rpx;
  }
</style>
components/yk-authpup/yk-authpup.vue
New file
@@ -0,0 +1,331 @@
<template>
    <view v-if="showPopup" class="uni-popup" :style="{top:isNativeHead?'':StatusBar}">
        <view :class="[type, ani, animation ? 'ani' : '']" class="uni-custom uni-popup__wrapper" @click="close(true)">
            <view class="uni-popup__wrapper-box">
                <view class="title">{{authList[permissionID].title}}</view>
                <view class="content">{{authList[permissionID].content}}</view>
            </view>
        </view>
    </view>
</template>
<script>
    export default {
        name: 'YkAuthpup',
        props: {
            // 开启动画
            animation: {
                type: Boolean,
                default: true
            },
            type: {
                type: String,
                default: 'top'
            },
            show: {
                type: Boolean,
                default: true
            },
            //是否是原生头部
            isNativeHead:{
                type: Boolean,
                default: true
            },
            permissionID: {
                type: [String, Number],
                default: ''
            },
            noticeTitle:{
                type: [String],
                default: ''
            }
        },
        data() {
            return {
                ani: '',
                showPopup: false,
                StatusBar:'',
                refuseNum:'',//拒绝次数,
                authList: {
                    'WRITE_EXTERNAL_STORAGE': {
                        title: "存储空间/照片权限申请说明",
                        content: this.noticeTitle
                    },
                    'ACCESS_FINE_LOCATION': {
                        title: "地理位置权限申请说明",
                        content: this.noticeTitle
                    },
                    'CAMERA':{
                        title: "相机/摄像头权限申请说明",
                        content:this.noticeTitle
                    },
                    'RECORD_AUDIO':{
                        title: "麦克风权限申请说明",
                        content: this.noticeTitle
                    },
                    'CALL_PHONE': {
                        title: "拨打/管理电话权限申请说明",
                        content: this.noticeTitle
                    }
                }
            }
        },
        created() {
            // #ifdef APP-PLUS
            this.getSystemInfo();
            // #endif
        },
        methods: {
            //获取状态栏高度
            getSystemInfo() {
                let _this = this;
                uni.getSystemInfo({
                    success: function(e) {
                        _this.StatusBar = e.statusBarHeight + 'px'; //用于自定义头部时,给手机状态栏留出位置,可通过isNativeHead这个参数控制
                    }
                })
            },
            open() {
                this.requestPermissions(this.permissionID);
            },
            close(type) {
                this.ani = '';
                this.$nextTick(() => {
                    setTimeout(() => {
                        this.showPopup = false;
                    }, 300)
                })
            },
            //权限检测
            requestPermissions(permissionID) {
                let _this = this;
                // #ifdef APP-PLUS
                //判断安卓与ios设备
                if (plus.os.name == 'Android') {
                    let _permissionID = 'android.permission.' + permissionID;
                    plus.android.checkPermission(_permissionID,
                        granted => {
                            if (granted.checkResult == -1) {
                                //还未授权当前查询的权限,打开权限申请目的自定义弹框
                                _this.showPopup = true;
                                _this.$nextTick(() => {
                                    setTimeout(() => {
                                        _this.ani = 'uni-' + _this.type
                                    },30)
                                })
                            }
                        },
                        error => {
                            console.log(error.message);
                        }
                    );
                    plus.android.requestPermissions([_permissionID],
                        (e) => {
                            //关闭权限申请目的自定义弹框
                            _this.ani = '';
                            _this.$nextTick(() => {
                                setTimeout(() => {
                                    _this.showPopup = false
                                }, 0)
                            })
                            //console.log(e,'kkkkk')
                            if (e.granted.length > 0) {
                                //当前查询权限已授权,此时可以通知页面执行接下来的操作
                                _this.$emit('changeAuth');
                            }
                            if (e.deniedAlways.length > 0) {
                                //当前查询权限已被永久禁用,此时需要引导用户跳转手机系统设置去开启
                                uni.showModal({
                                    title: '温馨提示',
                                    content: '还没有该权限,立即去设置开启?',
                                    cancelText: "取消",
                                    confirmText: "去设置",
                                    showCancel: true,
                                    confirmColor: '#000',
                                    cancelColor: '#666',
                                    success: (res) => {
                                        if (res.confirm) {
                                            _this.goSetting();
                                        }
                                    }
                                })
                            }
                        })
                } else {
                    //IOS不需要添加自定义弹框来描述权限目的,因为在配置文件的隐私信息访问的许可描述里可添加
                    //正常可以直接调用uni的API调起权限询问弹框使用各种权限,下面的判断使用场景主要是在IOS禁用某权限后,这个可以判断有无权限,进而引导用户跳转设置开启,仅列出了位置、相册、通讯录、相机、录音等权限,其他IOS权限可具体参考 https://ext.dcloud.net.cn/plugin?id=15787
                    let result = 0;
                    if (permissionID == 'ACCESS_FINE_LOCATION') {
                        //IOS检测位置权限
                        let cLLocationManager = plus.ios.importClass("CLLocationManager"),
                            authStatus = cLLocationManager.authorizationStatus(),
                            enable = cLLocationManager.locationServicesEnabled();
                        if (enable && authStatus != 2) {
                            result = 1;
                        } else {
                            result = 0;
                        }
                        plus.ios.deleteObject(cLLocationManager);
                    } else if (permissionID == 'WRITE_EXTERNAL_STORAGE') {
                        //IOS检测相册权限
                        let PHPhotoLibrary = plus.ios.importClass("PHPhotoLibrary"),
                            authStatus = PHPhotoLibrary.authorizationStatus();
                        if (authStatus === 3) {
                            result = 1;
                        } else {
                            result = 0;
                        }
                        plus.ios.deleteObject(PHPhotoLibrary);
                    } else if (permissionID == 'CAMERA') {
                        //IOS检测相机/摄像头权限
                        let avCaptureDevice = plus.ios.importClass("AVCaptureDevice"),
                            authStatus = avCaptureDevice.authorizationStatusForMediaType("vide");
                        if (authStatus === 3) {
                          result = 1;
                        } else {
                          result = 0;
                        }
                        plus.ios.deleteObject(avCaptureDevice);
                    } else if (permissionID == 'CALL_PHONE') {
                        //IOS检测通讯录权限
                        let contactStore = plus.ios.importClass("CNContactStore"),
                            authStatus = contactStore.authorizationStatusForEntityType(0);
                        if (authStatus === 3) {
                            result = 1;
                        } else {
                            result = 0;
                        }
                        plus.ios.deleteObject(contactStore);
                    }else if(permissionID == 'RECORD_AUDIO'){
                        //IOS检测麦克风权限
                        let aVAudioSession = plus.ios.importClass("AVAudioSession"),
                          aVAudio = aVAudioSession.sharedInstance(),
                          authStatus = aVAudio.recordPermission();
                        if ([1684369017, 1970168948].includes(authStatus)) {
                          result = 0;
                        } else {
                          result = 1;
                        }
                        plus.ios.deleteObject(aVAudioSession);
                    }
                    if (result) {
                        //当前查询权限已授权,此时可以通知页面执行接下来的操作
                        that.$emit('changeAuth')
                    } else {
                        //当前查询的权限已禁用,引导用户跳转手机系统设置去开启
                        uni.showModal({
                            title: '温馨提示',
                            content: '还没有该权限,立即去设置开启?',
                            cancelText: "取消",
                            confirmText: "去设置",
                            showCancel: true,
                            confirmColor: '#000',
                            cancelColor: '#666',
                            success: (res) => {
                                if (res.confirm) {
                                    _this.goSetting();
                                }
                            }
                        })
                    }
                }
                // #endif
            },
            //跳转手机系统设置
            goSetting() {
                if (plus.os.name == "iOS") {
                    var UIApplication = plus.ios.import("UIApplication");
                    var application2 = UIApplication.sharedApplication();
                    var NSURL2 = plus.ios.import("NSURL");
                    var setting2 = NSURL2.URLWithString("app-settings:");
                    application2.openURL(setting2);
                    plus.ios.deleteObject(setting2);
                    plus.ios.deleteObject(NSURL2);
                    plus.ios.deleteObject(application2);
                } else {
                    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);
                }
            }
        }
    }
</script>
<style lang="scss">
    .uni-popup {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 99999;
        overflow: hidden;
        &__wrapper {
            position: absolute;
            z-index: 9999999;
            /* #ifndef APP-NVUE */
            box-sizing: border-box;
            /* #endif */
            &.ani {
                /* #ifndef APP-NVUE */
                transition: all 0.3s;
                /* #endif */
            }
            &.top {
                top: 0;
                width:705rpx;
                /* #ifdef APP-NVUE */
                left:22.5rpx;
                /* #endif */
                /* #ifndef APP-NVUE */
                left:0;
                transform: translateY(-705rpx);
                /* #endif */
            }
            &-box {
                position: relative;
                /* #ifndef APP-NVUE */
                box-sizing: border-box;
                /* #endif */
            }
            &.uni-custom {
                & .uni-popup__wrapper-box {
                    width: 705rpx;
                    /* #ifndef APP-NVUE */
                    margin: 0 22.5rpx;
                    /* #endif */
                    padding: 30upx;
                    background: #fff;
                    z-index:9999;
                    border: solid 2rpx #ddd;
                    /* #ifndef APP-NVUE */
                    box-sizing: border-box;
                    /* #endif */
                    border-radius: 16rpx;
                    .title{
                        font-size: 32rpx;
                        font-weight: bold;
                    }
                    .content{
                        margin-top: 16rpx;
                        line-height: 1.6;
                    }
                }
                &.top{
                    & .uni-popup__wrapper-box {
                        width: 705rpx;
                    }
                }
            }
            &.uni-top{
                transform: translateY(0);
            }
        }
    }
</style>
js_sdk/wa-permission/permission.js
New file
@@ -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
}