app.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { SET_SHOW_LOADING } from './type'
  2. import { doPointRequest } from '../../config/requestApi'
  3. import { J_STORAGE_KEY } from '../../config/constant'
  4. export default {
  5. namespaced: true,
  6. state() {
  7. return {
  8. globalLoading: {
  9. showLoading: false,
  10. showInfo: ''
  11. }
  12. }
  13. },
  14. mutations: {
  15. [SET_SHOW_LOADING](state, obj) {
  16. state.globalLoading.showLoading = obj.flag
  17. state.globalLoading.showInfo = obj.info
  18. }
  19. },
  20. actions: {
  21. /**
  22. *
  23. * @param context
  24. * @param data {{eventType:1-浏览商品 2-添加购物车 3-提交订单,productIds:字符串逗号分割}}
  25. * @returns {Promise<void>}
  26. */
  27. async doPointer(context, data) {
  28. // 判断是否登录
  29. let item = {}
  30. if (uni.getStorageSync(J_STORAGE_KEY)) {
  31. item = uni.getStorageSync(J_STORAGE_KEY)
  32. }
  33. if (JSON.stringify(item) === '{}') {
  34. return
  35. }
  36. const res = await doPointRequest(data)
  37. // const res = await NET.request(API.doPointer, data, 'post')
  38. console.log('埋点---------------------------------->', res)
  39. }
  40. }
  41. }