app.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { CHANGE_IS_IN_MINIPROGRAM, CHANGE_SYSTERM_INFO, CHANGE_SYSTERM_TERMINAL } from './type'
  2. import { isInWx } from '../../utils'
  3. export default {
  4. namespaced: true,
  5. state() {
  6. return {
  7. isInMiniProgram: false, // 是否套壳的
  8. systermInfo: {},
  9. terminal: 0,
  10. platformOperationShopId: 186
  11. }
  12. },
  13. mutations: {
  14. [CHANGE_IS_IN_MINIPROGRAM](state, tag) {
  15. if (tag) {
  16. state.isInMiniProgram = tag
  17. }
  18. },
  19. [CHANGE_SYSTERM_INFO](state, system) {
  20. state.systermInfo = system
  21. console.log(system)
  22. },
  23. [CHANGE_SYSTERM_TERMINAL](state, terminal) {
  24. state.terminal = terminal
  25. }
  26. },
  27. actions: {
  28. getUserSystermInfo({ commit }) {
  29. return new Promise((resolve, reject) => {
  30. uni.getSystemInfo({
  31. success: (systermInfo) => {
  32. commit(CHANGE_SYSTERM_INFO, systermInfo)
  33. resolve()
  34. },
  35. fail: () => {
  36. commit(CHANGE_SYSTERM_INFO, {})
  37. resolve()
  38. }
  39. })
  40. })
  41. },
  42. getSystermTerminal({ commit }) {
  43. return new Promise((resolve, reject) => {
  44. if (isInWx()) {
  45. commit(CHANGE_SYSTERM_TERMINAL, 3)
  46. } else {
  47. // #ifdef H5
  48. commit(CHANGE_SYSTERM_TERMINAL, 5) // H5包含pc和移动端浏览器和微信浏览器的可能
  49. // #endif
  50. // #ifdef APP
  51. commit(CHANGE_SYSTERM_TERMINAL, 1)
  52. // #endif
  53. // #ifdef MP-WEIXIN
  54. commit(CHANGE_SYSTERM_TERMINAL, 2)
  55. // #endif
  56. // #ifdef MP-ALIPAY
  57. commit(CHANGE_SYSTERM_TERMINAL, 4)
  58. // #endif
  59. }
  60. })
  61. }
  62. }
  63. }