ReedawFoodApp/store/actions.js

145 lines
3.2 KiB
JavaScript
Raw Normal View History

2025-05-30 11:14:38 +08:00
import model from "../toolJs/model.js"
import tools from '@/toolJs/tools.js'
// Action 包含异步操作请求API方法、回调函数提交mutaions更改state数据状态使之可以异步
export default {
// 账户信息
getAccountNumber({
commit
}) {
return model.getAccountNumber({}).then(res => {
console.log("账户信息", res.data)
if (res.code != 0) {
tools.msg(res.msg)
return
}
commit('changeAccountNumber', res.data)
});
},
// 用户信息
getUserInfo({
commit
},
account) {
return model.getUserInfo(account).then(res => {
console.log("用户信息", res.data)
if (res.code != 0) {
tools.msg(res.msg)
return
}
uni.setStorageSync('userid', res.data.id)
uni.setStorageSync('gender', res.data.gender)
commit('changeUser', res.data)
commit('changeLungLevel', res.data.vitalcapacity_data)
});
},
// 成员列表
getFamilyList({
commit
},
account) {
return model.getUserList(account).then(res => {
if (res.code != 0) {
tools.msg(res.msg)
return
}
commit('changeFamilay', res.data)
});
},
// 获取所有卡片
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) {
commit('changeLungLevel', res.data.list)
commit('changeMeasureLung', res.data)
} else {
commit('changeMeasureLung', null)
}
})
},
// 公共
getPublicContent({ //报告
commit
}, account) {
return model.getpublicContent(account).then((res) => {
console.log("公共报告", res)
if (res.code == 0) {
commit('changePublicContent', res.data)
} else {
commit('changePublicContent', null)
}
})
},
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)
}
})
},
// 设备
getUserDeviceList({ // 用户设备
commit
}) {
return model.getUserDeviceList({}).then(res => {
console.log("用户设备", res)
if (res.data) {
commit('changeUserDeviceList', res.data.list)
} else {
commit('changeUserDeviceList', [])
}
})
},
}