Browse Source

gx sellbox

voice
刘嘉炜 4 years ago
parent
commit
fcd21a02b9
  1. 2
      src/js/server.js
  2. 20
      src/subpackage/device/components/device_name/device_name.vue
  3. 4
      src/subpackage/device/js/device_api.js
  4. 46
      src/subpackage/device/pages/device_manage/device_manage.vue
  5. 4
      src/subpackage/device/pages/index/index.vue
  6. 114
      src/subpackage/device/pages/sell_box_manage/sell_box_manage.vue
  7. 5
      src/subpackage/device/pages/switch_manage/switch_manage.vue

2
src/js/server.js

@ -11,7 +11,7 @@ export class Server {
const _token = uni.getStorageSync('token') || '';
if(_token)data['token'] = _token;
if(method === 'POST'&&_token)url = url + `?token=${_token}`
uni.request({
url,
data,

20
src/subpackage/device/components/device_name/device_name.vue

@ -1,19 +1,30 @@
<template>
<view class="device-name">
<image class="dn-logo"></image>
<image class="dn-logo" mode="aspectFit" :src="curStoreInfo.logo || ''"></image>
<view class="dn-content">
<view class="dc-store-name">文字文字文字文字文字文字文字</view>
<view class="dc-store-name">{{curStoreInfo.name || '-'}}</view>
<view class="dc-name">
<image class="dn-ico" mode="aspectFit" src="/subpackage/device/static/images/position.png"></image>
<text class="dn-txt">文字文字文字文字文字文字文字-01</text>
<text class="dn-txt">{{name || '-'}}</text>
</view>
</view>
</view>
</template>
<script>
import { mapState } from 'vuex'
export default {
props: {
name: {
type: String,
defalut: ''
}
},
computed: {
...mapState({ curStoreInfo: state => state.device.curStoreInfo }),
},
methods: {
}
}
</script>
@ -29,7 +40,6 @@ export default {
margin-right: 12upx;
width: 72upx;
height: 72upx;
background-color: skyblue;
}
.dn-content{
flex-grow: 1;

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

@ -2,6 +2,10 @@ import { ORIGIN } from '../../../js/api';
export const DEVICE_API = {
stadiumList:`${ORIGIN}/stadium/list`, // 店铺列表
vendingGoodsList:`${ORIGIN}/stadium/vending/goods/list`, // 售货柜-商品列表
vendingGoodsRestock:`${ORIGIN}/admin/stadium/vending/goods/restock`, // 售货柜-库存修改保存
hardwareList:`${ORIGIN}/admin/stadium/hardware/list`, // 设备列表
ouxuanac:`${ORIGIN}/ouxuanac/sendPacket`, // 中控控制
// ouxuanac--> http://api.ouxuan.net/project/233/interface/api/10012 接口文档

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

@ -3,10 +3,10 @@
<store-name></store-name>
<view class="dm-tit">{{pageInfo.name || '-'}}</view>
<view class="dm-list">
<view class="dl-item" v-for="i in 10" :key="i">
<view class="dl-item" v-for="(e, i) in deviceList" :key="i">
<view class="di-header">
<image mode="aspectFit" :src="getIcon()"></image>
<view class="dh-name">欧轩智能测试柜-01</view>
<view class="dh-name">{{e.hardware_type_name || '-'}}</view>
<view class="dh-test-btn" v-if="pageInfo.isTestBtn" @click="testBtn">
<image mode="aspectFit" :src="pageInfo.testBtnIcon || ''"></image>
<view>{{pageInfo.testBtnName || '-'}}</view>
@ -15,7 +15,7 @@
<view class="di-section">
<view class="ds-stock" v-if="pageInfo.isShowStock">
<view>库存<text class="active">充足</text></view>
<view hover-class="hover-active" @click="stockBtn">{{pageInfo.stockBtnName || '-'}}</view>
<view hover-class="hover-active" @click="stockBtn(e)">{{pageInfo.stockBtnName || '-'}}</view>
</view>
<view class="ds-contral">
<view>
@ -41,6 +41,10 @@
<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';
import { mapState } from 'vuex';
const dmObj = {
'd7': {
id: 7,
@ -52,6 +56,7 @@ const dmObj = {
stockBtnName: '补货',
deviceBtnOpenName: '开启售货',
deviceBtnStopName: '停止售货',
deviceType: 'VendingMachine', //
},
'd8': {
id: 8,
@ -88,31 +93,56 @@ const dmObj = {
},
}
export default {
computed: {
...mapState({
curStoreInfo: state => state.device.curStoreInfo,
})
},
components: {
'store-name': store_name
},
data(){
return {
deviceList: [],
pageInfo: {},
isStart: false
isStart: false,
}
},
onLoad(options){
let _pageInfo = dmObj[`d${options.sid}`] || {};
this.pageInfo = _pageInfo;
uni.setNavigationBarTitle({ title: _pageInfo.name });
this.getDeviceList(_pageInfo)
},
methods: {
getDeviceList(pageInfo){
let { curStoreInfo } = this;
deviceServer.get({
url: deviceApi.hardwareList,
data: {
'filter[stadium_id]': curStoreInfo.id,
'filter[hardware_type]': pageInfo.deviceType,
},
failMsg: '加载设备失败!'
})
.then(res=>{
let _list = res.list || [];
this.deviceList = _list;
console.log(res);
})
},
getIcon(){
let { pageInfo } = this;
if(!pageInfo.id)return '';
return `/subpackage/device/static/images/devices/${pageInfo.id}.png`
},
stockBtn(){
console.log(123)
stockBtn(e){
let { pageInfo } = this;
if(pageInfo.id == 7)return util.routeTo(`/subpackage/device/pages/sell_box_manage/sell_box_manage`, 'nT');
let _query = {
id: e.id,
name: e.hardware_type_name
}
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 == 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`, 'nT');

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

@ -63,8 +63,8 @@ export default {
},
routeTo(e){
if(e.path == '')return util.showNone('暂未开放!');
if(e.id != 5)return util.showNone(`开发中!`);
util.routeTo(`${rootPage}${e.path}?sid=${e.id}`, 'nT');
if(e.id == 5 || e.id == 7)return util.routeTo(`${rootPage}${e.path}?sid=${e.id}`, 'nT');
util.showNone(`开发中!`);
}
}
}

114
src/subpackage/device/pages/sell_box_manage/sell_box_manage.vue

@ -1,27 +1,27 @@
<template>
<view class="sell-box-manage">
<device-name id="devicename"></device-name>
<device-name id="devicename" :name="optionsQuery.name"></device-name>
<view class="sbm-section" :style="'height:'+ sectionHeight +'px;'">
<scroll-view class="ss-tabs" scroll-y>
<view :class="['st-item', i == 2?'active':'']" v-for="(e,i) in 20" :key="i">第一</view>
<view :class="['st-item', e.row == scrollIntoViewID?'active':'']" v-for="(e,i) in goodsList" :key="i" @click="tabChange(e.row)">{{e.row || ''}}</view>
</scroll-view>
<scroll-view class="ss-list" scroll-y>
<view class="sl-section" v-for="k in 5" :key="k">
<view class="ss-tit"><text>售货机第行的商品</text></view>
<scroll-view class="ss-list" scroll-y :scroll-into-view="'ss'+scrollIntoViewID" scroll-with-animation>
<view class="sl-section" v-for="(e,i) in goodsList" :key="i" :id="'ss' + e.row">
<view class="ss-tit">{{e.row || ''}}<text>售货机第{{e.row || ''}}行的商品</text></view>
<view class="ss-goods-list">
<view class="sgl-item" v-for="i in 5" :key="i">
<view class="sgl-item" v-for="(k,j) in e.vending_goods" :key="j">
<view class="si-img">
<image></image>
<image mode="aspectFit" :src="k.image || ''"></image>
<view class="si-tag"><view>101</view></view>
</view>
<view class="si-name">
<view>维他奶原味豆奶</view>
<view>{{k.goods_name || '-'}}</view>
</view>
<view class="si-price">¥3.5</view>
<view class="si-price">¥{{k.price || '-'}}</view>
<view class="si-contral">
<view hover-class="hover-active">-</view>
<input disabled value="200"/>
<view hover-class="hover-active">+</view>
<view hover-class="hover-active" @click="reduceGoods({group: i, index: j})">-</view>
<input disabled :value="k.stock || 0"/>
<view hover-class="hover-active" @click="addGoods({group: i, index: j})">+</view>
</view>
</view>
</view>
@ -30,28 +30,38 @@
</scroll-view>
</view>
<view class="sbm-fixed-bar">
<view>
<image class="active" mode="aspectFit" src="/subpackage/device/static/images/selected_987.png"></image>
<text>确认补货</text>
<view @click="fillAll">
<image v-if="isFillAll" class="active" mode="aspectFit" src="/subpackage/device/static/images/selected_987.png"></image>
<image v-else></image>
<text>全部货道铺满</text>
</view>
<view>确认补货</view>
<view @click="confirmSave">确认补货</view>
</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';
export default {
components: {
'device-name': device_name
},
data(){
return {
sectionHeight: 0
sectionHeight: 0,
optionsQuery: {},
goodsList: [],
scrollIntoViewID: '',
isFillAll: false
}
},
async onLoad(){
async onLoad(options){
let _query = util.jsonPar(options.query);
this.optionsQuery = _query || {};
this.getGoodsList(_query.id)
// this.getGoodsList(12)
},
async onReady(){
let _topBar = await util.getNodeMes(`#devicename`);
@ -59,8 +69,68 @@ export default {
let _sysMes = uni.getSystemInfoSync();
this.sectionHeight = _sysMes.windowHeight - (_botBar.height + _topBar.height);
console.log(_topBar, _botBar, _sysMes, this.sectionHeight)
},
methods: {
fillAll(){
this.isFillAll = !this.isFillAll;
},
confirmSave: util.debounce(function(){
let { isFillAll, optionsQuery } = this;
let _list = this.goodsList.slice();
let _goodsArr = [];
_list.forEach((el,idx)=>{
if(el.vending_goods.length)el.vending_goods.forEach((e,i)=>{
_goodsArr.push({ id: e.id, stock: isFillAll? e.depth : e.stock });
})
})
util.showLoad();
deviceServer.post({
url: deviceApi.vendingGoodsRestock,
data: _goodsArr,
isDefaultGet: false
})
.then(res=>{
if(res.data.code == 0){
util.showNone(res.data.message || '操作成功!');
setTimeout(_=>this.getGoodsList(optionsQuery.id), 1200);
}else{
util.showNone(res.data.message || '操作失败!');
}
})
console.log(_goodsArr)
}, 300, 300),
addGoods({group, index}){
let _list = this.goodsList.slice();
if(_list[group].vending_goods[index].depth<= _list[group].vending_goods[index].stock)return util.showNone('超出上限');
_list[group].vending_goods[index].stock++;
this.goodsList = _list;
},
reduceGoods({group, index}){
let _list = this.goodsList.slice();
if(_list[group].vending_goods[index].stock<=0)return;
_list[group].vending_goods[index].stock--;
this.goodsList = _list;
},
getGoodsList(hardware_id){
util.showLoad();
deviceServer.get({
url: deviceApi.vendingGoodsList,
data: { hardware_id },
failMsg: '加载失败!'
})
.then(res=>{
util.hideLoad()
let _list = res.list || [];
this.goodsList = _list;
if(_list.length>0)this.scrollIntoViewID = _list[0].row;
})
.catch(util.hideLoad)
},
tabChange(row){
this.scrollIntoViewID = row;
}
}
}
</script>
@ -134,11 +204,10 @@ export default {
margin-bottom: 10upx;
width: 148upx;
height: 148upx;
background-color: skyblue;
>image{
width: 100%;
height: 100%;
background-color: turquoise;
background-color: #faf7fa;
}
.si-tag{
position: absolute;
@ -251,7 +320,6 @@ export default {
border-radius: 50%;
border: 2upx solid #DDD;
&.active{
border-width: 0;
border-color: transparent;
}
}

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

@ -167,17 +167,20 @@ export default {
is_delay: true,
queue_group: 'gate'
}
util.showLoad();
deviceServer.post({
url: deviceApi.ouxuanac,
data: {
device: curStoreInfo.device_name, // ,
data: _query, // src\subpackage\device\js\ouxuanac.md
},
failMsg: '操作失败!'
failMsg: '操作失败!',
})
.then(res=>{
util.hideLoad();
console.log(res);
})
.catch(util.hideLoad)
},
getIcon(){
let { pageInfo } = this;

Loading…
Cancel
Save