爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB

  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. function authorize(scope) {
  4. return new Promise((success, error) => {
  5. common_vendor.index.authorize({
  6. /* scope.writePhotosAlbum 类型是保存到相册 */
  7. scope,
  8. success,
  9. complete(res) {
  10. common_vendor.index.getSetting({
  11. success(res2) {
  12. if (!res2.authSetting[scope]) {
  13. setting();
  14. }
  15. }
  16. });
  17. }
  18. });
  19. function setting() {
  20. common_vendor.index.showModal({
  21. title: "当前操作未授权,请授权!",
  22. content: "拒绝授权将影响本小程序部分功能的使用",
  23. confirmText: "授权",
  24. success(e) {
  25. if (!e.confirm) {
  26. return error();
  27. }
  28. common_vendor.index.openSetting({
  29. success(res) {
  30. if (!res.authSetting[scope]) {
  31. common_vendor.index.showToast({
  32. title: "授权失败",
  33. icon: "none"
  34. });
  35. return error();
  36. }
  37. success();
  38. }
  39. });
  40. }
  41. });
  42. }
  43. });
  44. }
  45. exports.authorize = authorize;
  46. //# sourceMappingURL=../../.sourcemap/mp-weixin/utils/authorize.js.map