| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- /**
- * 健康积分/等级状态模块
- * P2-1 身份重塑系统
- */
- import api from '@/utils/api.js'
- var healthScoreStore = {
- state: {
- scoreInfo: null,
- timeline: [],
- scoreLoading: false
- },
- mutations: {
- setScoreInfo: function(state, info) {
- state.scoreInfo = info
- state.scoreLoading = false
- },
- setTimeline: function(state, list) {
- state.timeline = list
- },
- setScoreLoading: function(state) {
- state.scoreLoading = true
- }
- },
- actions: {
- fetchScoreInfo: function({ commit }, memberId) {
- if (!memberId) return
- commit('setScoreLoading')
- api.getHealthScoreInfo({ memberId: memberId }).then(function(res) {
- if (res.code === 200) {
- commit('setScoreInfo', res.data)
- } else {
- commit('setScoreLoading')
- }
- }).catch(function() {})
- },
- fetchTimeline: function({ commit }, memberId) {
- if (!memberId) return
- api.getHealthTimeline({ memberId: memberId }).then(function(res) {
- if (res.code === 200) {
- commit('setTimeline', res.data || [])
- }
- }).catch(function() {})
- }
- }
- }
- export default healthScoreStore
|