Browse Source

华为的审核准备换插件了

master
unknown 1 week ago
parent
commit
afa624ae9c
  1. 46
      App.vue
  2. 7
      components/callPhone/callPhone.vue
  3. 4
      config/api.js
  4. 2
      config/site.config.js
  5. 12
      config/utils.js
  6. 12
      manifest.json
  7. 8
      pages/indexEntry/consult/pubComplaint/pubComplaint.vue
  8. 9
      pages/indexEntry/consult/pubConsult/pubConsult.vue
  9. 7
      pages/indexEntry/signIn/signAndOut/signAndOut.vue
  10. 7
      pages/indexEntry/signIn/signAndOut/signAndOutSubjiect1.vue
  11. 27
      pages/indexEntry/signIn/signIn.vue
  12. 25
      pages/indexEntry/theory/theory.vue
  13. 8
      pages/indexEntry/theory/webView.vue
  14. 6
      pages/mineEntry/personaInfo/personaInfo.vue
  15. 6
      pages/tabbar/index/comp/schoolItem.vue
  16. 24
      pages/tabbar/index/index.vue
  17. 7
      pages/tabbar/mine/index.vue
  18. 3
      store/index.js
  19. 230
      store/modules/permissionToast.js
  20. 50
      store/modules/user.js
  21. 8
      uni_modules/uni-registerRequestPermissionTips/changelog.md
  22. 115
      uni_modules/uni-registerRequestPermissionTips/package.json
  23. 95
      uni_modules/uni-registerRequestPermissionTips/readme.md
  24. 3
      uni_modules/uni-registerRequestPermissionTips/utssdk/app-android/AndroidManifest.xml
  25. 3
      uni_modules/uni-registerRequestPermissionTips/utssdk/app-android/config.json
  26. 148
      uni_modules/uni-registerRequestPermissionTips/utssdk/app-android/index.uts
  27. 6
      uni_modules/uni-registerRequestPermissionTips/utssdk/app-android/res/anim/popupwindow_enter.xml
  28. 5
      uni_modules/uni-registerRequestPermissionTips/utssdk/app-android/res/anim/popupwindow_exit.xml
  29. 6
      uni_modules/uni-registerRequestPermissionTips/utssdk/app-android/res/drawable/dcloud_permission_background.xml
  30. 19
      uni_modules/uni-registerRequestPermissionTips/utssdk/interface.uts

46
App.vue

@ -1,10 +1,44 @@
<script> <script>
// import location from '@/common/js/location.js'
import {
registerRequestPermissionTipsListener,
unregisterRequestPermissionTipsListener,
setRequestPermissionTips
} from "@/uni_modules/uni-registerRequestPermissionTips"
var PermissionTips = {
"android.permission.CAMERA": "<h4 style=\"font-size:40px;\">正在读取通讯录权限</h4><font color=#cccccc>通讯录权限不会获取任何信息,请注意</font>",
"android.permission.READ_PHONE_STATE": "<h4 style=\"font-size:40px;\">正在读取网络状态权限</h4><font color=#cccccc>通讯录权限不会获取任何信息,请注意通讯录权限不会获取任何信息,请注意通讯录权限不会获取任何信息,请注意</font>"
}
export default { export default {
onLaunch: function() { onLaunch: function() {
// location.getLocation(()=>{
// this.$store.dispatch('getCity')
// });
var brand = uni.getSystemInfoSync().deviceBrand
setRequestPermissionTips(PermissionTips)
registerRequestPermissionTipsListener({
onRequest: (e) => {
console.log(e)
},
onConfirm: (e) => {
console.log(e)
},
onComplete: (e) => {
//
if (brand.toLowerCase() == "huawei") {
var tips = {}
var hasDeniedPermission = false
for (var k in PermissionTips) {
if (e[k] != "denied") {
tips[k] = PermissionTips[k]
} else {
hasDeniedPermission = true
}
}
setRequestPermissionTips(tips) //
if (hasDeniedPermission)
uni.showModal({
content: "权限已经被拒绝,请前往设置中开启"
})
}
}
})
}, },
onShow: function() { onShow: function() {
console.log('App Show') console.log('App Show')
@ -12,8 +46,8 @@
onHide: function() { onHide: function() {
console.log('App Hide') console.log('App Hide')
}, },
methods: {
onExit: function() {
unregisterRequestPermissionTipsListener(null)
} }
} }
</script> </script>

7
components/callPhone/callPhone.vue

@ -26,10 +26,15 @@
show=true show=true
} }
}, },
callPhoneClick(item) {
async callPhoneClick(item) {
let phone = item.name let phone = item.name
// #ifdef APP-PLUS // #ifdef APP-PLUS
/* #ifdef APP-PLUS */
let result = await this.$store.dispatch("requestPermissions",'CALL_PHONE',)
if (result !== 1) return
/* #endif */
this.$u.utils.callPhone(phone) this.$u.utils.callPhone(phone)
// #endif // #endif

4
config/api.js

@ -161,9 +161,9 @@ export const signOutAuth = (data) => http.post('business/student/sign/outAuth',
// 签退 // 签退
export const signOut = (data) => http.post('business/student/sign/out', data) export const signOut = (data) => http.post('business/student/sign/out', data)
// 学员扫码签到前置校验——理科 // 学员扫码签到前置校验——理科
export const vailStudentSignSubject1 = (data) => http.post('business/student/theorySign/before_in', data)
export const vailStudentSignSubject1 = (data) => http.post('business/student/theorySign/before_in', data, {custom: {catch: true, toast: false }})
// 学员扫码签退前置校验——理科 // 学员扫码签退前置校验——理科
export const vailStudentSignOutSubject1 = (data) => http.post('business/student/theorySign/before_out', data)
export const vailStudentSignOutSubject1 = (data) => http.post('business/student/theorySign/before_out', data, {custom: {catch: true, toast: false }})
// 学员扫码签到—理科 // 学员扫码签到—理科
export const theorySignSubject1 = (data) => http.post('business/student/theorySign/in', data) export const theorySignSubject1 = (data) => http.post('business/student/theorySign/in', data)
// 学员扫码签退 -- 签退不做人脸—理科 // 学员扫码签退 -- 签退不做人脸—理科

2
config/site.config.js

@ -15,6 +15,6 @@ module.exports = {
// http://123.6.232.1:8099/测试地址 // http://123.6.232.1:8099/测试地址
// http://192.168.1.43:8318/本地地址
// http://192.168.1.106:8318//本地地址
//http://www.lyjppt.com/正式地址 //http://www.lyjppt.com/正式地址

12
config/utils.js

@ -166,8 +166,18 @@ export function uploadImgApi(filePath, imgName, imgLink='image') {
}) })
} }
export function scanCodeFn(_this) {
export async function scanCodeFn(_this) {
/* #ifdef APP-PLUS */
let result2 = await store.dispatch("requestPermissions",'CAMERA',)
if (result2 !== 1) return
let result = await store.dispatch("requestPermissions",'WRITE_EXTERNAL_STORAGE',)
if (result !== 1) return
/* #endif */
console.log('就这样吧')
// return
uni.scanCode({ uni.scanCode({
hideAlbum: true,
scanType: ['qrCode'], scanType: ['qrCode'],
success: function(res) { success: function(res) {
console.log('条码类型:' + res.scanType); console.log('条码类型:' + res.scanType);

12
manifest.json

@ -2,8 +2,8 @@
"name" : "洛阳学车", "name" : "洛阳学车",
"appid" : "__UNI__3347C6E", "appid" : "__UNI__3347C6E",
"description" : "", "description" : "",
"versionName" : "1.4.5",
"versionCode" : 145,
"versionName" : "1.4.6",
"versionCode" : 146,
"transformPx" : false, "transformPx" : false,
/* 5+App */ /* 5+App */
"app-plus" : { "app-plus" : {
@ -93,9 +93,9 @@
"ad" : {}, "ad" : {},
"maps" : { "maps" : {
"amap" : { "amap" : {
"name" : "amapOV4nNDfa",
"appkey_ios" : "2839b2b14fdcd2983e0d6247ce9baf7a", "appkey_ios" : "2839b2b14fdcd2983e0d6247ce9baf7a",
"appkey_android" : "3c5fcc5ee6aaba56e4806f3382399c16",
"name" : "amapOV4nNDfa"
"appkey_android" : "3c5fcc5ee6aaba56e4806f3382399c16"
} }
}, },
"geolocation" : { "geolocation" : {
@ -229,9 +229,9 @@
"disableHostCheck" : true, "disableHostCheck" : true,
"proxy" : { "proxy" : {
"/api" : { "/api" : {
// "target" : "http://www.lyjppt.com/",
"target" : "http://www.lyjppt.com/",
// "target" : "http://123.6.232.1:8099/", // "target" : "http://123.6.232.1:8099/",
"target" : "http://192.168.1.106:8318/",
// "target" : "http://192.168.1.106:8318/",
"changeOrigin" : true, "changeOrigin" : true,
"secure" : true, "secure" : true,
"pathRewrite" : { "pathRewrite" : {

8
pages/indexEntry/consult/pubComplaint/pubComplaint.vue

@ -186,7 +186,13 @@
this.imgArr.splice(index, 1) this.imgArr.splice(index, 1)
}, },
// //
chooseImages(type) {
async chooseImages(type) {
/* #ifdef APP-PLUS */
let result2 = await this.$store.dispatch("requestPermissions",'CAMERA',)
if (result2 !== 1) return
let result = await this.$store.dispatch("requestPermissions",'WRITE_EXTERNAL_STORAGE',)
if (result !== 1) return
/* #endif */
let imgNum = 3 - (this.imgArr.length) let imgNum = 3 - (this.imgArr.length)
uni.chooseImage({ uni.chooseImage({
count: imgNum, // count: imgNum, //

9
pages/indexEntry/consult/pubConsult/pubConsult.vue

@ -81,7 +81,14 @@
this.imgArr.splice(index, 1) this.imgArr.splice(index, 1)
}, },
// //
chooseImages(type) {
async chooseImages(type) {
/* #ifdef APP-PLUS */
// let result2 = await this.$store.dispatch("requestPermissions",'CAMERA',)
// if (result2 !== 1) return
// let result = await this.$store.dispatch("requestPermissions",'WRITE_EXTERNAL_STORAGE',)
// if (result !== 1) return
/* #endif */
let imgNum = 3 - (this.imgArr.length) let imgNum = 3 - (this.imgArr.length)
uni.chooseImage({ uni.chooseImage({
count: imgNum, // count: imgNum, //

7
pages/indexEntry/signIn/signAndOut/signAndOut.vue

@ -24,7 +24,7 @@
</view> </view>
<view class="textCon"> <view class="textCon">
<view class="text">信息认证</view> <view class="text">信息认证</view>
<view class="redTps" v-if="!step1">失败原因{{stepFailureReason}}</view>
<view class="redTps" v-if="!step1&&stepFailureReason">失败原因{{stepFailureReason}}</view>
</view> </view>
<view class="btn" :class="{red: !step1}">{{step1?'通过': '不通过'}}</view> <view class="btn" :class="{red: !step1}">{{step1?'通过': '不通过'}}</view>
</view> </view>
@ -109,7 +109,10 @@
} }
console.log('扫码传的参数') console.log('扫码传的参数')
console.log(this.params) console.log(this.params)
const res = await fn(this.params)
const res = await fn(this.params).catch((err)=>{
console.log(err,'出错了')
this.stepFailureReason = err.msg
})
console.log('第一步校验信息') console.log('第一步校验信息')
console.log(res) console.log(res)
console.log(res.msg) console.log(res.msg)

7
pages/indexEntry/signIn/signAndOut/signAndOutSubjiect1.vue

@ -24,7 +24,7 @@
</view> </view>
<view class="textCon"> <view class="textCon">
<view class="text">信息认证</view> <view class="text">信息认证</view>
<view class="redTps" v-if="!step1">失败原因{{stepFailureReason}}</view>
<view class="redTps" v-if="!step1&&stepFailureReason">失败原因{{stepFailureReason}}</view>
</view> </view>
<view class="btn" :class="{red: !step1}">{{step1?'通过': '不通过'}}</view> <view class="btn" :class="{red: !step1}">{{step1?'通过': '不通过'}}</view>
</view> </view>
@ -109,7 +109,10 @@
} }
console.log('扫码传的参数') console.log('扫码传的参数')
console.log(this.params) console.log(this.params)
const res = await fn(this.params)
const res = await fn(this.params).catch((err)=>{
console.log(err,'出错了')
this.stepFailureReason = err.msg
})
console.log('第一步校验信息') console.log('第一步校验信息')
console.log(res) console.log(res)
console.log(res.msg) console.log(res.msg)

27
pages/indexEntry/signIn/signIn.vue

@ -11,13 +11,14 @@
</view> </view>
</view> </view>
</view> </view>
<!-- <button @click="testFn">测试一下</button> -->
</view> </view>
</template> </template>
<script> <script>
import zengCalen from '@/uni_modules/zeng-calen/components/zeng-calen/zeng-calen' import zengCalen from '@/uni_modules/zeng-calen/components/zeng-calen/zeng-calen'
import { scanCodeFn } from '@/config/utils.js' import { scanCodeFn } from '@/config/utils.js'
import { monthSignRecord, signDetail, monthSignRecordSubjiect1, signDetailSubjiect1 } from '@/config/api.js'
import { monthSignRecord, signDetail, monthSignRecordSubjiect1, signDetailSubjiect1, getDescribeBodyFaceVerify } from '@/config/api.js'
export default { export default {
components: {zengCalen}, components: {zengCalen},
data() { data() {
@ -27,7 +28,7 @@
chooseDayLack: [], // chooseDayLack: [], //
list: [], list: [],
signMonth: '', signMonth: '',
tmpSubjiect1: []
tmpSubjiect1: [],
} }
}, },
onLoad() { onLoad() {
@ -35,6 +36,28 @@
this.monthSignRecordFn() this.monthSignRecordFn()
}, },
methods: { methods: {
testFn() {
let _this = this
const verifyPlugin = uni.requireNativePlugin('Ocr-FaceDetectModule');
let certifyId = 'sha22da9140ca0060462c566329c74d81'
verifyPlugin.verify({
certifyId,
// extParams: {
// kIdentityParamKeyIdCardFaceOnly: 'YES'
// }
}, function(response){
console.log(response)
if(response.code==1000) {
getDescribeBodyFaceVerify({certifyId,}).then((useRes)=>{
console.log('来这里了吗?')
})
}else if(response.code==2006) {
_this.$u.toast('认证失败!请确定是本人后再重试')
}else {
_this.$u.toast(response.msg||response.code)
}
});
},
// - // -
async monthSignRecordFn() { async monthSignRecordFn() {
const {data: res} = await monthSignRecord({signMonth: this.signMonth}) const {data: res} = await monthSignRecord({signMonth: this.signMonth})

25
pages/indexEntry/theory/theory.vue

@ -38,21 +38,20 @@
this.currentId = item.id this.currentId = item.id
}, },
goPage() { goPage() {
// return this.$u.toast('')
if(this.currentId==1) {
// let url = 'https://www.hzsjspx.com/theory/scienceStudy?token=amlhcGVpMTY5NTc3NzUzODg5ODA5NjU1&lat=30.343055&lng=120.183711&isUni=1'
let url =`http://121.41.97.244/question/question?phone=${this.vuex_userInfo.phone}&cityCode=3311&isUni=1`
if(!this.vuex_userInfo.phone) {
this.$u.toast('请先登录')
setTimeout(()=>{
uni.navigateTo({
url:'/pages/userCenter/login/login'
})
},1500)
return
}
let url =`http://question.ywxcw.cn/h5/index.html#/?phone=${this.vuex_userInfo.phone}&type=1`
// let url =`http://192.168.1.94:90`
this.$store.commit('updateWebVeiwUrl', url) this.$store.commit('updateWebVeiwUrl', url)
this.$goPage('/pages/indexEntry/theory/webView') this.$goPage('/pages/indexEntry/theory/webView')
}else if(this.currentId==2) {
let theory = website+':91/theory/'
let token = this.$store.state.user.vuex_loginInfo.accessToken
let lat = this.vuex_cityInfo.lat|| 30.27419537786047
let lng = this.vuex_cityInfo.lng|| 120.20633397715788
let url = `${theory}?token=${token}&lat=${lat}&lng=${lng}&isWx=1`
this.$store.commit('updateWebVeiwUrl', url)
this.$goPage('/pages/indexEntry/webView/webView')
}
} }
} }
} }

8
pages/indexEntry/theory/webView.vue

@ -1,6 +1,6 @@
<template> <template>
<view class="pageBg"> <view class="pageBg">
<web-view :src="link" :webview-styles="webviewStyles" :update-title="false"></web-view>
<web-view :src="link" :webview-styles="webviewStyles" :update-title="false" @message="handerMessage" @onPostMessage="handerMessage"></web-view>
</view> </view>
</template> </template>
@ -38,6 +38,12 @@
}) })
}, 1000); // }, 1000); //
// #endif // #endif
},
methods: {
handerMessage() {
console.log('会不会来这里呢?')
// uni.navigateBack()
}
} }
} }
</script> </script>

6
pages/mineEntry/personaInfo/personaInfo.vue

@ -13,7 +13,7 @@
<view class="card"> <view class="card">
<view class="row"> <view class="row">
<view class="lab">手机号</view> <view class="lab">手机号</view>
<view class="val">{{ vuex_userInfo.phone }}</view>
<view class="val">{{ showPhone(vuex_userInfo.phone) }}</view>
</view> </view>
</view> </view>
@ -92,6 +92,10 @@
}, },
methods: { methods: {
showPhone(phone) {
if(!phone) return ''
return phone.substr(0, 3)+'****'+phone.substr(7)
},
// //
async avatarApplyFn() { async avatarApplyFn() {
const res = await avatarApply({avatarImg: this.photoPath}) const res = await avatarApply({avatarImg: this.photoPath})

6
pages/tabbar/index/comp/schoolItem.vue

@ -22,7 +22,7 @@
</view> </view>
</callPhone> </callPhone>
</view> </view>
<view class="adr"><text style="margin-right: 6rpx;">{{item.districtName}}</text> 距您{{ $u.utils.distanceFn(item.distance)}}</view>
<view class="adr">{{item.districtName}}<text style="margin-left: 6rpx;" v-if="vuex_cityInfo.lat">距您{{ $u.utils.distanceFn(item.distance)}}</text> </view>
<!-- <view class="credit">行业信用 <text v-if="item.creditrating">{{item.creditrating}}</text></view> --> <!-- <view class="credit">行业信用 <text v-if="item.creditrating">{{item.creditrating}}</text></view> -->
</view> </view>
@ -48,8 +48,8 @@
methods: { methods: {
imgError() { imgError() {
delete this.item.schoolIntroduceDO.iconPath delete this.item.schoolIntroduceDO.iconPath
console.log('这图片有问题')
// this.$forceUpdate()
console.log('这图片有问题', this.item.schoolIntroduceDO.iconPath)
this.$forceUpdate()
} }
} }
} }

24
pages/tabbar/index/index.vue

@ -69,7 +69,7 @@
<!-- 推荐教练 --> <!-- 推荐教练 -->
<view class="coachCon" v-if="coachList.length"> <view class="coachCon" v-if="coachList.length">
<view class="h1_row"> <view class="h1_row">
<view class="h1" ><text class="active">推荐教练</text></view>
<view class="h1" ><text class="active">教练</text></view>
<moreRight text="查看全部" @click.native="$goPage('/pages/indexEntry/findCoach/findCoach')"/> <moreRight text="查看全部" @click.native="$goPage('/pages/indexEntry/findCoach/findCoach')"/>
</view> </view>
@ -166,11 +166,11 @@
icon: require('../../../static/images/indexIcon/entryIcon (5).png'), icon: require('../../../static/images/indexIcon/entryIcon (5).png'),
url: '/pages/indexEntry/signIn/signIn', url: '/pages/indexEntry/signIn/signIn',
}, },
// {
// text: '',
// icon: require('../../../static/images/indexIcon/entryIcon (2).png'),
// url: '/pages/indexEntry/theory/theory',
// },
{
text: '理论学习',
icon: require('../../../static/images/indexIcon/entryIcon (2).png'),
url: '/pages/indexEntry/theory/theory',
},
], ],
swiperDotIndex: 0, swiperDotIndex: 0,
@ -236,9 +236,7 @@
methods: { methods: {
async getLatLngFn() { async getLatLngFn() {
uni.showLoading({
title: '正在更新位置...'
})
await this.$store.dispatch('getCity') await this.$store.dispatch('getCity')
this.recommendSchoolList() this.recommendSchoolList()
}, },
@ -258,9 +256,9 @@
await this.getarticleListFn() await this.getarticleListFn()
await this.getRecommendList() await this.getRecommendList()
await this.recommendSchoolList() await this.recommendSchoolList()
this.$nextTick(()=>{uni.hideLoading()})
uni.hideLoading()
}catch(e){ }catch(e){
this.$nextTick(()=>{uni.hideLoading()})
uni.hideLoading()
} }
@ -282,8 +280,6 @@
// } // }
this.lat = this.vuex_cityInfo.lat this.lat = this.vuex_cityInfo.lat
const {data: res} = await recommendSchoolList({pageNo:1,pageSize: 20, lat: this.vuex_cityInfo.lat||'34.682945', lng: this.vuex_cityInfo.lng||'112.477298'}) const {data: res} = await recommendSchoolList({pageNo:1,pageSize: 20, lat: this.vuex_cityInfo.lat||'34.682945', lng: this.vuex_cityInfo.lng||'112.477298'})
res[8].schoolIntroduceDO.iconPath = ''
res[9].schoolIntroduceDO.iconPath = ''
this.recommendSchool = Object.freeze(res) this.recommendSchool = Object.freeze(res)
// this.recommendSchool = res // this.recommendSchool = res
// console.log(res) // console.log(res)
@ -301,7 +297,7 @@
this.$store.commit('updateSchool', {}) this.$store.commit('updateSchool', {})
return this.$u.utils.clickSignUp() return this.$u.utils.clickSignUp()
}else if(item.text=='签到签退') { }else if(item.text=='签到签退') {
// if(this.vuex_userInfo.applyStep<6) return this.$u.toast('')
if(this.vuex_userInfo.applyStep<6) return this.$u.toast('先报名学员')
} }
this.$goPage(item.url) this.$goPage(item.url)
}, },

7
pages/tabbar/mine/index.vue

@ -11,7 +11,7 @@
<view class="rightInfo" @click="topClick"> <view class="rightInfo" @click="topClick">
<view class="name-row"> <view class="name-row">
<view class="leftTxt"> <view class="leftTxt">
<view class="name">{{ vuex_userInfo.name?vuex_userInfo.name:vuex_userInfo.phone?vuex_userInfo.phone:'请登录' }}</view>
<view class="name">{{ vuex_userInfo.name?vuex_userInfo.name:vuex_userInfo.phone?showPhone(vuex_userInfo.phone):'请登录' }}</view>
<view class="arrowIcon"> <view class="arrowIcon">
<image src="@/static/images/icon/arrowRightfff.png" mode=""></image> <image src="@/static/images/icon/arrowRightfff.png" mode=""></image>
</view> </view>
@ -20,7 +20,7 @@
<image src="@/static/images/mineIcon/sanCode.png" mode=""></image> <image src="@/static/images/mineIcon/sanCode.png" mode=""></image>
</view> </view>
</view> </view>
<view class="phone" v-if="vuex_userInfo.name">{{ vuex_userInfo.phone }}</view>
<view class="phone" v-if="vuex_userInfo.name">{{ showPhone(vuex_userInfo.phone) }}</view>
</view> </view>
</view> </view>
<view class="pad"> <view class="pad">
@ -85,6 +85,9 @@
if(this.show) this.show = false if(this.show) this.show = false
}, },
methods: { methods: {
showPhone(phone) {
return phone.substr(0, 3)+'****'+phone.substr(7)
},
async deleteTestClick() { async deleteTestClick() {
const res = await deleteTest({phone: 18267103167}) const res = await deleteTest({phone: 18267103167})
this.$store.commit('goLogin') this.$store.commit('goLogin')

3
store/index.js

@ -2,8 +2,10 @@ import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import school from './modules/school'; import school from './modules/school';
import user from './modules/user'; import user from './modules/user';
import permissionToast from './modules/permissionToast';
import getters from './getters'; import getters from './getters';
Vue.use(Vuex); Vue.use(Vuex);
@ -28,6 +30,7 @@ const store = new Vuex.Store({
modules: { modules: {
school, school,
user, user,
permissionToast
}, },
}); });

230
store/modules/permissionToast.js

@ -0,0 +1,230 @@
// 页面路径:store/index.js
const permissionToast = {
// 初始化状态
state: {
// 处理应用程序权限请求
WRITE_EXTERNAL_STORAGE: false,
ACCESS_FINE_LOCATION: false,
CAMERA: false,
CALL_PHONE: false,
/* #ifdef APP-PLUS */
isIos: plus.os.name == "iOS",
/* #endif */
mapping: {
'CAMERA': {
title: "洛阳学车对扫开相机/摄像头权限申请说明",
content: "便于您使用该功能拍照,扫码,打卡签到签退等功能",
methods: 'SET_CAMERA'
},
'WRITE_EXTERNAL_STORAGE': {
title: "洛阳学车对存储空间/照片权限申请说明",
content: "便于您使用该功能上传您的照片/图片/视频及用于更换头像、下载、投诉与咨询等场景中读取和写入相册和文件内容。",
methods: 'SET_WRITE_EXTERNAL_STORAGE'
},
'ACCESS_FINE_LOCATION': {
title: "洛阳学车对地理位置权限申请说明",
content: "洛阳学车应用程序可以提供基于位置的服务、定位导航、计算距离、扫码场地打卡等功能。",
methods: 'SET_ACCESS_FINE_LOCATION'
},
'CALL_PHONE': {
title: "洛阳学车拨打/管理电话权限申请说明",
content: "便于您使用该功能联系驾校、教练场景下使用",
methods: 'SET_CALL_PHONE'
}
}
},
mutations: {
// 管理权限告知目的
SET_WRITE_EXTERNAL_STORAGE(state, val) {
state.WRITE_EXTERNAL_STORAGE = val
},
SET_CALL_PHONE(state, val) {
state.CALL_PHONE = val
},
SET_ACCESS_FINE_LOCATION(state, val) {
state.ACCESS_FINE_LOCATION = val
},
SET_CAMERA(state,val) {
state.CAMERA = val
}
},
actions: {
//权限获取
async requestPermissions({state,dispatch,commit}, permissionID) {
console.log('gogogoog来了没??')
try {
if (!state[permissionID] && !state.isIos) {
var viewObj = await dispatch('nativeObjView', permissionID);
viewObj.show();
}
console.log('android.permission.' + permissionID, '当前手机权限');
return new Promise(async (resolve, reject) => {
//苹果不需要这个
if (state.isIos) {
resolve(1);
return
}
// 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);
},
function(error) {
console.log('申请权限错误:' + error.code + " = " + error
.message);
resolve({
code: error.code,
message: error.message
});
}
);
});
}
const result = await requestAndroidPermission(
'android.permission.' + permissionID
);
if (result === 1) {
//'已获得授权'
commit(state.mapping[permissionID].methods, true)
} else if (result === 0) {
//'未获得授权'
commit(state.mapping[permissionID].methods, false)
} else {
commit(state.mapping[permissionID].methods, true)
uni.showModal({
title: '提示',
content: '操作权限已被拒绝,请手动前往设置',
confirmText: "立即设置",
success: (res) => {
if (res.confirm) {
dispatch('gotoAppPermissionSetting')
}
}
})
}
if (viewObj) viewObj.close()
resolve(result);
});
} catch (error) {
console.log(error);
uni.$u.toast('应用定位权限已关闭,请手动打开')
uni.hideLoading()
reject(error);
}
},
//提示框
nativeObjView({state}, permissionID) {
const systemInfo = uni.getSystemInfoSync();
const statusBarHeight = systemInfo.statusBarHeight;
const navigationBarHeight = systemInfo.platform === 'android' ? 48 :
44; // Set the navigation bar height based on the platform
const totalHeight = statusBarHeight + navigationBarHeight;
let view = new plus.nativeObj.View('per-modal', {
top: '0px',
left: '0px',
width: '100%',
backgroundColor: '#444',
//opacity: .5;
})
view.drawRect({
color: '#fff',
radius: '5px'
}, {
top: totalHeight + 'px',
left: '5%',
width: '90%',
height: "100px",
})
view.drawText(state.mapping[permissionID].title, {
top: totalHeight + 5 + 'px',
left: "8%",
height: "30px"
}, {
align: "left",
color: "#000",
}, {
onClick: function(e) {
console.log(e);
}
})
view.drawText(state.mapping[permissionID].content, {
top: totalHeight + 35 + 'px',
height: "60px",
left: "8%",
width: "84%"
}, {
whiteSpace: 'normal',
size: "14px",
align: "left",
color: "#656563"
})
function show() {
view = plus.nativeObj.View.getViewById('per-modal');
view.show()
view = null //展示的时候也得清空,不然影响下次的关闭,不知道为啥
}
function close() {
view = plus.nativeObj.View.getViewById('per-modal');
view.close();
view = null
}
return {
show,
close
}
},
// 跳转到**应用**的权限页面
gotoAppPermissionSetting({state}) {
if (state.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);
}
}
}
}
// 导出 store
export default permissionToast

50
store/modules/user.js

@ -2,7 +2,7 @@ import { httpPrefix } from '../../config/site.config.js';
// #ifdef APP-PLUS // #ifdef APP-PLUS
// import { requestSingleFreshLocation } from '@/common/js/qqLatLng.js' // import { requestSingleFreshLocation } from '@/common/js/qqLatLng.js'
// #endif // #endif
import store from '@/store/index.js'
let apiOk =true let apiOk =true
let refreshTokenFn = null let refreshTokenFn = null
let timer = null let timer = null
@ -62,8 +62,14 @@ const user = {
getCity({commit}) { getCity({commit}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// #ifdef APP-PLUS // #ifdef APP-PLUS
store.dispatch("requestPermissions",'ACCESS_FINE_LOCATION',).then((result)=>{
if (result !== 1) return
uni.showLoading({
title: '正在更新位置...'
})
getCityInfo(resolve, reject,commit) getCityInfo(resolve, reject,commit)
})
// #endif // #endif
// #ifdef H5 // #ifdef H5
@ -178,24 +184,28 @@ function getCityInfo(resolve, reject, commit) {
let result = res.location let result = res.location
if(result.latitude===0) { if(result.latitude===0) {
console.log('gogogo来了吗没有获取到经纬度?') console.log('gogogo来了吗没有获取到经纬度?')
// openGps()
uni.getLocation({
// type: 'wgs84',
type: 'gcj02',
success: function(res) {
console.log('只为弹出权限当前位置的经度:' + res.longitude);
// console.log('当前位置的纬度:' + res);
getCityInfo(resolve, reject, commit)
uni.hideLoading()
},
fail() {
uni.showToast({
title: '您的定位权限已关闭,请手动开启定位权限',
icon: 'none'
})
uni.hideLoading()
}
})
// uni.showToast({
// title: '您的定位权限已关闭,请手动开启定位权限',
// icon: 'none'
// })
// uni.hideLoading()
// uni.getLocation({
// // type: 'wgs84',
// type: 'gcj02',
// success: function(res) {
// console.log('只为弹出权限当前位置的经度:' + res.longitude);
// // console.log('当前位置的纬度:' + res);
// getCityInfo(resolve, reject, commit)
// uni.hideLoading()
// },
// fail() {
// uni.showToast({
// title: '您的定位权限已关闭,请手动开启定位权限',
// icon: 'none'
// })
// uni.hideLoading()
// }
// })
}else { }else {
console.log('腾讯云经纬度') console.log('腾讯云经纬度')
console.log(result) console.log(result)

8
uni_modules/uni-registerRequestPermissionTips/changelog.md

@ -0,0 +1,8 @@
## 1.0.3(2024-10-18)
修复4.25版引起的插件回调只触发一次的问题。
## 1.0.2(2024-09-05)
修复uni.chooseImage或者其他部分情况下弹窗不显示的bug。
## 1.0.1(2024-05-30)
修复云打包可能报错的bug
## 1.0.0(2024-03-09)
支持全局监听权限申请。当申请权限时,会在页面顶部显示申请权限的目的。

115
uni_modules/uni-registerRequestPermissionTips/package.json

@ -0,0 +1,115 @@
{
"id": "uni-registerRequestPermissionTips",
"displayName": "uni-registerRequestPermissionTips",
"version": "1.0.3",
"description": "支持android平台全局监听权限的申请。当申请权限时,会在页面顶部显示申请权限的目的。主要解决上架华为应用市场审核要求:APP在调用终端权限时,应同步告知用户申请该权限的目的。",
"keywords": [
"权限",
"权限申请",
"上架",
"华为"
],
"repository": "",
"engines": {
"HBuilderX": "^4.0"
},
"dcloudext": {
"type": "uts",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [
],
"uni-ext-api": {
"uni": {
"registerRequestPermissionTipsListener": {
"name": "registerRequestPermissionTipsListener",
"app": {
"js": false,
"kotlin": true,
"swift": false
}
},
"unregisterRequestPermissionTipsListener": {
"name": "unregisterRequestPermissionTipsListener",
"app": {
"js": false,
"kotlin": true,
"swift": false
}
},
"setRequestPermissionTips": {
"name": "setRequestPermissionTips",
"app": {
"js": false,
"kotlin": true,
"swift": false
}
}
}
},
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y",
"alipay": "y"
},
"client": {
"Vue": {
"vue2": "y",
"vue3": "y"
},
"App": {
"app-android": "y",
"app-ios": "n",
"app-harmony": "u"
},
"H5-mobile": {
"Safari": "n",
"Android Browser": "n",
"微信浏览器(Android)": "n",
"QQ浏览器(Android)": "n"
},
"H5-pc": {
"Chrome": "n",
"IE": "n",
"Edge": "n",
"Firefox": "n",
"Safari": "n"
},
"小程序": {
"微信": "n",
"阿里": "n",
"百度": "n",
"字节跳动": "n",
"QQ": "n",
"钉钉": "n",
"快手": "n",
"飞书": "n",
"京东": "n"
},
"快应用": {
"华为": "n",
"联盟": "n"
}
}
}
}
}

95
uni_modules/uni-registerRequestPermissionTips/readme.md

@ -0,0 +1,95 @@
## registerRequestPermissionTipsListener(listener?)
注册权限监听事件
## unregisterRequestPermissionTipsListener(listener?)
取消注册权限监听事件
## RequestPermissionTipsListener的属性值
|名称 |类型 |描述 |必填 |
|:-- |:-- |:-- |:-- |
|onRequest |(permissions:Array<string>)=>void |申请系统权限回调,permissions为触发权限申请的所有权限 |否 |
|onConfirm |(permissions:Array<string>)=>void |弹出系统权限授权框回调,permissions为触发弹出权限授权框的所有权限 |否 |
|onComplete |(permissions:UTSJSONObject)=>void |权限申请完成回调,permissions包括权限及权限的状态。`grant`为权限已获取,`denied`为权限已拒绝 |否 |
## setRequestPermissionTips(UTSJSONObject)
设置权限监听的说明。支持针对权限设置具体的说明。
参考:`{"android.permission.CAMERA":"<p>相机权限申请说明</p>"}`
安卓权限列表可参考[谷歌官方文档](https://developer.android.com/reference/android/Manifest.permission)。
权限申请说明基于原生TextView实现,可以实现加载html内容,支持的标签及属性可参考:
```
<b><strong>:加粗文本。
<i><em>:斜体文本。
<u>:下划线文本。
<sup>:上标文本。
<sub>:下标文本。
<tt>:等宽字体文本。
<big>:放大字体。
<small>:缩小字体。
<strike><s><del>:带有删除线的文本。
<p>:段落。
<div>:块级容器。
<h1><h2><h3><h4><h5><h6>:区域标题元素。
<ul>, <ol>, <li>:无序列表和有序列表。
<br>:换行。
<font color="..."><font size="...">:设置文本颜色和大小。
```
## 示例
```
<script>
import {
registerRequestPermissionTipsListener,
unregisterRequestPermissionTipsListener,
setRequestPermissionTips
} from "@/uni_modules/uni-registerRequestPermissionTips"
var PermissionTips = {
"android.permission.CAMERA": "<h4 style=\"font-size:40px;\">正在读取通讯录权限</h4><font color=#cccccc>通讯录权限不会获取任何信息,请注意</font>",
"android.permission.READ_PHONE_STATE": "<h4 style=\"font-size:40px;\">正在读取网络状态权限</h4><font color=#cccccc>通讯录权限不会获取任何信息,请注意通讯录权限不会获取任何信息,请注意通讯录权限不会获取任何信息,请注意</font>"
}
export default {
onLaunch: function() {
var brand = uni.getSystemInfoSync().deviceBrand
setRequestPermissionTips(PermissionTips)
registerRequestPermissionTipsListener({
onRequest: (e) => {
console.log(e)
},
onConfirm: (e) => {
console.log(e)
},
onComplete: (e) => {
// 华为手机在权限禁止之后,再次申请权限不会出现权限申请框。此时应该引导用户去系统设置开启此权限,不应该频繁申请。
if (brand.toLowerCase() == "huawei") {
var tips = {}
var hasDeniedPermission = false
for (var k in PermissionTips) {
if (e[k] != "denied") {
tips[k] = PermissionTips[k]
} else {
hasDeniedPermission = true
}
}
setRequestPermissionTips(tips) // 更新弹框提醒,防止华为手机不出现权限申请框时权限提醒框闪烁的情况
if (hasDeniedPermission)
uni.showModal({
content: "权限已经被拒绝,请前往设置中开启"
})
}
}
})
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
},
onExit: function() {
unregisterRequestPermissionTipsListener(null)
}
}
</script>
```

3
uni_modules/uni-registerRequestPermissionTips/utssdk/app-android/AndroidManifest.xml

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="io.dcloud.uts.permissionrequest">
</manifest>

3
uni_modules/uni-registerRequestPermissionTips/utssdk/app-android/config.json

@ -0,0 +1,3 @@
{
"minSdkVersion": "21"
}

148
uni_modules/uni-registerRequestPermissionTips/utssdk/app-android/index.uts

@ -0,0 +1,148 @@
import { UnregisterRequestPermissionTipsListener, RegisterRequestPermissionTipsListener, RequestPermissionTipsListener, SetRequestPermissionTips } from "../interface";
import RelativeLayout from 'android.widget.RelativeLayout';
import LinearLayout from 'android.widget.LinearLayout';
import Color from 'android.graphics.Color';
import TextView from 'android.widget.TextView';
import ViewGroup from 'android.view.ViewGroup';
import Activity from 'android.app.Activity';
import HashMap from 'java.util.HashMap';
import AnimationUtils from 'android.view.animation.AnimationUtils';
import R from 'io.dcloud.uts.permissionrequest.R'
import Html from 'android.text.Html';
import View from 'android.view.View';
import Runnable from "java.lang.Runnable"
let PermissionTipsView : View | null = null
let permissionTips : HashMap<String, String> = new HashMap<String, String>()
var permissionListener : RequestPermissionListener | null = null
var listener : RequestPermissionTipsListener | null = null
@UTSJS.keepAlive
export function unregisterRequestPermissionTipsListener(e : RequestPermissionTipsListener | null) {
listener = null;
if (permissionListener != null) {
permissionListener!.stop()
permissionListener = null
}
if (PermissionTipsView != null) {
if (PermissionTipsView!.getParent() != null) {
PermissionTipsView!.setAnimation(null);
((PermissionTipsView!.getParent()) as ViewGroup).removeView(PermissionTipsView)
}
PermissionTipsView = null
}
}
@UTSJS.keepAlive
export function registerRequestPermissionTipsListener(l : RequestPermissionTipsListener | null) {
listener = l
if (permissionListener == null) {
permissionListener = uni.createRequestPermissionListener()
permissionListener!.onRequest((permissions : Array<string>) => {
if (listener != null)
listener!.onRequest?.invoke(permissions)
})
permissionListener!.onConfirm((permissions : Array<string>) => {
UTSAndroid.getUniActivity()!.runOnUiThread(new ConfirmRunnable(permissions))
})
permissionListener!.onComplete((permissions : Array<string>) => {
UTSAndroid.getUniActivity()!.runOnUiThread(new CompleteRunnable(permissions))
})
}
}
class ConfirmRunnable implements Runnable {
permissions : Array<string>
constructor(permissions : Array<string>) {
this.permissions = permissions
}
override run() {
let activity = UTSAndroid.getUniActivity()!
if (PermissionTipsView != null && PermissionTipsView!.getParent() != null) {
PermissionTipsView!.setAnimation(null);
((PermissionTipsView!.getParent()) as ViewGroup).removeView(PermissionTipsView)
}
if (this.permissions.length > 0) {
try {
PermissionTipsView = createPermissionWindow(activity, this.permissions);
if (PermissionTipsView != null) {
(activity.findViewById(android.R.id.content) as ViewGroup).addView(PermissionTipsView!)
}
} catch (e) {
console.log(e)
}
}
if (listener != null)
listener!.onConfirm?.invoke(this.permissions)
}
}
class CompleteRunnable implements Runnable {
permissions : Array<string>
constructor(permissions : Array<string>) {
this.permissions = permissions
}
override run() {
let activity = UTSAndroid.getUniActivity()!
if (PermissionTipsView != null) {
PermissionTipsView!.setAnimation(AnimationUtils.loadAnimation(activity, R.anim.popupwindow_exit));
((PermissionTipsView!.getParent()) as ViewGroup).removeView(PermissionTipsView!)
PermissionTipsView = null
}
if (listener != null) {
var permissionStatus = {}
for (var p in this.permissions) {
permissionStatus[p] = UTSAndroid.checkSystemPermissionGranted(UTSAndroid.getUniActivity()!, [p]) ? "grant" : "denied"
}
listener!.onComplete?.invoke(permissionStatus)
}
}
}
export const setRequestPermissionTips : SetRequestPermissionTips = (tips : UTSJSONObject) => {
permissionTips.clear()
for (var k in tips) {
permissionTips.put(k, tips[k] != null ? tips[k].toString() : "")
}
}
function createPermissionWindow(activity : Activity, permissions : Array<string>) : ViewGroup | null {
let rootView = new RelativeLayout(activity);
rootView.setBackgroundColor(Color.TRANSPARENT);
let backgroundView = new LinearLayout(activity);
backgroundView.setPadding(30, 0, 30, 30);
backgroundView.setOrientation(1)
backgroundView.setBackgroundResource(R.drawable.dcloud_permission_background);
let permissionTipsList : Array<string> = new Array<string>()
for (var p in permissions) {
if (permissionTips.containsKey(p) && permissionTipsList.indexOf(permissionTips.get(p)) == -1) {
permissionTipsList.push(permissionTips.get(p)!)
}
}
for (var p in permissionTipsList) {
let text = new TextView(activity);
text.setText(Html.fromHtml(p, Html.FROM_HTML_SEPARATOR_LINE_BREAK_HEADING))
text.setPadding(0, 30, 0, 0)
text.setTextSize((5 * getScale()).toFloat())
text.setTextColor(Color.BLACK)
backgroundView.addView(text)
}
if (backgroundView.getChildCount() == 0) {
return null;
}
let rll = new RelativeLayout.LayoutParams(-1, -2)
rll.topMargin = (UTSAndroid.getStatusBarHeight() * getScale()).toInt();
rll.leftMargin = 30;
rll.rightMargin = 30;
rll.bottomMargin = 30;
rootView.addView(backgroundView, rll)
rootView.setAnimation(AnimationUtils.loadAnimation(activity, R.anim.popupwindow_enter));
return rootView;
}
function getScale() : Float {
if (UTSAndroid.getUniActivity() != null) {
return UTSAndroid.getUniActivity()!.resources.displayMetrics.scaledDensity
}
return (0 as number).toFloat();
}

6
uni_modules/uni-registerRequestPermissionTips/utssdk/app-android/res/anim/popupwindow_enter.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200"
android:fromYDelta="-100%"
android:toYDelta="0" >
</translate>

5
uni_modules/uni-registerRequestPermissionTips/utssdk/app-android/res/anim/popupwindow_exit.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200"
android:fromYDelta="0"
android:toYDelta="-100%" />

6
uni_modules/uni-registerRequestPermissionTips/utssdk/app-android/res/drawable/dcloud_permission_background.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="8dp" />
<!-- <stroke android:color="@color/black" android:width="2dp"/>-->
<solid android:color="#ffffff"/>
</shape>

19
uni_modules/uni-registerRequestPermissionTips/utssdk/interface.uts

@ -0,0 +1,19 @@
export type RequestPermissionTipsListener = {
onRequest ?: ((permissions : Array<string>) => void) | null,
onConfirm ?: ((permission : Array<string>) => void) | null,
onComplete ?: ((permissions : UTSJSONObject) => void) | null
}
export type RegisterRequestPermissionTipsListener = (listener : RequestPermissionTipsListener | null) => void
export type UnregisterRequestPermissionTipsListener = (listener : RequestPermissionTipsListener | null) => void
export type SetRequestPermissionTips = (tips : UTSJSONObject) => void
export interface Uni {
registerRequestPermissionTipsListener : RegisterRequestPermissionTipsListener,
unregisterRequestPermissionTipsListener : UnregisterRequestPermissionTipsListener
setRequestPermissionTips : SetRequestPermissionTips
}
Loading…
Cancel
Save