wechat.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * @description: 获取设备设置
  3. * @param {string} key
  4. * @return {*}
  5. */
  6. export const getSystemSetting = (key: string) => {
  7. const systemSetting = wx.getSystemSetting()
  8. if (key && key in systemSetting) {
  9. return systemSetting[key];
  10. } else {
  11. return systemSetting;
  12. }
  13. };
  14. /**
  15. * @description: 获取微信APP授权设置
  16. * @param {string} key
  17. * @return {*}
  18. * 'authorized'/'denied'/'not determined'
  19. * */
  20. export const getAppAuthorizeSetting = (key: string) => {
  21. const appAuthorizeSetting = wx.getAppAuthorizeSetting()
  22. if (key && key in appAuthorizeSetting) {
  23. return appAuthorizeSetting[key];
  24. } else {
  25. return appAuthorizeSetting;
  26. }
  27. };
  28. /**
  29. * @description: 获取设备基础信息
  30. * @param {string} key
  31. * @return {*}
  32. *
  33. * */
  34. export const getDeviceInfo = (key?: string) => {
  35. const deviceInfo = wx.getDeviceInfo()
  36. if (key && key in deviceInfo) {
  37. return deviceInfo[key];
  38. } else {
  39. return deviceInfo;
  40. }
  41. };
  42. /**
  43. * @description: 获取窗口信息
  44. * @param {string} key
  45. * @return {*}
  46. *
  47. * */
  48. export const getWindowInfo = (key: string) => {
  49. const windowInfo = wx.getWindowInfo()
  50. if (key && key in windowInfo) {
  51. return windowInfo[key];
  52. } else {
  53. return windowInfo;
  54. }
  55. };
  56. /**
  57. * @description: 获取微信APP基础信息
  58. * @param {string} key
  59. * @return {*}
  60. *
  61. * */
  62. export const getAppBaseInfo = (key?: string) => {
  63. const appBaseInfo = wx.getAppBaseInfo()
  64. if (key && key in appBaseInfo) {
  65. return appBaseInfo[key];
  66. } else {
  67. return appBaseInfo;
  68. }
  69. };