common.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import request from '@/api/request'
  2. import { platform } from '@/utils/platform'
  3. import funWxShare from '@/utils/wxShare0.0'
  4. const state = {
  5. userinfo: {
  6. user_head_img_url: '', // 用户头像
  7. user_nickname: '', // 用户昵称
  8. user_sex: '', // 用户性别
  9. user_balance: 0, // 用户可提现余额(单位为分)
  10. user_crash_balance: 0, // 累计提现(单位为分)
  11. user_unreceive_balance: 0, // 用户未结算金额(单位为分)
  12. created_at: '', // 注册时间
  13. id: '', // 用户ID
  14. last_month_money: '', // 上月预估收益
  15. month_money: '' // 本月预估收益
  16. },
  17. orderType: [], // 订单类型
  18. inviteId: '', // 邀请人ID,分享链接携带
  19. isInit: false, // 获取用户信息接口、订单类型接口加锁
  20. // 商家列表
  21. sourceList: [
  22. {
  23. name: '京东',
  24. value: 'jd',
  25. default: require('../../assets/businessLogo/jd0.png'),
  26. active: require('../../assets/businessLogo/jd1.png'),
  27. logo: require('../../assets/businessLogo/jd2.png')
  28. },
  29. {
  30. name: '唯品会',
  31. value: 'vip',
  32. default: require('../../assets/businessLogo/vip0.png'),
  33. active: require('../../assets/businessLogo/vip1.png'),
  34. logo: require('../../assets/businessLogo/vip2.png')
  35. },
  36. {
  37. name: '拼多多',
  38. value: 'pdd',
  39. default: require('../../assets/businessLogo/pdd0.png'),
  40. active: require('../../assets/businessLogo/pdd1.png'),
  41. logo: require('../../assets/businessLogo/pdd2.png')
  42. },
  43. {
  44. name: '考拉',
  45. value: 'kaola',
  46. default: require('../../assets/businessLogo/kaola0.png'),
  47. active: require('../../assets/businessLogo/kaola1.png'),
  48. logo: require('../../assets/businessLogo/kaola2.png')
  49. },
  50. {
  51. name: '淘宝',
  52. value: 'taobao'
  53. }
  54. ]
  55. }
  56. const getters = {
  57. userinfo (state) {
  58. return state.userinfo
  59. },
  60. orderType (state) {
  61. return state.orderType
  62. },
  63. inviteId (state) {
  64. return state.inviteId
  65. },
  66. isInit (state) {
  67. return state.isInit
  68. },
  69. sourceList (state) {
  70. return state.sourceList
  71. }
  72. }
  73. const actions = {
  74. async getUserInfo ({ commit }) {
  75. try {
  76. const { status, data } = await request({
  77. method: 'GET',
  78. url: '/api/user/info'
  79. })
  80. if (status) {
  81. commit('UPDATE_USERINFO', data)
  82. platform.isWeixin && funWxShare('返不停', '一个省钱、赚钱又返钱的生活平台', `${location.origin}/img/share.png`, `${location.origin}?invite_id=${data.id}`)
  83. }
  84. } catch (err) {
  85. console.log(err)
  86. }
  87. },
  88. async getOrdertype ({ commit }) {
  89. try {
  90. const { status, data } = await request({
  91. method: 'GET',
  92. url: '/api/order/type/list'
  93. })
  94. if (status) {
  95. commit('UPDATE_ORDER_TYPE', data)
  96. }
  97. } catch (err) {
  98. console.log(err)
  99. }
  100. }
  101. }
  102. const mutations = {
  103. UPDATE_USERINFO (state, value) {
  104. state.userinfo = {
  105. ...value
  106. }
  107. },
  108. UPDATE_ORDER_TYPE (state, value) {
  109. state.orderType = [...value]
  110. },
  111. UPDATE_INVITE_ID (state, value) {
  112. state.inviteId = value
  113. },
  114. UPDATE_ISINIT (state, value) {
  115. state.isInit = value
  116. }
  117. }
  118. export default {
  119. namespaced: true,
  120. state,
  121. getters,
  122. actions,
  123. mutations
  124. }