Browse Source

coffee && rentbox

voice
刘嘉炜 4 years ago
parent
commit
71496f5c0f
  1. 10
      src/subpackage/device/js/device_api.js
  2. 2
      src/subpackage/device/pages/coffee_manage/coffee_manage.vue
  3. 122
      src/subpackage/device/pages/coffee_test/coffee_test.vue
  4. 12
      src/subpackage/device/pages/device_manage/device_manage.vue
  5. 2
      src/subpackage/device/pages/index/index.vue
  6. 113
      src/subpackage/device/pages/locker_manage/locker_manage.vue
  7. 88
      src/subpackage/device/pages/switch_manage/switch_manage.vue

10
src/subpackage/device/js/device_api.js

@ -10,9 +10,17 @@ export const DEVICE_API = {
hardwareSave:`${ORIGIN}/admin/stadium/hardware/save`, // 设备开启/关闭
drinkList:`${ORIGIN}/admin/stadium/coffee/drink/list`, // 咖啡机口味列表
drinkRestock:`${ORIGIN}/admin/stadium/coffee/drink/restock`, // 咖啡机口味列表
drinkRestock:`${ORIGIN}/admin/stadium/coffee/drink/restock`, // 咖啡机口味补货
leaseList:`${ORIGIN}/admin/stadium/lease/cabinet/list`, // 租售柜列表
lockerList:`${ORIGIN}/admin/stadium/locker/cabinet/list`, // 储物柜列表
hardwareInfo:`${ORIGIN}/admin/stadium/hardware/get/`, // 设备信息
hardwareList:`${ORIGIN}/admin/stadium/hardware/list`, // 设备列表
ouxuanac:`${ORIGIN}/ouxuanac/sendPacket`, // 中控控制
// ouxuanac--> http://api.ouxuan.net/project/233/interface/api/10012 接口文档

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

@ -53,7 +53,7 @@ export default {
confirmSave: util.debounce(function(){
let { typeList, isFillAll } = this;
util.showModal({
title: '是否确认补?',
title: '是否确认补?',
content: isFillAll?'请确认全部补满':'',
showCancel: true,
success: res=>{

122
src/subpackage/device/pages/coffee_test/coffee_test.vue

@ -1,29 +1,131 @@
<template>
<view class="coffee-test">
<device-name></device-name>
<device-name :name="optionsQuery.name"></device-name>
<view class="ct-tit">测试设备</view>
<view class="ct-tip">您可选择饮品出水口测试饮品出水口是否正常</view>
<view class="ct-tip">热饮请留意避免烫伤</view>
<view class="ct-list">
<view class="cl-item" v-for="i in 4" :key="i">
<image mode="aspectFit" class="ci-close active" src="/subpackage/device/static/images/selected_987.png" ></image>
<image class="ci-img"></image>
<view>咖啡</view>
<view class="cl-item" v-for="(e, i) in typeList" :key="i" @click="curTestInfo = e">
<image
mode="aspectFit"
:class="['ci-close', curTestInfo.id == e.id?'active' : '']"
:src="curTestInfo.id == e.id?'/subpackage/device/static/images/selected_987.png':''"
></image>
<image class="ci-img" mode="aspectFit" :src="e.image || ''"></image>
<view>{{e.name || '-'}}</view>
</view>
</view>
<view class="ct-btns">
<view class="active"></view>
<view>常温</view>
<view class="ct-btns" v-if="typeList.length">
<view :class="[temperatureType == 'hot'?'active': '']" @click="temperatureType = 'hot'"></view>
<view :class="[temperatureType == 'cold'?'active': '']" @click="temperatureType = 'cold'">常温</view>
</view>
<view class="ct-fixed-btn" hover-class="hover-active">确定</view>
<view class="ct-fixed-btn" hover-class="hover-active" @click="confirmTest">确定</view>
</view>
</template>
<script>
import util from '../../../../utils/util';
import device_name from '../../components/device_name/device_name';
import deviceServer from '../../js/device_server';
import deviceApi from '../../js/device_api';
import { mapState } from 'vuex';
export default {
components: {
'device-name': device_name
},
computed: {
...mapState({
curStoreInfo: state => state.device.curStoreInfo,
})
},
data(){
return {
curTestInfo: {},
optionsQuery: {},
typeList: [],
temperatureType: 'cold',
}
},
onLoad(options){
let _query = util.jsonPar(options.query);
this.optionsQuery = _query;
console.log(_query);
this.coffeeList(_query.id);
},
methods: {
coffeeList(hardware_id){
deviceServer.get({
url: deviceApi.drinkList,
data: {
'filter[stadium_hardware_id]': hardware_id
},
failMsg: '加载失败!'
})
.then(res=>{
let _list = res.list || [];
this.typeList = _list
if(_list.length >0)this.curTestInfo = _list[0];
console.log(res);
})
},
confirmTest(){
let { curTestInfo, temperatureType, optionsQuery, curStoreInfo } = this;
util.showModal({
title: '确认测试?',
content : '热饮请留意避免烫伤!',
showCancel: true,
success: res=>{
if(res.confirm)this.testReq();
}
})
},
async testReq(){
try{
let { curTestInfo, temperatureType, curStoreInfo } = this;
util.showLoad();
let deviceInfo = await deviceServer.get({
url: deviceApi.hardwareInfo + curTestInfo.stadium_hardware_id,
data: {},
failMsg: '获取设备信息失败!'
})
if(!deviceInfo)return console.warn('获取设备信息失败!deviceInfo--->',deviceInfo);
if(
deviceInfo.hardware_connect_method !=='Tcp' ||
deviceInfo.hardware_model !=='MIAOQUE'
){
let _errorStr = `connect error: connect method ${deviceInfo.hardware_connect_method}, model: ${deviceInfo.hardware_model}`
console.warn(_errorStr);
return util.showNone(_errorStr);
}
deviceServer.post({
url: deviceApi.ouxuanac,
data: {
device: curStoreInfo.device_name, // ,
data: {
"name": "coffeebox-tcp",
"value": {
"id": deviceInfo.hardware_id + '',
"tcp": deviceInfo.hardware_net_addr + '',
"t": temperatureType + '',
}
}, // src\subpackage\device\js\ouxuanac.md
},
isDefaultGet: false,
})
.then(res=>{
util.hideLoad();
if(res.data.code == 0){
util.showNone(res.data.message || '操作成功!');
}else{
util.showNone(res.data.message || '操作失败!');
}
util.hideLoad();
})
}catch(err){
util.hideLoad();
console.warn('操作失败!',err)
}
}
}
}
</script>
@ -73,7 +175,6 @@ export default {
border-radius: 50%;
border: 2upx solid #ddd;
&.active{
border-width: 0;
border-color: transparent;
}
}
@ -82,7 +183,6 @@ export default {
display: block;
width: 160upx;
height: 160upx;
background-color: skyblue;
}
>view{
padding: 0 20upx;

12
src/subpackage/device/pages/device_manage/device_manage.vue

@ -67,6 +67,7 @@ const dmObj = {
stockBtnName: '查看',
deviceBtnOpenName: '开启售货',
deviceBtnStopName: '停止售货',
deviceType: 'AssortedLease', //
},
'd9': {
id: 9,
@ -78,6 +79,7 @@ const dmObj = {
stockBtnName: '查看',
deviceBtnOpenName: '开启租用',
deviceBtnStopName: '停止租用',
deviceType: 'AssortedLocker', //
},
'd10': {
id: 10,
@ -163,10 +165,11 @@ export default {
let { pageInfo } = this;
let _query = {
id: e.id,
name: e.hardware_type_name
name: e.hardware_name,
page_id: pageInfo.id
}
if(pageInfo.id == 7)return util.routeTo(`/subpackage/device/pages/sell_box_manage/sell_box_manage?query=${util.jsonStr(_query)}`, 'nT');
if(pageInfo.id == 8)return util.routeTo(`/subpackage/device/pages/locker_manage/locker_manage?type=8`, 'nT');
if(pageInfo.id == 8)return util.routeTo(`/subpackage/device/pages/locker_manage/locker_manage?query=${util.jsonStr(_query)}`, 'nT');
// if(pageInfo.id == 9)return util.routeTo(`/subpackage/device/pages/locker_manage/locker_manage`, 'nT');
if(pageInfo.id == 10)return util.routeTo(`/subpackage/device/pages/coffee_manage/coffee_manage?query=${util.jsonStr(_query)}`, 'nT');
},
@ -174,11 +177,12 @@ export default {
let { pageInfo } = this;
let _query = {
id: e.id,
name: e.hardware_type_name
name: e.hardware_name,
page_id: pageInfo.id
}
if(pageInfo.id == 7)return util.routeTo(`/subpackage/device/pages/sell_box_test/sell_box_test?query=${util.jsonStr(_query)}`, 'nT');
// if(pageInfo.id == 8)return util.routeTo(`/subpackage/device/pages/locker_manage/locker_manage`, 'nT');
if(pageInfo.id == 9)return util.routeTo(`/subpackage/device/pages/locker_manage/locker_manage?type=9`, 'nT');
if(pageInfo.id == 9)return util.routeTo(`/subpackage/device/pages/locker_manage/locker_manage?query=${util.jsonStr(_query)}`, 'nT');
if(pageInfo.id == 10)return util.routeTo(`/subpackage/device/pages/coffee_test/coffee_test?query=${util.jsonStr(_query)}`, 'nT');
}
}

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

@ -69,6 +69,8 @@ export default {
e.id == 3 || //
e.id == 4 || //
e.id == 5 ||  //
e.id == 8 ||  //
e.id == 9 ||  //
e.id == 10 ||  //
e.id == 11 ||  //
e.id == 7   //

113
src/subpackage/device/pages/locker_manage/locker_manage.vue

@ -1,31 +1,45 @@
<template>
<view class="locer-manage">
<device-name></device-name>
<device-name :name="optionsQuery.name"></device-name>
<view class="lm-list">
<view class="ll-item" v-for="i in 10" :key="i">
<view class="ll-item" v-for="(e,i) in boxList" :key="i" @click="itemClick(i)">
<view class="li-left">
<view class="ll-box">2</view>
<view class="ll-tag" :class="[i==1?'grey':i==2?'orange':'']">已租</view>
<view class="ll-box">{{e.id || '-'}}</view>
<view
v-if="getleaseBoxType(e)"
class="ll-tag"
:class="[e.usage_status==0?'grey':e.usage_status==1&&!isRent(e)?'orange':'']"
>{{getleaseBoxType(e)}}</view>
</view>
<view class="li-content">
<view>
<view class="lc-name">球拍+</view>
<view class="lc-name">{{isRent(e)?e.cabinet_name || '-':e.goods_name || '-'}}</view>
<view class="lc-price">
<view>20<text>/小时</text></view>
<view>押金100</view>
<view>{{e.price || '0'}}<text>{{e.unit || '-'}}</text></view>
<view v-if="optionsQuery.page_id == 8&&isRent(e)">押金{{e.deposit || '0'}}</view>
</view>
</view>
<image class="active" mode="aspectFit" src="/subpackage/device/static/images/selected_987.png"></image>
<image
v-if="e._isSelected"
class="active"
mode="aspectFit"
src="/subpackage/device/static/images/selected_987.png">
</image>
<image v-else></image>
</view>
</view>
</view>
<view class="lm-tip">{{getTip}}</view>
<view class="lm-fixed-bar">
</view>
<view class="lm-fixed-bar">
<view class="lfb-select-all">
<image class="active" mode="aspectFit" src="/subpackage/device/static/images/selected_987.png"></image>
<view class="lfb-select-all" @click="selectAll">
<image v-if="isSelectedAll" class="active" mode="aspectFit" src="/subpackage/device/static/images/selected_987.png"></image>
<image v-else></image>
<text>全选</text>
</view>
<view class="lfb-confirm" hover-class="hover-active" @click="openLocker">打开柜子</view>
@ -36,31 +50,87 @@
<script>
import util from '../../../../utils/util';
import device_name from '../../components/device_name/device_name';
import deviceServer from '../../js/device_server';
import deviceApi from '../../js/device_api';
// e.page_id == 8 ||  //
// e.page_id == 9 ||  //
export default {
components: {
'device-name': device_name
},
computed: {
getTip(){
let { type } = this;
if(type == 8)return 'Tips:如需更换货物、设置价格请前往PC端商家后台设置';
if(type == 9)return 'Tips:如需设置柜子信息、设置价格请前往PC端商家后台设置';
let { optionsQuery } = this;
if(optionsQuery.page_id == 8)return 'Tips:如需更换货物、设置价格请前往PC端商家后台设置';
if(optionsQuery.page_id == 9)return 'Tips:如需设置柜子信息、设置价格请前往PC端商家后台设置';
return
},
isSelectedAll(){
let { boxList } = this;
let _is = true;
boxList.forEach(el=>{
if(!el._isSelected)_is = false;
})
return _is
}
},
data(){
return{
optionsQuery: {},
boxList: [],
}
},
onLoad(options){
this.type = options.type;
console.log(options)
let _query = util.jsonPar(options.query);
this.optionsQuery = _query;
console.log(_query);
this.getBoxList();
},
methods: {
selectAll(){
let { isSelectedAll } = this;
let _boxList = this.boxList.slice();
this.boxList = _boxList.map(el=>{
el._isSelected = !isSelectedAll;
return el;
});
},
itemClick(index){
let _boxList = this.boxList.slice();
_boxList[index]._isSelected = !_boxList[index]._isSelected;
this.boxList = _boxList;
},
isRent(info){
if(!info)return false;
return info.cabinet_type === 'rent'
},
getleaseBoxType(info){
let _rentArr = ['未租', '已租'];
let _sellArr = ['未卖', '已卖'];
if(!info)return '';
if(info.cabinet_type == 'rent')return _rentArr[info. usage_status] || '';
if(info.cabinet_type == 'sell')return _sellArr[info. usage_status] || '';
},
getBoxList(){
deviceServer.get({
url: this.getListApi(),
data: {},
failMsg: '加载失败!'
})
.then(res=>{
let _list = res.list || [];
this.boxList = _list;
console.log(res);
})
},
getListApi(){
let { optionsQuery } = this;
if(optionsQuery.page_id == 8)return deviceApi.leaseList;
if(optionsQuery.page_id == 9)return deviceApi.lockerList;
},
openLocker(){
let { type } = this;
if(type == 8)return util.showModal({
let { optionsQuery } = this;
if(optionsQuery.page_id == 9)return util.showModal({
title: '提示',
content: '是否补货',
showCancel: true,
@ -171,7 +241,6 @@ export default {
border: 2upx solid #dddddd;
align-self: center;
&.active{
border-width: 0;
border-color: transparent;
}
}
@ -244,7 +313,7 @@ export default {
border: 2upx solid #d8d8d8;
border-radius: 50%;
&.active{
border-width: 0;
border-color: transparent;
}
}
}

88
src/subpackage/device/pages/switch_manage/switch_manage.vue

@ -19,11 +19,11 @@
</view>
</view>
<view class="si-bottom" v-if="pageInfo.isOpen || pageInfo.isClose">
<view v-if="pageInfo.isOpen" @click="operateBtn({ info: e, status: 1 })">
<view v-if="pageInfo.isOpen" @click="operateBtn({ switchInfo: e, status: 1 })">
<image mode="aspectFit" :src="pageInfo.openIcon || ''"></image>
<view>{{pageInfo.openName || '-'}}</view>
</view>
<view v-if="pageInfo.isClose" @click="operateBtn({ info: e, status: 0 })">
<view v-if="pageInfo.isClose" @click="operateBtn({ switchInfo: e, status: 0 })">
<image mode="aspectFit" :src="pageInfo.closeIcon || ''"></image>
<view>{{pageInfo.closeName || '-'}}</view>
</view>
@ -155,28 +155,53 @@ export default {
},
// status 0 -> 1 ->
operateBtn: util.debounce(function({ info, status }){
let { curStoreInfo, pageInfo } = this;
let _query = curStoreInfo.hardware_type === 'GateControl' ?
this.getGateQuery({switchInfo: info, status}) :
this.getSwitchQuery({ switchInfo: info, status });
operateBtn: util.debounce(function({ switchInfo, status }){
util.showLoad();
deviceServer.post({
url: deviceApi.ouxuanac,
data: {
let _data = this.getOperateReqData({ switchInfo, status })
//->& 20201224 5
if(switchInfo.hardware_type === 'AccessControl'&&status == 1){
this.operateReq({data: this.getOperateReqData({ switchInfo, status: 0 }), isTip: false, isLoad: false});
}
this.operateReq({ data: _data });
}, 300, 300),
//
getOperateReqData({ switchInfo, status }){
let { curStoreInfo } = this;
let _query = switchInfo.hardware_type === 'GateControl' ?
this.getGateQuery({ switchInfo, status}) :
this.getSwitchQuery({ switchInfo, status });
let _data = {
device: curStoreInfo.device_name, // ,
data: _query, // src\subpackage\device\js\ouxuanac.md
},
failMsg: '操作失败!',
};
//->& 20201224 5
if(switchInfo.hardware_type === 'AccessControl'&&status == 0)_data['delay'] = '5';
return _data;
},
//
operateReq({data, isTip=true, isLoad=true}){
if(isLoad)util.showLoad();
deviceServer.post({
url: deviceApi.ouxuanac,
data: data,
isDefaultGet: false,
})
.then(res=>{
util.hideLoad();
console.log(res);
if(isLoad)util.hideLoad();
if(res.data.code == 0){
if(isTip)util.showNone(res.data.message || '操作成功!');
}else{
if(isTip)util.showNone(res.data.message || '操作失败!');
}
})
.catch(util.hideLoad)
}, 300, 300),
.catch(err=>{if(isLoad)util.hideLoad()})
},
// //
getGateQuery({ switchInfo, status }){
let { enter_id, leave_id, hardware_net_addr } = switchInfo;
@ -201,22 +226,22 @@ export default {
let {
hardware_connect_method,
hardware_type,
hardware_connect_id,
hardware_id,
node_id,
hardware_net_addr
} = switchInfo;
const postData = {
name: this.getQueryName(switchInfo),
value: { id: hardware_connect_id + '', } // value String
value: { id: hardware_id + '', } // value String
};
if (hardware_connect_method === 'Gpio') postData.value['status'] = this.getRelayStatus(status);
if (this.changeLowerCase(hardware_connect_method) === 'gpio') postData.value['status'] = this.getRelayStatus(status);
// tcp hardware_net_addr
if (hardware_connect_method === 'Tcp') postData.value['tcp'] = hardware_net_addr + '';
if (hardware_connect_method === 'SerialPort485' || hardware_connect_method === 'Tcp'){
if (this.changeLowerCase(hardware_connect_method) === 'tcp') postData.value['tcp'] = hardware_net_addr + '';
let _flag = this.changeLowerCase(hardware_connect_method) === 'serialport485' || this.changeLowerCase(hardware_connect_method) === 'tcp';
if (_flag){
if(hardware_type === 'Air'){ // key op
postData.value['op'] = this.getAirRelayStatus(status);
postData['name'] = this.getAirQueryName(switchInfo)
@ -228,7 +253,9 @@ export default {
}
return postData;
},
changeLowerCase(str){
return str.toString().toLocaleLowerCase();
},
//
// Low = "low", //
// High = "high", //
@ -258,13 +285,14 @@ export default {
// name
getAirQueryName(switchInfo){
let { hardware_connect_method, hardware_model } = switchInfo;
if(hardware_connect_method === 'Tcp'&&hardware_model === 'JianDa')return 'ray-air-rs-tcp';
let _flag = this.changeLowerCase(hardware_connect_method) === 'tcp'&&this.changeLowerCase(hardware_model) === 'jianda';
if(_flag)return 'ray-air-rs-tcp';
let _obj = {
'Acmelec': 'acmelec',
'ZhongNan': 'zhongnan',
'JianDa': 'ray-air-rs'
'acmelec': 'acmelec',
'zhongnan': 'zhongnan',
'jianda': 'ray-air-rs'
};
return _obj[hardware_model] || '';
return _obj[this.changeLowerCase(hardware_model)] || '';
},
getIcon(){
let { pageInfo } = this;

Loading…
Cancel
Save