ReedawFoodApp/store/actions.js

178 lines
3.6 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 {
2026-03-23 09:50:49 +08:00
//配置接口
getHomeConfig({
commit,
dispatch
}) {
return model.getHomeConfig({}).then(res => {
2026-03-31 16:04:41 +08:00
res.data.language_arr = [{
"name": "中文",
"val": "zh",
"key": "zh"
}, {
"name": "English",
"val": "en",
"key": "en"
}, {
"name": "日本語(Japanese)",
"val": "jp",
"key": "ja"
}, {
"name": "Français(French)",
"val": "fra",
"key": "fr"
}, {
"name": "Deutsch(German)",
"val": "de",
"key": "de"
}, {
"name": "한국어(Korean)",
"val": "kor",
"key": "ko"
}, {
"name": "Русский(Russian)",
"val": "ru",
"key": "ru"
}, {
"name": "Português(Portuguese)",
"val": "pt",
"key": "pt"
}, {
"name": "Español(Spanish)",
"val": "spa",
"key": "es"
}, {
"name": "Arabic(العربية)",
"val": "ara",
"key": "ar"
}]
2026-03-23 09:50:49 +08:00
commit('changeConfigInfo', res.data)
return res.data
})
},
2025-05-30 11:14:38 +08:00
// 账户信息
getAccountNumber({
commit
}) {
return model.getAccountNumber({}).then(res => {
console.log("账户信息", res.data)
if (res.code != 0) {
tools.msg(res.msg)
return
}
commit('changeAccountNumber', res.data)
});
},
2026-03-23 09:50:49 +08:00
// 成员列表
getFamilyList({
2025-05-30 11:14:38 +08:00
commit
},
account) {
2026-03-23 09:50:49 +08:00
return model.getUserList(account).then(res => {
2025-05-30 11:14:38 +08:00
if (res.code != 0) {
tools.msg(res.msg)
return
}
2026-03-23 09:50:49 +08:00
commit('changeFamilay', res.data.user_list)
2025-05-30 11:14:38 +08:00
});
},
2026-03-23 09:50:49 +08:00
// 用户信息
getUserInfo({
2025-05-30 11:14:38 +08:00
commit
},
account) {
2026-03-23 09:50:49 +08:00
return model.getUserInfo(account).then(res => {
console.log("用户信息", res.data)
2025-05-30 11:14:38 +08:00
if (res.code != 0) {
tools.msg(res.msg)
return
}
2026-03-30 10:02:10 +08:00
uni.setStorageSync('userid', res.data.aud_id)
2026-03-23 09:50:49 +08:00
uni.setStorageSync('gender', res.data.gender)
commit('changeUser', res.data)
2025-05-30 11:14:38 +08:00
});
},
2026-03-23 09:50:49 +08:00
// 首页身体数据
getResult({
2025-05-30 11:14:38 +08:00
commit
}, account) {
2026-03-23 09:50:49 +08:00
return model.getResultHome(account).then((res) => {
2025-05-30 11:14:38 +08:00
console.log("报告", res)
if (res.code == 0) {
commit('changeMeasureResult', res.data)
} else {
commit('changeMeasureResult', null)
}
})
},
2026-03-23 09:50:49 +08:00
// 获取用户卡片
getCardAllList({
commit
},
account) {
return model.getCardAllList(account).then(res => {
commit('changeCardList', res.data)
})
},
2026-03-30 10:02:10 +08:00
//趋势
GetBodyTrendList({
commit
}, account) {
return model.getTrendList(account).then((res) => {
console.log("趋势", res)
commit('changeTrend', res.data)
})
},
2026-03-27 10:04:26 +08:00
getPublicRecord({
commit
}, account) {
let that = this
return model.getPublicRecord(account).then(res => {
if (res.code == 0) {
commit('changePublicRecord', res.data)
}
})
},
2025-05-30 11:14:38 +08:00
// 跳绳数据
getSkipResult({ //报告
commit
}, account) {
2026-03-23 09:50:49 +08:00
return model.getSkipDataResult(account).then((res) => {
2025-05-30 11:14:38 +08:00
console.log("跳绳报告", res)
if (res.code == 0) {
commit('changeMeasureSkip', res.data)
} else {
commit('changeMeasureSkip', null)
}
})
},
// 肺活量
getLungResult({ //报告
commit
}, account) {
2026-03-23 09:50:49 +08:00
return model.getLungDataResult(account).then((res) => {
2025-05-30 11:14:38 +08:00
if (res.code == 0) {
commit('changeLungLevel', res.data.list)
commit('changeMeasureLung', res.data)
} else {
commit('changeMeasureLung', null)
}
})
},
2026-03-23 09:50:49 +08:00
// 计食器信息
getCountFoodInfo({
2025-05-30 11:14:38 +08:00
commit
}, account) {
2026-03-23 09:50:49 +08:00
return model.getCountFoodInfo(account).then(res => {
if (res.code == 0) {
commit('changeCountFoodInfo', res.data)
2025-05-30 11:14:38 +08:00
}
2026-03-23 09:50:49 +08:00
return res.data
});
2025-05-30 11:14:38 +08:00
},
}