system.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. const services_ams = require("../services/ams.js");
  4. const getNavTop = () => {
  5. let windowWidth = common_vendor.wx$1.getSystemInfoSync().windowWidth;
  6. const statusBarHeight = common_vendor.wx$1.getSystemInfoSync().statusBarHeight;
  7. const menuButton = common_vendor.wx$1.getMenuButtonBoundingClientRect();
  8. (menuButton.height + (menuButton.top - statusBarHeight) * 2) * (750 / windowWidth);
  9. const navTop = statusBarHeight * (750 / windowWidth);
  10. return navTop;
  11. };
  12. const SYSTEM_INFO = common_vendor.index.getWindowInfo();
  13. const getStatusBarHeight = () => SYSTEM_INFO.statusBarHeight;
  14. const getNavBarPaddingTop = () => {
  15. if (common_vendor.index.getMenuButtonBoundingClientRect) {
  16. let { top, height } = common_vendor.index.getMenuButtonBoundingClientRect();
  17. return height + (top - getStatusBarHeight());
  18. } else {
  19. return 0;
  20. }
  21. };
  22. const getActivityData = () => {
  23. const appid = common_vendor.index.getStorageSync("appid");
  24. let isAuth = false;
  25. services_ams.getActivity(appid).then((res) => {
  26. const data = res.data[0] || {};
  27. common_vendor.index.setStorageSync("activityData", JSON.stringify(data));
  28. }).catch((err) => {
  29. console.log(err);
  30. });
  31. return isAuth;
  32. };
  33. const getMobile = async (code, path) => {
  34. const res = await services_ams.getPhoneNumberInfo(code);
  35. try {
  36. if (res.code === 200) {
  37. common_vendor.index.setStorageSync("phone", res.data);
  38. if (path) {
  39. common_vendor.index.navigateTo({
  40. url: path
  41. });
  42. }
  43. } else {
  44. common_vendor.index.showToast({
  45. title: "获取手机号失败",
  46. icon: "none"
  47. });
  48. }
  49. return res.data;
  50. } catch (err) {
  51. common_vendor.index.showToast({
  52. title: "获取手机号失败",
  53. icon: "none"
  54. });
  55. }
  56. };
  57. const isGetPhone = () => {
  58. const data = JSON.parse(common_vendor.index.getStorageSync("activityData")) || {};
  59. const authCheck = (data == null ? void 0 : data.authCheck.split(",")) || [];
  60. const isCheck = authCheck.includes("1");
  61. const isPhone = !!common_vendor.index.getStorageSync("phone");
  62. return isCheck && isPhone;
  63. };
  64. exports.getActivityData = getActivityData;
  65. exports.getMobile = getMobile;
  66. exports.getNavBarPaddingTop = getNavBarPaddingTop;
  67. exports.getNavTop = getNavTop;
  68. exports.getStatusBarHeight = getStatusBarHeight;
  69. exports.isGetPhone = isGetPhone;