前端-胡立永 2 weeks ago
parent
commit
dc91222fc0
3 changed files with 61 additions and 0 deletions
  1. +6
    -0
      mixins/configList.js
  2. +53
    -0
      utils/authorize.js
  3. +2
    -0
      utils/index.js

+ 6
- 0
mixins/configList.js View File

@ -56,6 +56,12 @@ export default {
} }
return o return o
}, },
onLoad(query) {
if (query.shareId) {
uni.setStorageSync('shareId', query.shareId)
}
console.log(`uni.setStorageSync('shareId', ${query.shareId})`);
},
methods: { methods: {
} }
} }

+ 53
- 0
utils/authorize.js View File

@ -0,0 +1,53 @@
function authorize(scope){
return new Promise((success, error) => {
uni.authorize({
/* scope.writePhotosAlbum 类型是保存到相册 */
scope,
success,
complete(res) {
/* 判断如果没有授权就打开设置选项让用户重新授权 */
uni.getSetting({
success(res) {
if (!res.authSetting[scope]) {
setting()
}
}
});
}
});
function setting(){
uni.showModal({
title: '当前操作未授权,请授权!',
content: '拒绝授权将影响本小程序部分功能的使用',
confirmText: '授权',
success(e) {
if(!e.confirm){
return error()
}
uni.openSetting({
success(res) {
if (!res.authSetting[scope]) {
uni.showToast({
title: '授权失败',
icon: 'none',
})
return error()
}
success()
}
});
}
})
}
})
}
export default authorize

+ 2
- 0
utils/index.js View File

@ -19,8 +19,10 @@ Vue.prototype.$wxPay = wxPay
dayjs.locale('zh-cn') dayjs.locale('zh-cn')
import Oss from '@/utils/oss-upload/oss/index.js' import Oss from '@/utils/oss-upload/oss/index.js'
import authorize from '@/utils/authorize.js'
import { handleTree } from './tree.js' import { handleTree } from './tree.js'
Vue.prototype.$authorize = authorize
Vue.prototype.$handleTree = handleTree Vue.prototype.$handleTree = handleTree
Vue.prototype.$Oss = Oss Vue.prototype.$Oss = Oss
Vue.prototype.$dayjs = dayjs Vue.prototype.$dayjs = dayjs


Loading…
Cancel
Save