minix-template
Version:
minix template
237 lines (235 loc) • 4.99 kB
JavaScript
/*
* @Description:
* @Autor: tangsj
* @Date: 2022-05-12 19:08:11
* @LastEditTime: 2022-05-23 16:18:45
*/
import router from '@system.router'
import prompt from '@system.prompt'
export default {
data: {
homeList:[
{
name:'getHomeInfo',
// url:'pages/base/canlUse/index',
describe:'获取家庭信息及其设备列表'
},
{
name:'getAllHomeInfoList',
// url:'pages/base/log/index',
describe:'获取所有的家庭信息(不包含设备信息)'
},
{
name:'createHome',
// url:'pages/base/canlUse/index',
describe:'创建家庭'
},
{
name:'updateHomeInfo',
// url:'pages/base/log/index',
describe:'更新家庭信息'
},
{
name:'deleteHome',
// url:'pages/base/log/index',
describe:'删除家庭'
},
{
name:'getHomeMemberList',
// url:'pages/base/log/index',
describe:'获取家庭成员列表'
},
{
name:'inviteToHome',
// url:'pages/base/log/index',
describe:'邀请家庭成员'
}
]
},
goRouter(url){
router.push({
uri: url,
})
},
/**
* @description: 获取家庭信息及其设备列表
* @param {*}
* @return {*}
*/
getHomeInfo(){
const params = {
homeId: "1",
isCurrentFamily: "1",
hasRoomAndDeviceInfo: "000 "
}
this.$app.$def.bridge.getHomeInfo(params).then((res)=>{
prompt.showToast({
message: res,
duration: 200,
})
}).catch((err)=>{
prompt.showToast({
message: '接口调用失败',
duration: 200,
})
})
},
/**
* @description: 获取所有的家庭信息(不包含设备信息)
* @param {*}
* @return {*}
*/
getAllHomeInfoList(){
this.$app.$def.bridge.getAllHomeInfoList().then((res)=>{
prompt.showToast({
message: res,
duration: 200,
})
}).catch((err)=>{
prompt.showToast({
message: '接口调用失败',
duration: 200,
})
})
},
/**
* @description: 创建家庭
* @param {*}
* @return {*}
*/
createHome(){
const params = {
name: "tsj测试"
}
this.$app.$def.bridge.createHome(params).then((res)=>{
prompt.showToast({
message: res,
duration: 200,
})
}).catch((err)=>{
prompt.showToast({
message: '接口调用失败',
duration: 200,
})
})
},
/**
* @description: 更新家庭信息
* @param {*}
* @return {*}
*/
updateHomeInfo(){
const params = {
homeId: "12",
name: "家庭名称",
des: "描述",
address: "地址",
coordinate: "位置",
areaid: "xxx",
adCode: ""
}
this.$app.$def.bridge.updateHomeInfo(params).then((res)=>{
prompt.showToast({
message: res,
duration: 200,
})
}).catch((err)=>{
prompt.showToast({
message: '接口调用失败',
duration: 200,
})
})
},
/**
* @description:删除家庭
* @param {*}
* @return {*}
*/
deleteHome(){
const params = {
homeId:'1'
}
this.$app.$def.bridge.deleteHome(params).then((res)=>{
prompt.showToast({
message: res,
duration: 200,
})
}).catch((err)=>{
prompt.showToast({
message: '接口调用失败',
duration: 200,
})
})
},
/**
* @description:获取家庭成员列表
* @param {*}
* @return {*}
*/
getHomeMemberList(){
const params = {
homeId:'234354'
}
this.$app.$def.bridge.getHomeMemberList(params).then((res)=>{
prompt.showToast({
message: res,
duration: 200,
})
}).catch((err)=>{
prompt.showToast({
message: '接口调用失败',
duration: 200,
})
})
},
/**
* @description:获取家庭成员列表
* @param {*}
* @return {*}
*/
inviteToHome(){
const params = {
homeId:'234354',
loginAccount:'tt',
stamp:''
}
this.$app.$def.bridge.inviteToHome(params).then((res)=>{
prompt.showToast({
message: res,
duration: 200,
})
}).catch((err)=>{
prompt.showToast({
message: '接口调用失败',
duration: 200,
})
})
},
testBridge(name){
switch(name){
case 'getHomeInfo':
this.getHomeInfo()
break;
case 'getAllHomeInfoList':
this.getAllHomeInfoList()
break;
case 'createHome':
this.createHome()
break;
case 'updateHomeInfo':
this.updateHomeInfo()
break;
case 'deleteHome':
this.deleteHome()
break;
case 'getHomeMemberList':
this.getHomeMemberList()
break;
case 'inviteToHome':
this.inviteToHome()
break;
default:
break;
}
}
}