examTeamApp/store/actions.js

145 lines
3.2 KiB
JavaScript
Raw Normal View History

import model from "../toolJs/model.js"
import tools from '@/toolJs/tools.js'
2024-05-02 15:59:36 +08:00
// Action 包含异步操作请求API方法、回调函数提交mutaions更改state数据状态使之可以异步
export default {
2024-06-13 18:03:50 +08:00
// 账户信息
getAccountNumber({
2024-07-08 10:50:07 +08:00
commit
}) {
2024-06-13 18:03:50 +08:00
return model.getAccountNumber({}).then(res => {
console.log("账户信息", res.data)
if (res.code != 0) {
that.$tools.msg(res.msg)
return
}
commit('changeAccountNumber', res.data)
});
},
2024-07-08 10:50:07 +08:00
2024-05-02 15:59:36 +08:00
// 用户信息
getUserInfo({
commit
},
account) {
return model.getUserInfo(account).then(res => {
2024-05-29 16:35:45 +08:00
console.log("用户信息", res.data)
if (res.code != 0) {
that.$tools.msg(res.msg)
return
}
2024-06-13 18:03:50 +08:00
uni.setStorageSync('userid', res.data.id)
uni.setStorageSync('gender', res.data.gender)
2024-05-02 15:59:36 +08:00
commit('changeUser', res.data)
2024-07-22 14:13:19 +08:00
commit('changeLungLevel', res.data.vitalcapacity_data)
2024-05-29 16:35:45 +08:00
});
},
// 成员列表
getFamilyList({
commit
},
account) {
return model.getUserList(account).then(res => {
if (res.code != 0) {
that.$tools.msg(res.msg)
2024-05-02 15:59:36 +08:00
return
}
2024-05-29 16:35:45 +08:00
commit('changeFamilay', res.data)
2024-05-02 15:59:36 +08:00
});
2024-05-29 16:35:45 +08:00
},
// 获取所有卡片
getCardList({
commit
},
account) {
return model.getCardAllList(account).then(res => {
console.log("卡片列表", res.data)
commit('changeCardList', res.data)
})
},
// 身体数据
getResult({ //报告
commit
}, account) {
return model.getResult(account).then((res) => {
console.log("报告", res)
if (res.code == 0) {
commit('changeMeasureResult', res.data)
} else {
commit('changeMeasureResult', null)
}
})
},
// 跳绳数据
getSkipResult({ //报告
commit
}, account) {
return model.getSkipResult(account).then((res) => {
console.log("跳绳报告", res)
if (res.code == 0) {
commit('changeMeasureSkip', res.data)
} else {
commit('changeMeasureSkip', null)
}
})
},
// 肺活量
getLungResult({ //报告
commit
}, account) {
return model.getLungResult(account).then((res) => {
console.log("肺活量报告", res)
if (res.code == 0) {
2024-07-22 14:13:19 +08:00
commit('changeLungLevel', res.data.list)
2024-05-29 16:35:45 +08:00
commit('changeMeasureLung', res.data)
} else {
commit('changeMeasureLung', null)
}
})
},
2026-03-23 14:22:23 +08:00
// 公共
getPublicContent({ //报告
commit
}, account) {
return model.getpublicContent(account).then((res) => {
console.log("公共报告", res)
if (res.code == 0) {
commit('changePublicContent', res.data)
} else {
commit('changePublicContent', null)
}
})
},
2024-05-29 16:35:45 +08:00
GetBodyTrendList({ //趋势
commit
}, account) {
return model.getTrendList(account).then((res) => {
console.log("趋势", res)
commit('changeTrend', res.data)
})
},
gethistoryList({ // 获取历史记录
commit
}, account) {
return model.getHistoryList(account).then((res) => {
if (res.data && res.data.items) {
commit('changehistoryList', res.data.items)
} else {
commit('changehistoryList', null)
}
})
2024-07-08 10:50:07 +08:00
},
// 设备
getUserDeviceList({ // 用户设备
commit
}) {
return model.getUserDeviceList({}).then(res => {
console.log("用户设备", res)
if (res.data && res.data.list.length) {
commit('changeUserDeviceList', res.data.list)
} else {
commit('changeUserDeviceList', [])
}
})
},
2024-05-02 15:59:36 +08:00
}