Browse Source

完成:设备主页改版&&设备定时列表查看及操作

voice
zmt 4 years ago
parent
commit
649c472948
  1. 9
      src/pages.json
  2. 29
      src/subpackage/device/components/store_name/store_name.vue
  3. 4
      src/subpackage/device/js/device_api.js
  4. 67
      src/subpackage/device/js/ouxuanac.md
  5. 2
      src/subpackage/device/pages/audio_manage/audio_manage.vue
  6. 129
      src/subpackage/device/pages/index/index.vue
  7. 336
      src/subpackage/device/pages/index/timing_list.vue
  8. BIN
      src/subpackage/device/static/images/arrow_b2_light.png
  9. BIN
      src/subpackage/device/static/images/arrow_back.png
  10. BIN
      src/subpackage/device/static/images/icon_clock.png
  11. BIN
      src/subpackage/device/static/images/index_bg.png

9
src/pages.json

@ -216,7 +216,14 @@
{
"path": "pages/index/index",
"style" : {
"navigationBarTitleText": "欧轩智能商家助手"
"navigationBarTitleText": "欧轩智能商家助手",
"navigationStyle":"custom"
}
},
{
"path": "pages/index/timing_list",
"style" : {
"navigationBarTitleText": "定时列表"
}
},
{

29
src/subpackage/device/components/store_name/store_name.vue

@ -1,9 +1,9 @@
<template>
<picker class="store-name-picker" :range="storeList" range-key="name" @change="storeChange">
<view class="store-name">
<view class="store-name" :style="{background:getThemeBg()}">
<image class="sn-logo" mode="aspectFit" :src="curStoreInfo.logo || ''"></image>
<view class="sn-txt">{{curStoreInfo.name || '-'}}</view>
<image class="sn-arrow" mode="aspectFit" src="../../static/images/arrow_b2.png"></image>
<view class="sn-txt" :style="{color:getThemeColor()}">{{curStoreInfo.name || '-'}}</view>
<image class="sn-arrow" mode="aspectFit" :src="getThemeIcon()"></image>
</view>
</picker>
</template>
@ -15,7 +15,20 @@ export default {
...mapState({
storeList: state => state.device.storeList,
curStoreInfo: state => state.device.curStoreInfo,
})
}),
getThemeIcon(){
return ()=> {return (this.theme=='light')?'../../static/images/arrow_b2_light.png':'../../static/images/arrow_b2.png';}
},
getThemeColor(){
return ()=> {return (this.theme=='light')?'#FFFFFF':'#1a1a1a';}
},
getThemeBg(){
return ()=> {return (this.theme=='light')?'none':'#FFFFFF';}
},
},
props: ["theme"],//, "light":
created() {
console.log("store_name theme: ", this.theme);
},
methods: {
storeChange(e){
@ -31,14 +44,16 @@ export default {
<style>
.store-name-picker{
width: 100%;
z-index: 5;
}
.store-name{
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
justify-content: flex-start;
padding: 0 40upx;
height: 108upx;
background-color: #fff;
/* background-color: #fff; */
}
.sn-logo{
flex-grow: 0;
@ -48,7 +63,7 @@ export default {
height: 52upx;
}
.sn-txt{
flex-grow: 1;
/* flex-grow: 1; */
line-height: 40upx;
font-size: 28upx;
color: #1a1a1a;

4
src/subpackage/device/js/device_api.js

@ -45,6 +45,10 @@ export const DEVICE_API = {
//2021/0705 音响
uploadAudio:`${ORIGIN}/upload/file/audio`, // 上传录音
sendAudio:`${ORIGIN}/ouxuanac/sendPacket`, // 发送上传录音并播放
//2021/0713
acUpdate:`${ORIGIN}/ouxuanac/getDescribeDevice`, //中控在线状态查询
delInfoAC:`${ORIGIN}/ouxuanac/getDescribeDevice`, //删除状态
}
export default DEVICE_API;

67
src/subpackage/device/js/ouxuanac.md

@ -278,3 +278,70 @@ function GatePacket(tcp: string, cid: string,) {
}
```
> 2021-07 新增
### 通知中控播放音响 sendPacket
```
https://testmanager.ouxuanzhineng.cn/ouxuanac/sendPacket
//请求参数
{
"device": "设备名",
"data": {
"name": "audio-player",
"value": {
"url": "语音url"
}
},
"token": "f0d5c19b-b87e-11eb-bc7d-5254005df464"
}
//例子
{
"device": "00-10-7a-0f-6d-7a",
"data": {
"name": "audio-player",
"value": {
"url": "https://test.ouxuanzhineng.cn/ouxuanac/tts/textToVoice.wav?text=试试看&voice_type=4&speed=-1&volume=10"
}
},
"token": "f0d5c19b-b87e-11eb-bc7d-5254005df464"
}
```
### 文字转语音 textToVoice
```
https://test.ouxuanzhineng.cn/ouxuanac/tts/textToVoice.wav?text=试试看&voice_type=4&speed=-1&volume=10
```
### 查询中控在线状态 getDescribeDevice
```
示例:
https://testmanager.ouxuanzhineng.cn/ouxuanac/deviceQuery?id=00-de-47-e9-3a-fc
返回:
{"code":0,"data":{"DeviceName":"00-de-47-e9-3a-fc","Online":1,"LoginTime":1626126211,"LastUpdateTime":1624102433,"Tags":[{"Tag":"category","Type":2,"Value":"placeholder","Name":""},{"Tag":"note","Type":2,"Value":"锐那东方渔人码头店","Name":""}],"DeviceType":5,"ConnIP":1231216393,"FirstOnlineTime":1602899627,"LastOfflineTime":1626126208,"LastOfflineTimeStr":"2021-07-13 05:43:28","CreateTime":1602899594,"EnableState":1,"ClientIP":"36.113.100.107","RequestId":"fc49e900-2b4c-403b-bf00-d929725d2276"},"message":""}
```
### 更新定时列表 sendPacket
```
请求参数
let _data = {
"device": this.curStoreInfo.device_name,
"data": {
"name": "audio-player",
"value": {
"url": _url
}
},
// "token": "f0d5c19b-b87e-11eb-bc7d-5254005df464"
}
返回:
{"code":0,"data":[{"date_slice":[{"end":"","start":""}],"day_of_month":null,"day_of_week":[0,1,2,3,5,4,6],"expand_tags":null,"expand_value":{"main":{"name":"set-rpio","title":"测试中控照明8","value":{"id":"8","status":"low"}}},"extension":null,"group":"RPIO","time_arrow_id":"7d56981c-8dd4-11eb-9aad-4e965989bbce","times_on_day":["10:12:00-10:12:10"],"type":"DAY_OF_WEEK","weights":0},{"date_slice":[{"end":"","start":""}],"day_of_month":null,"day_of_week":[0,1,2,3,6,5,4],"expand_tags":null,"expand_value":{"main":{"name":"set-rpio","title":"测试中控照明9","value":{"id":"9","status":"low"}}},"extension":null,"group":"RPIO","time_arrow_id":"862813af-8dd4-11eb-9aad-4e965989bbce","times_on_day":["10:12:00-10:12:10"],"type":"DAY_OF_WEEK","weights":0},{"date_slice":[{"end":"","start":""}],"day_of_month":null,"day_of_week":[0,4,1,5,2,6,3],"expand_tags":null,"expand_value":{"main":{"name":"set-rpio","title":"测试中控照明10","value":{"id":"10","status":"low"}}},"extension":null,"group":"RPIO","time_arrow_id":"8def57e1-8dd4-11eb-9aad-4e965989bbce","times_on_day":["10:12:00-10:12:10"],"type":"DAY_OF_WEEK","weights":0},{"date_slice":[{"end":"","start":""}],"day_of_month":null,"day_of_week":[0,1,2,3,6,5,4],"expand_tags":null,"expand_value":{"main":{"name":"set-rpio","title":"测试中控照明8","value":{"id":"8","status":"high"}}},"extension":null,"group":"RPIO","time_arrow_id":"be5eb915-8dd4-11eb-9aad-4e965989bbce","times_on_day":["10:13:00-10:13:10"],"type":"DAY_OF_WEEK","weights":0},{"date_slice":[{"end":"","start":""}],"day_of_month":null,"day_of_week":[0,1,2,3,6,5,4],"expand_tags":null,"expand_value":{"main":{"name":"set-rpio","title":"测试中控照明9","value":{"id":"9","status":"high"}}},"extension":null,"group":"RPIO","time_arrow_id":"c8c39f5c-8dd4-11eb-9aad-4e965989bbce","times_on_day":["10:13:00-10:13:10"],"type":"DAY_OF_WEEK","weights":0}],"message":""}
```

2
src/subpackage/device/pages/audio_manage/audio_manage.vue

@ -291,7 +291,7 @@
}
},
fail: (e) => {
console.log('文字转录音文件下载失败',res);
console.log('文字转录音文件下载失败',e);
util.hideLoad()
rj(e)
},

129
src/subpackage/device/pages/index/index.vue

@ -1,6 +1,23 @@
<template>
<view class="index-container">
<store-name></store-name>
<view class="ic-top-box">
<image class="custom-back" @click="goBack()" src="../../static/images/arrow_back.png" :style="{top:getTop(18) + 'px'}" mode=""></image>
<view class="brand-name" :style="{marginTop:getTop(30) + 'px'}">{{curStoreInfo.brand_name}}</view>
<store-name :theme="'light'"></store-name>
<view class="device-info">
<text class="device-name">欧轩智能中控</text>
<text>设备id: {{curStoreInfo.device_name||"-"}}</text>
<text>最后上线时间{{deviceInfo.LastOfflineTimeStr||"-"}}</text>
<view class="">
<view class="">状态{{deviceInfo.Online==1?'在线':'离线'}}</view>
<view class="" @click="goTimingList">
<image src="../../static/images/icon_clock.png" mode=""></image>
定时列表</view>
</view>
</view>
</view>
<view class="ic-section">
<view class="is-list">
<view class="il-item" v-for="(e,i) in tabArr" :key="i" @click="routeTo(e)">
@ -36,13 +53,32 @@ const tabArr = [
{id: 14, name: '音响', path: `/pages/audio_manage/audio_manage`},
{id: 15, name: '机器人', path: ``},
];
import { mapState } from 'vuex'
export default {
components: {
'store-name': store_name
},
computed: {
...mapState({
storeList: state => state.device.storeList,
curStoreInfo: state => state.device.curStoreInfo,
}),
getTop(){
return (lineHeight)=>{
// #ifdef MP-WEIXIN
let wxBtn = wx.getMenuButtonBoundingClientRect()
// #endif
let txt_line_height = lineHeight //brand_name lineHeight
let top = (wxBtn?wxBtn.top:30 ) + (wxBtn.height-txt_line_height )/2
return top
}
},
},
data(){
return {
tabArr,
deviceInfo:""
}
},
async onLoad(){
@ -50,13 +86,41 @@ export default {
util.showLoad();
let _brandInfo = await this.$store.dispatch('getBrandInfo');
await this.$store.dispatch('getStoreList');
this.updateAC();
util.hideLoad();
}catch(err){
util.hideLoad();
}
},
onShow() {
this.updateAC()//
},
methods: {
updateAC(){
if(!this.curStoreInfo.device_name)return
util.showLoad();
// id:"00-de-47-e9-3a-fc"
deviceServer.get({
url: deviceApi.acUpdate,
data: {id:this.curStoreInfo.device_name},
failMsg: '加载失败!'
})
.then(res=>{
util.hideLoad()
this.deviceInfo = res
})
.catch(util.hideLoad)
},
goBack(){
uni.navigateBack({
delta:1
})
},
goTimingList(){
let timing_list = "/subpackage/device/pages/index/timing_list"
util.routeTo(`${timing_list}`, 'nT');
},
getImgPath(id){
if(!id)return '';
return `/subpackage/device/static/images/devices/${id || 14}.png`
@ -85,8 +149,71 @@ export default {
<style lang="scss">
@import '~style/public.scss';
.ic-top-box{
position: fixed;
top: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
background-color: lightgray;
background-image:url(../../static/images/index_bg.png);
background-size: 100% 100%;
width: 100%;
height: 560rpx;
.custom-back{
width: 18px;
height: 18px;
padding:0 20rpx;
position: fixed;
left: 10rpx;
}
.brand-name{
line-height: 30px;
font-size: 32rpx;
text-align: center;
color: white;
}
store-name{
align-self: flex-start;
}
.device-info{
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
> text:first-child{
font-weight: 900;
margin-top: 20rpx;
}
> text:nth-child(2){
margin-top: 30rpx;
color: #FFFFFF;font-size: 24rpx;
}
> text:nth-child(3){
margin-top: 20rpx;
font-size: 24rpx;
}
> view:last-child{
margin-top: 55rpx;
width: 100%;font-size: 28rpx;
@include centerFlex(space-between);
> view{
@include centerFlex(center);
image{
width: 30rpx;
height: 30rpx;
margin-right: 10rpx;
}
}
}
}
}
.ic-section{
padding: 60upx 30upx 0;
margin-top: 560rpx;//.ic-top-box
.is-list{
display: flex;
flex-wrap: wrap;

336
src/subpackage/device/pages/index/timing_list.vue

@ -0,0 +1,336 @@
<template>
<view class="timing-page">
<store-name></store-name>
<view class="t-title">定时列表</view>
<view class="t-box">
<view class="tab-list">
<view class="t-item " :class="e.on?'active':''" v-for="(e,i) in tabArr" @click="clickTab(i)">
{{e.name}}
</view>
</view>
<view class="info-list">
<view class="i-item" v-for="(item,index) in infoArr">
<view class="i-box">{{item[0]}}</view>
<rich-text class="i-box" :nodes="item[1]"></rich-text>
<!-- {{item[1]}} -->
<view class="i-box" v-if="isDel(item)" @click="delItem(item,index)" style="color: red;">{{item[2]}}</view>
<view class="i-box" v-else>{{item[2]}}</view>
</view>
</view>
</view>
</view>
</template>
<script>
import util from '../../../../utils/util';
import store_name from '../../components/store_name/store_name';
import deviceServer from '../../js/device_server';
import deviceApi from '../../js/device_api';
const rootPage = '/subpackage/device'
const tabArr = [{
id: 0,
name: '全部',
path: ``,
on: true
},
// {
// id: 1,
// name: '',
// path: ``,
// on: false
// },
// {
// id: 2,
// name: '',
// path: ``,
// on: false
// },
// {
// id: 3,
// name: '',
// path: ``,
// on: false
// },
];
const infoArr = [
["标题", "时间", "操作"],
// ["2", " 6:00 ", ""],
];
import {
mapState
} from 'vuex'
export default {
components: {
'store-name': store_name
},
computed: {
...mapState({
storeList: state => state.device.storeList,
curStoreInfo: state => state.device.curStoreInfo,
}),
isDel() {
return (item) => {
return item[2] == "删除" ? "true" : ""
}
}
},
data() {
return {
tabArr,
infoArr,
}
},
async onLoad(opts) {
try {
util.showLoad();
let _brandInfo = await this.$store.dispatch('getBrandInfo');
await this.$store.dispatch('getStoreList');
util.hideLoad();
} catch (err) {
util.hideLoad();
}
},
onShow() {
this.updateList() //
},
watch: {
curStoreInfo(newVal, oldVal){
this.infoArr.length = 1
this.updateList()
}
},
methods: {
clickTab(i) {
this.tabArr.forEach((item) => {
item.on = false
})
this.tabArr[i].on = true
},
//
delItem(e,i) {
let that = this
let delData = {
"device": this.curStoreInfo.device_name,
"delay": 1,
"data": {
"name": "delete-time-select",
"value": {
"uuid": e[3]
}
}
}
uni.showModal({
content: `确认要删除: ${e[0]}的计划任务 ?`,
success(res) {
console.log("确认删除", res.confirm)
if(res.confirm){
that.operateReq({
data: delData,
succFun: (res) => {
that.updateList()
},
isTip:true
})
}
},
})
},
async updateList() {
let that = this
let timingData = {
"device": this.curStoreInfo.device_name,
"data": {
"name": "get-time-select",
"value": {}
}
}
this.operateReq({
data: timingData,
succFun: (list) => {
that.infoArr.length = 1;
list.forEach(async (item,i)=> {
if(item.day_of_week)item.day_of_week = item.day_of_week.sort((a,b)=>a-b);//
let timetxt = await that.getTimeTxt(item);
that.infoArr.push([item.expand_value.main.title||"-",timetxt||"-","删除",item.time_arrow_id])
})
}
})
},
//,
getTimeTxt(row) {
return new Promise((rs,rj)=>{
let timeText = ""
if (!row.expand_value) {
rj('error')
}
if (row.type === 'DAY_OF_WEEK' && row.day_of_week) {
let arr = []
for (let i = 0; i < row.day_of_week.length; i++) {
arr += ' 周' + ['日', '一', '二', '三', '四', '五', '六'][row.day_of_week[i]];
}
timeText = `每个星期的 <strong>[${arr} ]</strong> `
}
if (row.type === 'DAY_OF_MONTH' && row.day_of_month) {
let arr = []
for (let i = 0; i < row.day_of_month.length; i++) {
arr += row.day_of_month[i] + '号 ';
}
timeText = `每个月的 <strong>[ ${arr} ]</strong> `
}
if (row.type === 'DATE_SLICE' && row.date_slice) {
timeText = ` ${row.date_slice[0].start.substring(0, 10)}~${row.date_slice[0].end.substring(0, 10)}`
}
if (row.times_on_day && row.times_on_day.length) {
timeText += ` 当天<strong>${row.times_on_day[0].substring(0, 5)}</strong>`
}
if (!row.expand_value.main) return '历史错误数据';
rs(` ${timeText} 执行 ${row.expand_value.main.value.status === 'high' ? '<strong style="color:gray;">[关闭]</strong>' : '<strong style="color:#009874;">[开启]</strong>'} 操作`)
})
},
goBack() {
uni.navigateBack({
delta: 1
})
},
goTimingList() {
let timing_list = "/subpackage/device/pages/index/timing_list"
util.routeTo(`${timing_list}`, 'nT');
},
//
operateReq({
data,
succFun,
isTip = false,
isLoad = true,
}) {
let that = this
if (isLoad) util.showLoad();
deviceServer.post({
url: deviceApi.ouxuanac,
data: data,
isDefaultGet: false,
})
.then(res => {
if (isLoad) util.hideLoad();
if (res.data.code == 0) {
if (isTip) util.showNone(res.data.message || '操作成功!');
succFun(res.data.data)
} else {
if (isTip) util.showNone(res.data.message || '操作失败!');
}
})
.catch(err => {
if (isLoad) util.hideLoad()
})
},
}
}
</script>
<style lang="scss">
@import '~style/public.scss';
.timing-page {
.t-title {
font-size: 44rpx;
color: #1A1A1A;
font-weight: 900;
margin: 60rpx auto 72rpx 40rpx;
}
.t-box {
height: 500rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
width: 100%;
.tab-list {
width: 100%;
padding-left: 30rpx;
@include centerFlex(flex-start);
flex-wrap: nowrap;
position: relative;
.t-item {
margin-right: 50rpx;
padding: 10rpx;
font-size: 32rpx;
font-weight: 900;
color: #9C9C9F;
line-height: 40rpx;
}
.active {
color: #009874;
@include centerFlex(center);
flex-direction: column;
}
.active:after {
position: absolute;
content: "";
background-color: #009874;
color: #009874;
width: auto;
display: block;
width: 30rpx;
text-align: center;
height: 6rpx;
border-radius: 3rpx;
top: 60rpx;
}
}
.info-list {
margin-top: 30rpx;
margin-bottom: 50rpx;
width: 700rpx;
height: auto;
background: #FFFFFF;
border-radius: 10rpx;
font-size: 28rpx;
.i-item {
@include centerFlex(space-between);
.i-box {
@include centerFlex(center);
flex-direction: row;
padding: 26rpx 10rpx;
height: 100%;
}
.i-box:first-child {
width: 176rpx;
}
.i-box:nth-child(2) {
width: 100%;
border: 1rpx solid #F2F2F7;
border-bottom: none;
border-top: none;
}
.i-box:last-child {
width: 114rpx;
}
}
.i-item:not(:last-child) {
border-bottom: 1rpx solid #F2F2F7;
}
}
}
}
</style>

BIN
src/subpackage/device/static/images/arrow_b2_light.png

After

Width: 14  |  Height: 14  |  Size: 311 B

BIN
src/subpackage/device/static/images/arrow_back.png

After

Width: 20  |  Height: 20  |  Size: 395 B

BIN
src/subpackage/device/static/images/icon_clock.png

After

Width: 14  |  Height: 14  |  Size: 512 B

BIN
src/subpackage/device/static/images/index_bg.png

After

Width: 187  |  Height: 155  |  Size: 16 KiB

Loading…
Cancel
Save