"use strict";
|
|
const common_vendor = require("../common/vendor.js");
|
|
function authorize(scope) {
|
|
return new Promise((success, error) => {
|
|
common_vendor.index.authorize({
|
|
/* scope.writePhotosAlbum 类型是保存到相册 */
|
|
scope,
|
|
success,
|
|
complete(res) {
|
|
common_vendor.index.getSetting({
|
|
success(res2) {
|
|
if (!res2.authSetting[scope]) {
|
|
setting();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
function setting() {
|
|
common_vendor.index.showModal({
|
|
title: "当前操作未授权,请授权!",
|
|
content: "拒绝授权将影响本小程序部分功能的使用",
|
|
confirmText: "授权",
|
|
success(e) {
|
|
if (!e.confirm) {
|
|
return error();
|
|
}
|
|
common_vendor.index.openSetting({
|
|
success(res) {
|
|
if (!res.authSetting[scope]) {
|
|
common_vendor.index.showToast({
|
|
title: "授权失败",
|
|
icon: "none"
|
|
});
|
|
return error();
|
|
}
|
|
success();
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
exports.authorize = authorize;
|
|
//# sourceMappingURL=../../.sourcemap/mp-weixin/utils/authorize.js.map
|