system.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 appid = common_vendor.index.getStorageSync("appid");
  35. const params = {
  36. code,
  37. appid
  38. };
  39. const res = await services_ams.getPhoneNumberInfo(params);
  40. try {
  41. if (res.code === 200) {
  42. common_vendor.index.setStorageSync("phone", res.data);
  43. if (path) {
  44. common_vendor.index.navigateTo({
  45. url: path
  46. });
  47. }
  48. } else {
  49. common_vendor.index.showToast({
  50. title: "获取手机号失败",
  51. icon: "none"
  52. });
  53. }
  54. return res.data;
  55. } catch (err) {
  56. common_vendor.index.showToast({
  57. title: "获取手机号失败",
  58. icon: "none"
  59. });
  60. }
  61. };
  62. const isGetPhone = () => {
  63. const data = JSON.parse(common_vendor.index.getStorageSync("activityData")) || {};
  64. const authCheck = (data == null ? void 0 : data.authCheck.split(",")) || [];
  65. const isCheck = authCheck.includes("1");
  66. const isPhone = !!common_vendor.index.getStorageSync("phone");
  67. return isCheck && isPhone;
  68. };
  69. exports.getActivityData = getActivityData;
  70. exports.getMobile = getMobile;
  71. exports.getNavBarPaddingTop = getNavBarPaddingTop;
  72. exports.getNavTop = getNavTop;
  73. exports.getStatusBarHeight = getStatusBarHeight;
  74. exports.isGetPhone = isGetPhone;