kitchendDevice/tools/model.js

283 lines
6.8 KiB
JavaScript

import http from './https.js'
import tools from './tools.js'
import store from '@/store'
let options = [{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}]
export default {
onlogin(param) { // 登录
return http.post("/api/app/wxopen/onlogin", param).then(res => {
return res
})
},
getSendCode(param) { // 验证码
return http.post("/api/app/wxopen/sendcode", param).then(res => {
return res
})
},
getDeregister(param) { //手机号注册
return http.post("/api/app/wxopen/deregister", param).then(res => {
return res
})
},
getRegister(param) { // 微信授权登录
return http.post('/api/app/wxopen/register', param).then(res => {
return res
})
},
getConfig(param) { // 小程序配置
return http.post("/api/app/wxopen/config", param).then(res => {
return res
})
},
getoutlogin(param) { // 退出登录
return http.post("/api/app/wxopen/logout", param).then(res => {
return res
})
},
uploadimg(param) { // 图片上传
return http.post("/api/app/wxopen/uploadimg", param).then(res => {
return res
})
},
submitadvice(param) { // 意见反馈
return http.post("/api/app/wxopen/submitadvice", param).then(res => {
return res
})
},
getnumdata(param) { // 枚举数据
return http.get("/api/app/wxopen/getenumdata", param).then(res => {
return res
})
},
getinfo(param) { // 获取账户资料
return http.post("/api/app/wxopen/info", param).then(res => {
return res
})
},
// 记录管理
getAddinsect(param) { //添加驱虫记录
return http.post("/api/app/result/addinsect", param).then(res => {
return res
})
},
getAddvaccion(param) { //添加疫苗记录
return http.post("/api/app/result/addvaccion", param).then(res => {
return res
})
},
getAddweight(param) { //添加重量/身长记录
return http.post("/api/app/result/addweight", param).then(res => {
return res
})
},
getdelete(param) { //删除记录
return http.post("/api/app/result/delete", param).then(res => {
return res
})
},
getList(param) { //记录列表
return http.post("/api/app/result/list", param).then(res => {
let cidata = {
weight: {
categories: [],
series: [{
name: "体重",
color: "#5ba7ff",
data: [],
}]
},
height: {
categories: [],
series: [{
color: "#3fcba7",
name: "身长",
data: [],
}]
}
}
if (res.data && res.data.rows.length) {
let list = res.data.rows
list.forEach(item => {
item.options = options
cidata.weight.categories.push(item.recordtime);
cidata.height.categories.push(item.recordtime);
cidata.weight.series.forEach(ite => {
ite.data.push(item.weight)
})
cidata.height.series.forEach(ite => {
ite.data.push(item.height)
})
})
res.data.rows.cidata = cidata
}
return res
})
},
gettrandlist(param) { //身长/体重趋势列表
return http.post("/api/app/result/trendlist", param).then(res => {
if (res.code == 0) {
let list = res.data
let cidata = {
weight: {
categories: [],
series: [{
name: "体重",
color: "#5ba7ff",
data: [],
}]
},
height: {
categories: [],
series: [{
color: "#3fcba7",
name: "身长",
data: [],
}]
}
}
for (var i = 0; i < list.length; i++) {
cidata.weight.categories.push(list[i].recordtime);
cidata.height.categories.push(list[i].recordtime);
cidata.weight.series.forEach(item => {
item.data.push(list[i].weight)
})
cidata.height.series.forEach(item => {
item.data.push(list[i].height)
})
}
res.data.cidata = cidata
}
return res
})
},
// 宠物管理
getPetList(param) { //宠物列表
return http.post("/api/app/pet/list", param).then(res => {
let options = [{
text: '编辑',
style: {
backgroundColor: '#ccc'
}
}, {
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}]
if (res.code == 0 && res.data && res.data.length) {
res.data.forEach(item => {
item.options = options
item.birthday = item.birthday.substring(0, 10)
})
}
return res
})
},
getPetDelete(param) { //宠物删除
return http.post("/api/app/pet/delete", param).then(res => {
return res
})
},
getPetInfo(param) { //宠物资料
return http.post("/api/app/pet/info", param).then(res => {
if (res.data.conf.alertlist.length) {
let alertlist = res.data.conf.alertlist //提醒类型
let insectlist = res.data.conf.insectlist //驱虫类型
let vaccionlist = res.data.conf.vaccionlist //疫苗类型
let petalerttype = store.state.enumdata.petalerttype
let petinsecttype = store.state.enumdata.petinsecttype
let vacciontype = store.state.enumdata.vacciontype
res.data.conf.alertlist = tools.jsonList(alertlist, petalerttype)
res.data.conf.insectlist = tools.jsonList(insectlist, petinsecttype)
res.data.conf.vaccionlist = tools.jsonList(vaccionlist, vacciontype)
}
return res
})
},
getPetSubmit(param) { //宠物信息提交
return http.post("/api/app/pet/submit", param).then(res => {
return res
})
},
getPetType(param) { //宠物类型列表
return http.post("/api/app/pet/typelist", param).then(res => {
return res
})
},
// ji记事本
getNotepadList(param) { //记事列表
return http.post("/api/app/notepad/list", param).then(res => {
if (res.data && res.data.rows.length) {
res.data.rows.forEach(item => {
item.options = options
})
}
return res
})
},
getNotepadDelete(param) { //记事删除
return http.post("/api/app/notepad/delete", param).then(res => {
return res
})
},
getNotepadSubmit(param) { //增加记事
return http.post("/api/app/notepad/submit", param).then(res => {
return res
})
},
// 提醒
getAlertList(param) { //提醒列表
return http.post("/api/app/alert/list", param).then(res => {
let options2 = [{
text: '忽略',
style: {
backgroundColor: '#dfdfdf'
}
}, {
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}]
if (res.data && res.data.rows.length) {
res.data.rows.forEach(item => {
if (item.status == 1) {
item.options = options2
} else {
item.options = options
}
})
}
return res
})
},
getAlertDelete(param) { //提醒删除
return http.post("/api/app/alert/delete", param).then(res => {
return res
})
},
getAlertStatus(param) { //提醒状态修改
return http.post("/api/app/alert/setstatus", param).then(res => {
return res
})
},
getAlertSubmit(param) { //提醒信息提交
return http.post("/api/app/alert/submit", param).then(res => {
return res
})
},
getnoticelist(param) { //通知列表
return http.post("/api/app/alert/noticelist", param).then(res => {
return res
})
}
}