sys.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import { defineStore } from 'pinia'
  2. import router from '@/router'
  3. interface SysState {
  4. /**
  5. * 状态栏高度
  6. */
  7. statusBarHeight: number
  8. /**
  9. * 胶囊按钮高度
  10. */
  11. MenuButtonHeight: number
  12. /**
  13. * 支付成功页面查看订单按钮跳转路径
  14. *
  15. */
  16. paySuccessPath: string
  17. /**
  18. * 支付成功页面返回首页按钮跳转路径
  19. */
  20. payBackIndexPath: string
  21. /**
  22. * 支付失败页面返回首页按钮跳转路径
  23. */
  24. payFailPath: string
  25. /**
  26. * 透明度
  27. */
  28. opcity: number
  29. /**
  30. * 是否上线审核
  31. */
  32. isOnlineAudit: boolean
  33. /**
  34. * 如果是组件模式加tabbar,从订单详情返回订单列表页面需要刷新,监听此字段刷新页面
  35. */
  36. refreshOrderList: boolean
  37. }
  38. export const useSysStore = defineStore('system', {
  39. state: (): SysState => ({
  40. statusBarHeight: 0,
  41. MenuButtonHeight: 0,
  42. paySuccessPath: '',
  43. payBackIndexPath: '',
  44. payFailPath: '',
  45. opcity: 0,
  46. isOnlineAudit: true,
  47. refreshOrderList: false,
  48. }),
  49. actions: {
  50. getSystemData() {
  51. const { statusBarHeight } = uni.getSystemInfoSync()
  52. const { height } = uni.getMenuButtonBoundingClientRect()
  53. this.statusBarHeight = Number(statusBarHeight)
  54. this.MenuButtonHeight = height
  55. },
  56. /**
  57. *
  58. * @param payBackIndexPath 支付成功页面返回首页按钮跳转路径
  59. *
  60. * @param paySuccessPath 支付成功页面查看订单按钮跳转路径
  61. */
  62. setPaySuccessPath(paySuccessPath: string, payBackIndexPath: string) {
  63. this.paySuccessPath = paySuccessPath
  64. this.payBackIndexPath = payBackIndexPath
  65. },
  66. async getAudit() {
  67. const res = await Apis.sys.dictPage({ data: { typeCode: 'sys_applet' } })
  68. this.isOnlineAudit = res.data?.list[0].value === '0'
  69. },
  70. /**
  71. * 申请退款获取退款订单信息
  72. * @param orderNumber
  73. * @returns
  74. */
  75. async getRefunOrder(orderNumber: string) {
  76. uni.showLoading({ mask: true })
  77. return new Promise((resolve, reject) => {
  78. Apis.xsb.findByOrderNumber({
  79. data: {
  80. orderNumber,
  81. },
  82. }).then((res) => {
  83. // resolve(res.data)
  84. router.push({ name: 'common-afterSales', params: { order: JSON.stringify(res.data) } })
  85. uni.hideLoading()
  86. }).catch((err) => {
  87. reject(err)
  88. uni.hideLoading()
  89. })
  90. })
  91. },
  92. },
  93. })