system.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. common_vendor.index.showToast({
  37. title: res.msg,
  38. icon: "success"
  39. });
  40. common_vendor.index.setStorageSync("phone", res.data);
  41. if (path) {
  42. common_vendor.index.navigateTo({
  43. url: path
  44. });
  45. }
  46. return res.data;
  47. } catch (err) {
  48. common_vendor.index.showToast({
  49. title: err.msg,
  50. icon: "none"
  51. });
  52. }
  53. };
  54. const isGetPhone = () => {
  55. const data = JSON.parse(common_vendor.index.getStorageSync("activityData")) || {};
  56. const authCheck = (data == null ? void 0 : data.authCheck.split(",")) || [];
  57. const isCheck = authCheck.includes("1");
  58. const isPhone = !!common_vendor.index.getStorageSync("phone");
  59. return isCheck && isPhone;
  60. };
  61. exports.getActivityData = getActivityData;
  62. exports.getMobile = getMobile;
  63. exports.getNavBarPaddingTop = getNavBarPaddingTop;
  64. exports.getNavTop = getNavTop;
  65. exports.getStatusBarHeight = getStatusBarHeight;
  66. exports.isGetPhone = isGetPhone;