sys.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { defineStore } from 'pinia'
  2. interface SysState {
  3. /**
  4. * 状态栏高度
  5. */
  6. statusBarHeight: number
  7. /**
  8. * 胶囊按钮高度
  9. */
  10. MenuButtonHeight: number
  11. /**
  12. * 支付成功页面查看订单按钮跳转路径
  13. *
  14. */
  15. paySuccessPath: string
  16. /**
  17. * 支付成功页面返回首页按钮跳转路径
  18. */
  19. payBackIndexPath: string
  20. /**
  21. * 支付失败页面返回首页按钮跳转路径
  22. */
  23. payFailPath: string
  24. /**
  25. * 透明度
  26. */
  27. opcity: number
  28. /**
  29. * 是否上线审核
  30. */
  31. isOnlineAudit: boolean
  32. }
  33. export const useSysStore = defineStore('system', {
  34. state: (): SysState => ({
  35. statusBarHeight: 0,
  36. MenuButtonHeight: 0,
  37. paySuccessPath: '',
  38. payBackIndexPath: '',
  39. payFailPath: '',
  40. opcity: 0,
  41. isOnlineAudit: true,
  42. }),
  43. actions: {
  44. getSystemData() {
  45. const { statusBarHeight } = uni.getSystemInfoSync()
  46. const { height } = uni.getMenuButtonBoundingClientRect()
  47. this.statusBarHeight = Number(statusBarHeight)
  48. this.MenuButtonHeight = height
  49. },
  50. /**
  51. *
  52. * @param payBackIndexPath 支付成功页面返回首页按钮跳转路径
  53. *
  54. * @param paySuccessPath 支付成功页面查看订单按钮跳转路径
  55. */
  56. setPaySuccessPath(paySuccessPath: string, payBackIndexPath: string) {
  57. this.paySuccessPath = paySuccessPath
  58. this.payBackIndexPath = payBackIndexPath
  59. },
  60. async getAudit() {
  61. const res = await Apis.sys.dictPage({ data: { typeCode: 'sys_applet' } })
  62. this.isOnlineAudit = res.data?.list[0].value === '0'
  63. console.log(res.data?.list[0].value === '0')
  64. },
  65. },
  66. })