Commit 2b3c89a2 by 施宇

1

parent d032b2d7
{"ignoreds":["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"],"folderInfo":{"./":{"mtimeMs":1588039958728.2603,"children":["app.js","app.json","app.wxss","project.config.json","sitemap.json"]},"pages/":{"mtimeMs":1588045516900.1838,"children":[]},"res/":{"mtimeMs":1587987929535.54,"children":[]},"res/css/":{"mtimeMs":1587468648224.7944,"children":["res/css/base.wxss"]},"res/img/":{"mtimeMs":1588153975467.2988,"children":["res/img/all-check-left-a.png","res/img/all-check-left.png","res/img/all-check-right-a.png","res/img/all-check-right.png","res/img/ck-icon-a.png","res/img/ck-icon.png","res/img/close-icon.png","res/img/kc-icon-a.png","res/img/kc-icon.png","res/img/login-img.png","res/img/login-text.png","res/img/nav-arrow-down.png","res/img/question-icon.png","res/img/search-icon.png","res/img/sh-icon-a.png","res/img/sh-icon.png","res/img/sigle-check-left-a.png","res/img/sigle-check-left.png","res/img/sigle-check-right-a.png","res/img/sigle-check-right.png","res/img/sj-icon-a.png","res/img/sj-icon.png","res/img/sz-icon-a.png","res/img/sz-icon.png","res/img/warn-icon.png"]},"utils/":{"mtimeMs":1588235657705.948,"children":["utils/api.js","utils/axios.js","utils/md5.js","utils/print.js","utils/printerjobs.js","utils/textEncoding.js","utils/util.js"]},".git/":{"mtimeMs":1588235995853.019,"children":[]},".wechatide/":{"mtimeMs":1587519550088.0625,"children":[".wechatide/fileCache.cfg"]},"pages/home/":{"mtimeMs":1587536014892.4702,"children":["pages/home/home.js","pages/home/home.json","pages/home/home.wxml","pages/home/home.wxss"]},"pages/login/":{"mtimeMs":1587535974795.0686,"children":["pages/login/login.js","pages/login/login.json","pages/login/login.wxml","pages/login/login.wxss"]},"components/":{"mtimeMs":1587538211879.0247,"children":[]},"components/navC/":{"mtimeMs":1587538221287.4016,"children":["components/navC/navC.js","components/navC/navC.json","components/navC/navC.wxml","components/navC/navC.wxss"]},"pages/receivinggoods/":{"mtimeMs":1587538742321.587,"children":["pages/receivinggoods/receivinggoods.js","pages/receivinggoods/receivinggoods.json","pages/receivinggoods/receivinggoods.wxml","pages/receivinggoods/receivinggoods.wxss"]},"pages/upperShelf/":{"mtimeMs":1587622056930.153,"children":["pages/upperShelf/upperShelf.js","pages/upperShelf/upperShelf.json","pages/upperShelf/upperShelf.wxml","pages/upperShelf/upperShelf.wxss"]},"pages/outbound/":{"mtimeMs":1587626008346.8442,"children":["pages/outbound/outbound.js","pages/outbound/outbound.json","pages/outbound/outbound.wxml","pages/outbound/outbound.wxss"]},"pages/scanDelivery/":{"mtimeMs":1587627596586.3196,"children":["pages/scanDelivery/scanDelivery.js","pages/scanDelivery/scanDelivery.json","pages/scanDelivery/scanDelivery.wxml","pages/scanDelivery/scanDelivery.wxss"]},"pages/picking/":{"mtimeMs":1587631234329.3645,"children":["pages/picking/picking.js","pages/picking/picking.json","pages/picking/picking.wxml","pages/picking/picking.wxss"]},"pages/cardBoard/":{"mtimeMs":1587632724321.1174,"children":["pages/cardBoard/cardBoard.js","pages/cardBoard/cardBoard.json","pages/cardBoard/cardBoard.wxml","pages/cardBoard/cardBoard.wxss"]},"pages/changeWarehouse/":{"mtimeMs":1587635396534.957,"children":["pages/changeWarehouse/changeWarehouse.js","pages/changeWarehouse/changeWarehouse.json","pages/changeWarehouse/changeWarehouse.wxml","pages/changeWarehouse/changeWarehouse.wxss"]},"pages/systemSettings/":{"mtimeMs":1587637181028.4365,"children":["pages/systemSettings/systemSettings.js","pages/systemSettings/systemSettings.json","pages/systemSettings/systemSettings.wxml","pages/systemSettings/systemSettings.wxss"]},"pages/printer/":{"mtimeMs":1587637593187.5686,"children":["pages/printer/printer.js","pages/printer/printer.json","pages/printer/printer.wxml","pages/printer/printer.wxss"]},"pages/inventoryQuery/":{"mtimeMs":1587639536186.8396,"children":["pages/inventoryQuery/inventoryQuery.js","pages/inventoryQuery/inventoryQuery.json","pages/inventoryQuery/inventoryQuery.wxml","pages/inventoryQuery/inventoryQuery.wxss"]},"pages/startPage/":{"mtimeMs":1588045543126.067,"children":["pages/startPage/startPage.js","pages/startPage/startPage.json","pages/startPage/startPage.wxml","pages/startPage/startPage.wxss"]}},"cacheVersion":1} {"ignoreds":["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"],"folderInfo":{"./":{"mtimeMs":1588039958728.2603,"children":["app.js","app.json","app.wxss","project.config.json","sitemap.json"]},"pages/":{"mtimeMs":1588761186704.5857,"children":[]},"res/":{"mtimeMs":1587987929535.54,"children":[]},"res/css/":{"mtimeMs":1587468648224.7944,"children":["res/css/base.wxss"]},"res/img/":{"mtimeMs":1588153975467.2988,"children":["res/img/all-check-left-a.png","res/img/all-check-left.png","res/img/all-check-right-a.png","res/img/all-check-right.png","res/img/ck-icon-a.png","res/img/ck-icon.png","res/img/close-icon.png","res/img/kc-icon-a.png","res/img/kc-icon.png","res/img/login-img.png","res/img/login-text.png","res/img/nav-arrow-down.png","res/img/question-icon.png","res/img/search-icon.png","res/img/sh-icon-a.png","res/img/sh-icon.png","res/img/sigle-check-left-a.png","res/img/sigle-check-left.png","res/img/sigle-check-right-a.png","res/img/sigle-check-right.png","res/img/sj-icon-a.png","res/img/sj-icon.png","res/img/sz-icon-a.png","res/img/sz-icon.png","res/img/warn-icon.png"]},"utils/":{"mtimeMs":1588729595864.972,"children":["utils/api.js","utils/axios.js","utils/md5.js","utils/printerjobs.js","utils/textEncoding.js","utils/util.js"]},".git/":{"mtimeMs":1588761188861.8364,"children":[]},".wechatide/":{"mtimeMs":1587519550088.0625,"children":[".wechatide/fileCache.cfg"]},"pages/home/":{"mtimeMs":1587536014892.4702,"children":["pages/home/home.js","pages/home/home.json","pages/home/home.wxml","pages/home/home.wxss"]},"pages/login/":{"mtimeMs":1587535974795.0686,"children":["pages/login/login.js","pages/login/login.json","pages/login/login.wxml","pages/login/login.wxss"]},"components/":{"mtimeMs":1587538211879.0247,"children":[]},"components/navC/":{"mtimeMs":1587538221287.4016,"children":["components/navC/navC.js","components/navC/navC.json","components/navC/navC.wxml","components/navC/navC.wxss"]},"pages/receivinggoods/":{"mtimeMs":1587538742321.587,"children":["pages/receivinggoods/receivinggoods.js","pages/receivinggoods/receivinggoods.json","pages/receivinggoods/receivinggoods.wxml","pages/receivinggoods/receivinggoods.wxss"]},"pages/upperShelf/":{"mtimeMs":1587622056930.153,"children":["pages/upperShelf/upperShelf.js","pages/upperShelf/upperShelf.json","pages/upperShelf/upperShelf.wxml","pages/upperShelf/upperShelf.wxss"]},"pages/outbound/":{"mtimeMs":1587626008346.8442,"children":["pages/outbound/outbound.js","pages/outbound/outbound.json","pages/outbound/outbound.wxml","pages/outbound/outbound.wxss"]},"pages/scanDelivery/":{"mtimeMs":1587627596586.3196,"children":["pages/scanDelivery/scanDelivery.js","pages/scanDelivery/scanDelivery.json","pages/scanDelivery/scanDelivery.wxml","pages/scanDelivery/scanDelivery.wxss"]},"pages/picking/":{"mtimeMs":1587631234329.3645,"children":["pages/picking/picking.js","pages/picking/picking.json","pages/picking/picking.wxml","pages/picking/picking.wxss"]},"pages/cardBoard/":{"mtimeMs":1587632724321.1174,"children":["pages/cardBoard/cardBoard.js","pages/cardBoard/cardBoard.json","pages/cardBoard/cardBoard.wxml","pages/cardBoard/cardBoard.wxss"]},"pages/changeWarehouse/":{"mtimeMs":1587635396534.957,"children":["pages/changeWarehouse/changeWarehouse.js","pages/changeWarehouse/changeWarehouse.json","pages/changeWarehouse/changeWarehouse.wxml","pages/changeWarehouse/changeWarehouse.wxss"]},"pages/systemSettings/":{"mtimeMs":1587637181028.4365,"children":["pages/systemSettings/systemSettings.js","pages/systemSettings/systemSettings.json","pages/systemSettings/systemSettings.wxml","pages/systemSettings/systemSettings.wxss"]},"pages/printer/":{"mtimeMs":1587637593187.5686,"children":["pages/printer/printer.js","pages/printer/printer.json","pages/printer/printer.wxml","pages/printer/printer.wxss"]},"pages/inventoryQuery/":{"mtimeMs":1587639536186.8396,"children":["pages/inventoryQuery/inventoryQuery.js","pages/inventoryQuery/inventoryQuery.json","pages/inventoryQuery/inventoryQuery.wxml","pages/inventoryQuery/inventoryQuery.wxss"]},"pages/startPage/":{"mtimeMs":1588045543126.067,"children":["pages/startPage/startPage.js","pages/startPage/startPage.json","pages/startPage/startPage.wxml","pages/startPage/startPage.wxss"]},"pages/mountingPlate/":{"mtimeMs":1588761190467.1958,"children":["pages/mountingPlate/mountingPlate.js","pages/mountingPlate/mountingPlate.json","pages/mountingPlate/mountingPlate.wxml","pages/mountingPlate/mountingPlate.wxss"]}},"cacheVersion":1}
\ No newline at end of file \ No newline at end of file
{ {
"pages": [ "pages": [
"pages/cardBoard/cardBoard", "pages/home/home",
"pages/printer/printer",
"pages/mountingPlate/mountingPlate",
"pages/scanDelivery/scanDelivery",
"pages/picking/picking",
"pages/receivinggoods/receivinggoods",
"pages/cardBoard/cardBoard",
"pages/startPage/startPage", "pages/startPage/startPage",
"pages/changeWarehouse/changeWarehouse", "pages/changeWarehouse/changeWarehouse",
"pages/receivinggoods/receivinggoods",
"pages/home/home",
"pages/login/login", "pages/login/login",
"pages/inventoryQuery/inventoryQuery", "pages/inventoryQuery/inventoryQuery",
"pages/printer/printer",
"pages/systemSettings/systemSettings", "pages/systemSettings/systemSettings",
"pages/picking/picking",
"pages/scanDelivery/scanDelivery",
"pages/outbound/outbound", "pages/outbound/outbound",
"pages/upperShelf/upperShelf" "pages/upperShelf/upperShelf"
], ],
......
...@@ -83,6 +83,9 @@ Component({ ...@@ -83,6 +83,9 @@ Component({
case 'pages/systemSettings/systemSettings': case 'pages/systemSettings/systemSettings':
index = 5; index = 5;
break; break;
case 'pages/mountingPlate/mountingPlate':
index = 6;
break;
default: default:
index = 0; index = 0;
break break
...@@ -115,7 +118,14 @@ Component({ ...@@ -115,7 +118,14 @@ Component({
drop1:false, drop1:false,
drop2:false drop2:false
}); });
console.log('退出') wx.removeStorageSync('access_token');
wx.removeStorageSync('userInfo');
wx.removeStorageSync('userId');
wx.removeStorageSync('storeInfo');
app.globalData.storeInfo = "";
wx.reLaunch({
url: '/pages/login/login'
});
}, },
drop2Operation:function(e){ drop2Operation:function(e){
let url = e.currentTarget.dataset.url; let url = e.currentTarget.dataset.url;
...@@ -135,14 +145,8 @@ Component({ ...@@ -135,14 +145,8 @@ Component({
me.setData({ me.setData({
userInfo:res.data userInfo:res.data
}); });
wx.setStorage({ wx.setStorageSync("userInfo", data);
key: "userInfo", wx.setStorageSync("userId",data.userId);
data: data
});
wx.setStorage({
key: "userId",
data: data.userId
});
......
<!--components/navC/navC.wxml--> <!--components/navC/navC.wxml-->
<view class="page-wrapper" bindtap="pageFun"> <view class="page-wrapper" bindtap="pageFun">
<view class="nav-top Bflex aic"> <view class="nav-top Bflex aic">
<view class="nav-left Bflex"> <view class="nav-left Bflex">
<view class="user-name Bflex aic" catchtap="drop1Fun"> <view class="user-name Bflex aic" catchtap="drop1Fun">
<text class="ellipsis">{{userInfo.email}}</text> <text class="ellipsis">{{userInfo.email}}</text>
<image class="arrow-down" src="../../res/img/nav-arrow-down.png"></image> <image class="arrow-down" src="../../res/img/nav-arrow-down.png"></image>
<view class="drop-down1 borderBox " wx:if="{{drop1}}"> <view class="drop-down1 borderBox " wx:if="{{drop1}}">
<view class="item" catchtap="drop1Operation">切换</view> <view class="item" catchtap="drop1Operation">切换</view>
<view class="item" catchtap="drop1Operation">退出</view> <view class="item" catchtap="drop1Operation">退出</view>
</view>
</view>
<view class="zq Bflex aic" catchtap="drop2Fun">
<text>专区</text>
<image class="arrow-down" src="../../res/img/nav-arrow-down.png"></image>
<view class="drop-down2 borderBox" wx:if="{{drop2}}">
<view class="item Bflex aic {{index == 1?'active':'' }}" catchtap="drop2Operation" data-url="/pages/receivinggoods/receivinggoods">
<image src="../../res/img/sh-icon.png" class="icon icon1"></image>
<image src="../../res/img/sh-icon-a.png" class="icon icon2"></image>
<text>收货管理</text>
</view>
<view class="item Bflex aic {{index == 2?'active':'' }}" catchtap="drop2Operation" data-url="/pages/upperShelf/upperShelf">
<image src="../../res/img/sj-icon.png" class="icon icon1"></image>
<image src="../../res/img/sj-icon-a.png" class="icon icon2"></image>
<text>上架</text>
</view>
<view class="item Bflex aic {{index == 3?'active':'' }}" catchtap="drop2Operation" data-url="/pages/outbound/outbound">
<image src="../../res/img/ck-icon.png" class="icon icon1"></image>
<image src="../../res/img/ck-icon-a.png" class="icon icon2"></image>
<text>出库管理</text>
</view>
<view class="item Bflex aic {{index == 4?'active':'' }}" catchtap="drop2Operation" data-url="/pages/inventoryQuery/inventoryQuery">
<image src="../../res/img/kc-icon.png" class="icon icon1"></image>
<image src="../../res/img/kc-icon-a.png" class="icon icon2"></image>
<text>库存查询</text>
</view>
<view class="item Bflex aic {{index == 5?'active':'' }}" catchtap="drop2Operation" data-url="/pages/systemSettings/systemSettings">
<image src="../../res/img/sz-icon.png" class="icon icon1"></image>
<image src="../../res/img/sz-icon-a.png" class="icon icon2"></image>
<text>系统设定</text>
</view> </view>
</view>
<view class="zq Bflex aic" catchtap="drop2Fun">
<text>专区</text>
<image class="arrow-down" src="../../res/img/nav-arrow-down.png"></image>
<view class="drop-down2 borderBox" wx:if="{{drop2}}">
<view class="item Bflex aic {{index == 1?'active':'' }}" catchtap="drop2Operation" data-url="/pages/receivinggoods/receivinggoods">
<image src="../../res/img/sh-icon.png" class="icon icon1"></image>
<image src="../../res/img/sh-icon-a.png" class="icon icon2"></image>
<text>收货管理</text>
</view>
<view class="item Bflex aic {{index == 2?'active':'' }}" catchtap="drop2Operation" data-url="/pages/upperShelf/upperShelf">
<image src="../../res/img/sj-icon.png" class="icon icon1"></image>
<image src="../../res/img/sj-icon-a.png" class="icon icon2"></image>
<text>上架</text>
</view>
<view class="item Bflex aic {{index == 6?'active':'' }}" catchtap="drop2Operation" data-url="/pages/mountingPlate/mountingPlate">
<image src="../../res/img/sj-icon.png" class="icon icon1"></image>
<image src="../../res/img/sj-icon-a.png" class="icon icon2"></image>
<text>装卡板</text>
</view>
<view class="item Bflex aic {{index == 3?'active':'' }}" catchtap="drop2Operation" data-url="/pages/outbound/outbound">
<image src="../../res/img/ck-icon.png" class="icon icon1"></image>
<image src="../../res/img/ck-icon-a.png" class="icon icon2"></image>
<text>出库管理</text>
</view>
<view class="item Bflex aic {{index == 4?'active':'' }}" catchtap="drop2Operation" data-url="/pages/inventoryQuery/inventoryQuery">
<image src="../../res/img/kc-icon.png" class="icon icon1"></image>
<image src="../../res/img/kc-icon-a.png" class="icon icon2"></image>
<text>库存查询</text>
</view>
<view class="item Bflex aic {{index == 5?'active':'' }}" catchtap="drop2Operation" data-url="/pages/systemSettings/systemSettings">
<image src="../../res/img/sz-icon.png" class="icon icon1"></image>
<image src="../../res/img/sz-icon-a.png" class="icon icon2"></image>
<text>系统设定</text>
</view>
</view>
</view> </view>
</view> </view>
<view class="html-title ellipsis">{{title}}</view>
<view class="nav-right">当前仓库:{{storeInfo.store_name||'--'}}</view>
</view> </view>
<view class="html-title ellipsis">{{title}}</view> <slot></slot>
<view class="nav-right">当前仓库:{{storeInfo.store_name||'--'}}</view>
</view>
<slot></slot>
</view> </view>
\ No newline at end of file
...@@ -5,9 +5,6 @@ import { ...@@ -5,9 +5,6 @@ import {
import { import {
apis apis
} from '../../utils/api.js'; } from '../../utils/api.js';
import {
openBluetoothAdapter
} from '../../utils/print.js';
Page({ Page({
/** /**
...@@ -17,9 +14,7 @@ Page({ ...@@ -17,9 +14,7 @@ Page({
tableData:[], tableData:[],
numText:"",//卡板号 numText:"",//卡板号
}, },
test:function(){
openBluetoothAdapter()
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</view> </view>
</view> </view>
<view class="btn-group Bflex"> <view class="btn-group Bflex">
<view class="btn-item btn blue-border-btn" catchtap="test">装卡板</view> <view class="btn-item btn blue-border-btn" >装卡板</view>
<view class="btn-item btn blue-border-btn">补打卡板标签</view> <view class="btn-item btn blue-border-btn">补打卡板标签</view>
<view class="btn-item btn disbled-btn">清除卡板记录</view> <view class="btn-item btn disbled-btn">清除卡板记录</view>
</view> </view>
......
...@@ -87,10 +87,7 @@ Page({ ...@@ -87,10 +87,7 @@ Page({
me.cancelFun(); me.cancelFun();
} }
}); });
wx.setStorage({ wx.setStorageSync("storeInfo",chooseObj);
key: "storeInfo",
data: chooseObj
});
app.globalData.storeInfo = chooseObj; app.globalData.storeInfo = chooseObj;
} else { } else {
wx.showToast({ wx.showToast({
......
<nav-c title="库存查询">
<view class="inventory-query-view width-854px nav-view borderBox"> <view class="inventory-query-view width-854px nav-view borderBox">
<nav-c></nav-c>
<view class="inventory-query-wrapper "> <view class="inventory-query-wrapper ">
<view class="view-top Bflex aic"> <view class="view-top Bflex aic">
<text class="desc noMarginLeft">型号:</text> <text class="desc noMarginLeft">型号:</text>
...@@ -97,4 +97,5 @@ ...@@ -97,4 +97,5 @@
</view> </view>
</view> </view>
</view> </view>
</view> </view>
\ No newline at end of file </nav-c>
...@@ -49,10 +49,8 @@ Page({ ...@@ -49,10 +49,8 @@ Page({
passwd:hexMD5(me.data.password) passwd:hexMD5(me.data.password)
}, function(res) { }, function(res) {
if (res.errcode === 0) { if (res.errcode === 0) {
wx.setStorage({ wx.setStorageSync(
key: "access_token", "access_token",res.access_token);
data: res.access_token
});
wx.redirectTo({ wx.redirectTo({
url: '/pages/home/home' url: '/pages/home/home'
}); });
......
import {
getData
} from '../../utils/axios.js';
import {
apis
} from '../../utils/api.js';
Page({
/**
* 页面的初始数据
*/
data: {
tableData:[],
numText:"",//卡板号
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
formInput:function(e){
let {value} = e.detail ;
// console.log(value.substring(0, 2))
let str = value.substring(0, 2);
this.setData({
numText:value
})
if(str == 'XB'){//扫描的是箱号
this.getXbData()
}else if(str == 'KB'){//扫描的是卡版号
this.getKbData()
}
},
getData:function(val){
},
getXbData:function(){
let me = this;
getData(apis.get_box_info, 'post', {"pallet_sn":me.data.numText}, function(res) {
if (res.errcode === 0) {
// let data = res.data;
// me.setData({
// tableData:data,
// numText:val
// })
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, true,true)
},
getKbData:function(){
let me = this;
getData(apis.pallet_in_box_list, 'post', {"pallet_sn":me.data.numText}, function(res) {
if (res.errcode === 0) {
// let data = res.data;
// me.setData({
// tableData:data,
// numText:val
// })
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, true,true)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"usingComponents": { "nav-c": "/components/navC/navC"},
"pageOrientation":"landscape",
"navigationBarBackgroundColor":"#094B8D"
}
\ No newline at end of file
<nav-c title="装卡板">
<view class="card-board-view width-854px nav-view borderBox">
<view class="card-board-wrapper ">
<view class="view-top Bflex aic">
<text class="desc">卡板号/箱号:</text>
<input class="input input-border" bindconfirm="formInput"></input>
<view class="number">
卡板号: <text>{{numText}}</text>
</view>
</view>
<view class="data-view Bflex aic">
<view class="data-table borderBox">
<view class="head Bflex">
<view class="td-1 td borderBox Iflex jcc aic td-50"><text>选项</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>卡板号</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>箱号</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-80"><text>操作</text></view>
</view>
<view class="body">
<block wx:if="{{!tableData.length}}">
<view class="body-data Bflex">
<view class="no-data-td ">暂无数据</view>
</view>
</block>
<block wx:else>
<view class="body-data Bflex" wx:for="{{tableData}}" wx:key="index">
<view class="td-1 td borderBox Iflex jcc aic td-50"><text class="box-icon"></text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>{{item.pallet_sn}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>{{item.box_sn}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-80"><text class="underline-text">取消</text></view>
</view>
</block>
</view>
</view>
<view class="btn-group Bflex">
<view class="btn-item btn blue-border-btn" >装卡板</view>
<view class="btn-item btn blue-border-btn">补打卡板标签</view>
<view class="btn-item btn disbled-btn">清除卡板记录</view>
</view>
</view>
</view>
</view>
</nav-c>
@import '/res/css/base.wxss';
page {
background-color: #F8F8F8;
}
.card-board-wrapper {
padding-left: 10px;
padding-right: 10px;
}
.view-top {
font-size: 14px;
color: #666666;
padding: 13px 0;
}
.desc {
margin-left: 33px;
}
.input {
width: 132px;
height: 33px;
color: #333;
padding: 0 7px;
line-height: 33px;
}
.number {
font-size: 12px;
margin-left: 21px;
}
.number text {
color: #333
}
.data-view {
background: #fff;
box-shadow: 0px 0px 10px -8px rgba(44, 44, 44, 0.81);
border-radius: 3px;
flex-direction: column;
padding:10px 0 40px;
}
.data-table {
border: 1px solid #D1D1D1;
width:368px;
}
.data-table .head {
color: #666;
border-bottom: 1px solid #D1D1D1;
font-size: 12px;
background-color: #F8F8F8;
}
.data-table .td {
padding: 8px 0;
word-break: break-all;
width:119px;
}
.data-table .body {
color: #333;
font-size: 14px;
}
.data-table .body .body-data {
border-bottom: 1px solid #D1D1D1;
}
.data-table .body .body-data:last-child {
border: none
}
.data-table .td-2 {
border-left: 1px solid #D1D1D1;
}
.data-table .td-50 {
width: 50px;
}
.data-table .td-80 {
width: 80px;
}
.box-icon {
margin: 0;
}
.btn-group{
margin-top:50px;
}
.btn-item {
width:140px;
height:33px;
line-height: 31px;
margin-left:38px;
}
// pages/picking/picking.js // pages/picking/picking.js
import {
getData
} from '../../utils/axios.js';
import {
apis
} from '../../utils/api.js';
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
rwVal:"JH200426100020",
hwVal:"1",
kbVal:"",
listArr:[],
initId:""
}, },
/** /**
...@@ -14,7 +24,102 @@ Page({ ...@@ -14,7 +24,102 @@ Page({
onLoad: function (options) { onLoad: function (options) {
}, },
chooseData:function(e){
let {id} = e.currentTarget.dataset;
let newId = "";
if(this.data.initId != id){
newId = id
}
this.setData({
initId:newId
})
},
rwInput:function(e){//任务号input监听
let {value} = e.detail ;
this.setData({
rwVal:value
})
},
rwConfirm:function(e){
let {value} = e.detail ;
this.getList({
pick_task_sn:value
},1)
},
hwInput:function(e){//货位号input监听
let {value} = e.detail ;
this.setData({
hwVal:value
})
},
hwConfirm:function(e){
let {value} = e.detail ;
let rwVal = this.data.rwVal
if(!rwVal){
wx.showToast({
title: '上架任务号不能为空',
icon: 'none',
duration: 2000
});
}else{
this.getList({
pick_task_sn:rwVal,
location_id:value
},1)
}
},
kbInput:function(e){//卡板/箱号input监听
let {value} = e.detail ;
this.setData({
kbVal:value
})
},
kbConfirm:function(e){
let {value} = e.detail ;
let rwVal = this.data.rwVal;
let hwVal = this.data.hwVal;
if(!rwVal){
wx.showToast({
title: '上架任务号不能为空',
icon: 'none',
duration: 2000
});
}else if(!hwVal){
wx.showToast({
title: '货位号不能为空',
icon: 'none',
duration: 2000
});
}else{
this.getList({
pick_task_sn:rwVal,
location_id:hwVal,
box_goods_pallet_sn:value
},2)
}
},
getList:function(data,type){
let me = this;
let url = type == 1?(apis.pick_task_list):(apis.confirm_pick)
getData(url, 'post', {...data}, function(res) {
if (res.errcode === 0) {
let data = res.data;
me.setData({
listArr:data||[]
})
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, true,true)
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
......
<nav-c title="拣货确认"> <nav-c title="拣货确认">
<view class="pinking-view width-854px nav-view borderBox"> <view class="pinking-view width-854px nav-view borderBox">
<view class="pinking-wrapper "> <view class="pinking-wrapper ">
<view class="view-top Bflex aic"> <view class="view-top Bflex aic">
<text class="desc">上架任务号/货位/卡板号/箱号/型号:</text> <text class="desc">上架任务号:</text>
<input class="input input-border" placeholder="请输入用户名"></input> <input class="input input-border" value="{{rwVal}}" bindinput="rwInput" bindconfirm="rwConfirm"></input>
<view class="number"> <text class="desc">货位号:</text>
拣货任务号: <text>0609</text> <input class="input input-border" value="{{hwVal}}" bindinput="hwInput" bindconfirm="hwConfirm"></input>
</view> <text class="desc">卡板号/箱号/型号:</text>
<view class="hw"> <input class="input input-border" value="{{kbVal}}" bindinput="kbInput" bindconfirm="kbConfirm"></input>
当前货位号: <view class="number">
<text>9857</text> 拣货任务号: <text>0609</text>
</view> </view>
</view> <view class="hw">
<view class="table-view"> 当前货位号:
<view class="scroll-view"> <text>9857</text>
<view class="data-table-view"> </view>
<view class="data-table borderBox"> </view>
<view class="head Bflex"> <view class="table-view">
<view class="td-1 td borderBox Iflex jcc aic td-50"><text>选项</text></view> <view class="scroll-view">
<view class="td-2 td borderBox Iflex jcc aic"><text>状态</text></view> <view class="data-table-view">
<view class="td-2 td borderBox Iflex jcc aic"><text>拣货说明</text></view> <view class="data-table borderBox">
<view class="td-2 td borderBox Iflex jcc aic"><text>货位</text></view> <view class="head Bflex">
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>卡板号</text></view> <view class="td-1 td borderBox Iflex jcc aic td-50"><text>选项</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>箱号</text></view> <view class="td-2 td borderBox Iflex jcc aic"><text>状态</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>型号</text></view> <view class="td-2 td borderBox Iflex jcc aic"><text>拣货说明</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>内含件数</text></view> <view class="td-2 td borderBox Iflex jcc aic"><text>货位</text></view>
<view class="td-2 td borderBox Iflex jcc aic "><text>数量</text></view> <view class="td-2 td borderBox Iflex jcc aic td-119"><text>卡板号</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>拣货人</text></view> <view class="td-2 td borderBox Iflex jcc aic td-119"><text>箱号</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-125"><text>拣货时间</text></view> <view class="td-2 td borderBox Iflex jcc aic td-119"><text>型号</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>内含件数</text></view>
<view class="td-2 td borderBox Iflex jcc aic "><text>数量</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>拣货人</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-125"><text>拣货时间</text></view>
</view> </view>
<view class="body"> <view class="body">
<view class="body-data Bflex"> <block wx:if="{{!listArr.length}}">
<view class="td-1 td borderBox Iflex jcc aic td-50"><text class="box-icon"></text></view> <view class="body-data Bflex">
<view class="td-2 td borderBox Iflex jcc aic"><text>状态</text></view> <view class="no-data-td ">暂无数据</view>
<view class="td-2 td borderBox Iflex jcc aic"><text>拣货说明</text></view> </view>
<view class="td-2 td borderBox Iflex jcc aic"><text>货位</text></view> </block>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>卡板号</text></view> <block wx:else>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>箱号</text></view> <view class="body-data Bflex {{initId == item.pick_task_detail_id ?'active':'' }}" wx:for="{{listArr}}" wx:key="index" bindtap="chooseData" data-id="{{ item.pick_task_detail_id}}">
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>型号</text></view> <view class="td-1 td borderBox Iflex jcc aic td-50"><text class="box-icon {{initId == item.pick_task_detail_id ?'checked':'' }}"></text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>内含件数</text></view> <view class="td-2 td borderBox Iflex jcc aic"><text>
<view class="td-2 td borderBox Iflex jcc aic "><text>数量</text></view> <block wx:if="{{item.pick_status == 1}}">未拣货</block>
<view class="td-2 td borderBox Iflex jcc aic"><text>拣货人</text></view> <block wx:elif="{{item.pick_status == 2}}">部分拣货</block>
<view class="td-2 td borderBox Iflex jcc aic td-125"><text>拣货时间</text></view> <block wx:elif="{{item.pick_status == 3}}">已拣货</block>
<block wx:elif="{{item.pick_status == 4}}">取消拣货</block>
</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>{{item.pick_remark}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>{{item.location_id_cn}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>{{item.pallet_id_cn}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>{{item.box_id_cn}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>{{item.goods_name}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>内含件数</text></view>
<view class="td-2 td borderBox Iflex jcc aic "><text>{{item.number}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>{{item.pick_user_id_cn}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-125"><text>{{item.pick_time}}</text></view>
</view>
</block>
</view>
</view> </view>
<view class="cancel-btn btn disbled-btn">取消拣货</view>
</view> </view>
</view> </view>
<view class="cancel-btn btn disbled-btn">取消拣货</view>
</view> </view>
</view> </view>
</view> </view>
</view> <view class="mask ">
</view> <view class=" pinking-mask">
<view class="mask "> <image class="close-icon" src="../../res/img/close-icon.png"></image>
<view class=" pinking-mask"> <view class="tips Bflex jcc aic">
<image class="close-icon" src="../../res/img/close-icon.png"></image> <image src="../../res/img/question-icon.png" class="question-icon"></image>
<view class="tips Bflex jcc aic"> <text class="text">确定要取消拣货吗?
<image src="../../res/img/question-icon.png" class="question-icon"></image>
<text class="text">确定要取消拣货吗?
确定后请将货物放回原货位上。</text> 确定后请将货物放回原货位上。</text>
</view> </view>
</view> </view>
</view> </view>
</nav-c> </nav-c>
\ No newline at end of file
...@@ -13,6 +13,7 @@ page { ...@@ -13,6 +13,7 @@ page {
font-size: 14px; font-size: 14px;
color: #666666; color: #666666;
padding: 13px 0; padding: 13px 0;
flex-wrap: wrap;
} }
.desc { .desc {
...@@ -20,7 +21,7 @@ page { ...@@ -20,7 +21,7 @@ page {
} }
.input { .input {
width: 132px; width: 140px;
height: 33px; height: 33px;
color: #333; color: #333;
padding: 0 7px; padding: 0 7px;
...@@ -30,10 +31,11 @@ page { ...@@ -30,10 +31,11 @@ page {
.number, .number,
.hw { .hw {
font-size: 12px; font-size: 12px;
margin-top: 10px;
} }
.number { .number {
margin-left: 8px; margin-left: 33px;
} }
.hw { .hw {
......
// pages/printer/printer.js // pages/printer/printer.js
import {
getData
} from '../../utils/axios.js';
import {
apis
} from '../../utils/api.js';
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
wlVal:"",
xVal:"",
kbVal:"",
list:[],
isShowWl:false,
isShowX:false,
isShowKb:false
},
onUnload:function(){
wx.closeBluetoothAdapter();
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.getPrintList();
this.openBluetoothAdapter();
}, },
openBluetoothAdapter:function(){
var that = this;
if (wx.openBluetoothAdapter) {
wx.showLoading({
title: '打印设备查找中',
mask:true
})
wx.openBluetoothAdapter({
success: function(res) {
/* 获取本机的蓝牙状态 */
setTimeout(() => {
that.getBluetoothAdapterState()
}, 1000)
},
fail: function(res) {
// 初始化失败
wx.hideLoading()
if (res.errCode === 10001) {
wx.showModal({
title: '错误',
content: '未找到打印设备, 请打开蓝牙后重试。',
showCancel: false
})}else{
wx.showModal({
title: '错误',
content: '设备蓝牙初始化失败, 请重试。',
showCancel: false
})
}
}
})
} else {
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
return
}
},
getBluetoothAdapterState() {
let that = this;
wx.getBluetoothAdapterState({
success: function(res) {
that.startBluetoothDevicesDiscovery()
},
fail(res) {
console.log(res);
wx.hideLoading()
wx.showModal({
title: '错误',
content: '设备蓝牙初始化失败, 请重试。',
showCancel: false
})
}
})
},
startBluetoothDevicesDiscovery() {
var that = this;
setTimeout(() => {
wx.startBluetoothDevicesDiscovery({
success: function(res) {
console.log(res)
/* 获取蓝牙设备列表 */
that.getBluetoothDevices()
},
fail(res) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '蓝牙搜索失败, 请重试。',
showCancel: false
})
}
})
}, 1000)
},
getBluetoothDevices() {
let that = this;
let arr = []
setTimeout(() => {
wx.getBluetoothDevices({
services: [],
allowDuplicatesKey: false,
interval: 0,
success: function(res) {
console.log(res)
wx.hideLoading()
if (res.devices.length > 0) {
for (let i = 0; i < res.devices.length; i++) {
if (res.devices[i].name || res.devices[i].localName) {
arr.push(res.devices[i].name || res.devices[i].localName)
};
};
that.setData({
list:arr
})
} else {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '找不到蓝牙设备, 请重试。',
showCancel: false
})
}
},
fail(res) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '获取蓝牙设备列表失败, 请重试。',
showCancel: false
})
console.log(res, '获取蓝牙设备列表失败=====')
}
})
}, 2000)
},
hiddenInput:function(){
this.setData({
isShowWl:false,
isShowX:false,
isShowKb:false
})
},
changeIsShow:function(e){
let {type} = e.currentTarget.dataset;
if(type == 0){
this.setData({
isShowWl:true,
isShowX:false,
isShowKb:false
})
}else if(type == 1){
this.setData({
isShowWl:false,
isShowX:true,
isShowKb:false
})
}else{
this.setData({
isShowWl:false,
isShowX:false,
isShowKb:true
})
}
},
choosePrint:function(e){
let {type,item} = e.currentTarget.dataset;
console.log(item)
this.hiddenInput()
if(type == 0){
this.setData({
wlVal:item
})
}else if(type == 1){
this.setData({
xVal:item
})
}else{
this.setData({
kbVal:item
})
}
},
getPrintList:function(){
let blueStorageData = wx.getStorageSync('blueData');//获取打印机设定的缓存数据
if(blueStorageData){
this.setData({
wlVal:blueStorageData.goods_printer,
xVal:blueStorageData.box_printer,
kbVal:blueStorageData.pallet_printer
})
}
},
addPrintList:function(){
wx.setStorageSync("blueData",{
goods_printer:this.data.wlVal,
box_printer:this.data.xVal,
pallet_printer:this.data.kbVal
})
this.cancelFun()
},
cancelFun:function(){
wx.navigateBack()
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
......
<view class="change-warehouse-view width-854px nav-view borderBox"> <nav-c>
<nav-c></nav-c> <view class="change-warehouse-view width-854px nav-view borderBox" bindtap="hiddenInput">
<view class="change-warehouse-wrapper"> <view class="change-warehouse-wrapper">
<view class="select-view Bflex aic"> <view class="select-view Bflex aic">
<text>物料标签</text> <text>物料标签</text>
<view class="select-input borderBox"> <view class="select-input borderBox" catchtap="changeIsShow" data-type="0">
<image class="arrow-down" src="../../res/img/nav-arrow-down.png"></image> <image class="arrow-down" src="../../res/img/nav-arrow-down.png"></image>
<view class="select-items"> <view class="text ellipsis">{{wlVal}}</view>
<view class="select-item"> <view class="select-items" wx:if="{{isShowWl}}">
A号仓储 <block wx:if="{{!list.length}}">
</view> <view class="select-item">
<view class="select-item"> 暂无数据
A号仓储 </view>
</view> </block>
<view class="select-item"> <block wx:else>
A号仓储 <view class="select-item" wx:for="{{list}}" wx:key="index" data-item="{{item}}" catchtap="choosePrint" data-type="0">
</view> {{item}}
<view class="select-item"> </view>
A号仓储 </block>
</view>
<view class="select-item">
A号仓储
</view>
<view class="select-item">
A号仓储
</view>
<view class="select-item">
A号仓储
</view>
<view class="select-item">
A号仓储
</view>
<view class="select-item">
A号仓储
</view> </view>
</view> </view>
</view> </view>
</view> <view class="select-view Bflex aic">
<view class="select-view Bflex aic"> <text>箱标签</text>
<text>箱标签</text> <view class="select-input borderBox" catchtap="changeIsShow" data-type="1">
<view class="select-input borderBox"> <image class="arrow-down" src="../../res/img/nav-arrow-down.png"></image>
<image class="arrow-down" src="../../res/img/nav-arrow-down.png"></image> <view class="text ellipsis">{{xVal}}</view>
<view class="select-items"> <view class="select-items" wx:if="{{isShowX}}">
<view class="select-item"> <block wx:if="{{!list.length}}">
A号仓储 <view class="select-item">
</view> 暂无数据
<view class="select-item"> </view>
A号仓储 </block>
</view> <block wx:else>
<view class="select-item"> <view class="select-item" wx:for="{{list}}" wx:key="index" data-item="{{item}}" catchtap="choosePrint" data-type="1">
A号仓储 {{item}}
</view> </view>
<view class="select-item"> </block>
A号仓储
</view>
<view class="select-item">
A号仓储
</view>
<view class="select-item">
A号仓储
</view>
<view class="select-item">
A号仓储
</view>
<view class="select-item">
A号仓储
</view>
<view class="select-item">
A号仓储
</view> </view>
</view> </view>
</view> </view>
</view> <view class="select-view Bflex aic">
<view class="select-view Bflex aic"> <text>卡板标签</text>
<text>卡板标签</text> <view class="select-input borderBox" catchtap="changeIsShow" data-type="2">
<view class="select-input borderBox"> <image class="arrow-down" src="../../res/img/nav-arrow-down.png"></image>
<image class="arrow-down" src="../../res/img/nav-arrow-down.png"></image> <view class="text ellipsis">{{kbVal}}</view>
<view class="select-items"> <view class="select-items" wx:if="{{isShowKb}}">
<view class="select-item"> <block wx:if="{{!list.length}}">
A号仓储 <view class="select-item">
</view> 暂无数据
<view class="select-item"> </view>
A号仓储 </block>
</view> <block wx:else>
<view class="select-item"> <view class="select-item" wx:for="{{list}}" wx:key="index" data-item="{{item}}" catchtap="choosePrint" data-type="2">
A号仓储 {{item}}
</view> </view>
<view class="select-item"> </block>
A号仓储
</view>
<view class="select-item">
A号仓储
</view>
<view class="select-item">
A号仓储
</view>
<view class="select-item">
A号仓储
</view>
<view class="select-item">
A号仓储
</view>
<view class="select-item">
A号仓储
</view> </view>
</view> </view>
</view> </view>
</view> <view class="btn-group Bflex">
<view class="btn-group Bflex"> <view class="btn-item btn blue-btn " bindtap="addPrintList">
<view class="btn-item btn blue-btn "> 确定
确定 </view>
</view> <view class="btn-item btn disbled-btn borderBox" bindtap="cancelFun">
<view class="btn-item btn disbled-btn borderBox"> 取消
取消 </view>
</view> </view>
</view>
</view>
</view> </view>
</view> </nav-c>
\ No newline at end of file \ No newline at end of file
...@@ -49,7 +49,7 @@ page { ...@@ -49,7 +49,7 @@ page {
padding:11px 0; padding:11px 0;
max-height: 100px; max-height: 100px;
overflow-y: auto; overflow-y: auto;
display: none; z-index: 2;
} }
.select-item{ .select-item{
padding:4px 23px 8px; padding:4px 23px 8px;
...@@ -67,4 +67,11 @@ page { ...@@ -67,4 +67,11 @@ page {
} }
.disbled-btn{ .disbled-btn{
margin-left: 80px; margin-left: 80px;
}
.select-input .text{
height:35px;
width:320px;
padding:0 10px;
line-height: 35px;
} }
\ No newline at end of file
// pages/receivinggoods/receivinggoods.js // pages/receivinggoods/receivinggoods.js
const PrinterJobs = require('../../utils/printerjobs');
import { import {
getData getData
} from '../../utils/axios.js'; } from '../../utils/axios.js';
...@@ -40,12 +41,427 @@ Page({ ...@@ -40,12 +41,427 @@ Page({
xiangIndex:0,//装新箱或者合箱 xiangIndex:0,//装新箱或者合箱
orderNum:"",//箱号 orderNum:"",//箱号
orderZl:"",//重量 orderZl:"",//重量
blueNameDefault:"L51 BT Printer",//默认连接蓝牙的名字
wlDeviceId:"",//物料标签的蓝牙deviceId
xDeviceId:"",//箱标签的蓝牙deviceId
},
initBlue:function(type,data){
//type 1 表示物料标签 2表示 箱标签 data为需要打印的数据
let blueStorageData = wx.getStorageSync('blueData');//获取打印机设定的缓存数据
if(blueStorageData){
//请求接口获取设定的数据然后缓存起来
let wlBlueName = blueStorageData.goods_printer || this.data.blueNameDefault;//物料打印机的名称
let xBlueName = blueStorageData.box_printer ||this.data.blueNameDefault;//箱打印机的名称
if(type == 1){
if(this.data.wlDeviceId){
console.log('重新连接')
//重新连接
this.createBLEConnectionWithDeviceId(type,this.data.wlDeviceId,data)
}else{
console.log(wlBlueName)
this.openBluetoothAdapter(type,wlBlueName,data)
}
}else{
if(this.data.xDeviceId){
console.log('重新连接')
//重新连接
this.createBLEConnectionWithDeviceId(type,this.data.xDeviceId,data)
}else{
this.openBluetoothAdapter(type,xBlueName,data)
}
}
}else{
wx.showModal({
title: '提示',
content: '请先绑定指定打印机',
showCancel: false
})
}
},
//初始化蓝牙设备
openBluetoothAdapter:function(type,name,data){
var that = this;
if (wx.openBluetoothAdapter) {
wx.showLoading({
title: '打印设备连接中',
mask:true
})
wx.openBluetoothAdapter({
success: function(res) {
/* 获取本机的蓝牙状态 */
setTimeout(() => {
that.getBluetoothAdapterState(type,name,data)
}, 1000)
},
fail: function(res) {
// 初始化失败
wx.hideLoading()
if (res.errCode === 10001) {
wx.showModal({
title: '错误',
content: '未找到打印设备, 请打开蓝牙后重试。',
showCancel: false
})}else{
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
}
})
} else {
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
return
}
},
getBluetoothAdapterState(type,name,data) {
let that = this;
wx.getBluetoothAdapterState({
success: function(res) {
that.startBluetoothDevicesDiscovery(type,name,data)
},
fail(res) {
console.log(res);
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
},
startBluetoothDevicesDiscovery(type,name,data) {
var that = this;
setTimeout(() => {
wx.startBluetoothDevicesDiscovery({
success: function(res) {
console.log(res)
/* 获取蓝牙设备列表 */
that.getBluetoothDevices(type,name,data)
},
fail(res) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
}, 1000)
},
getBluetoothDevices(type,name,data) {
let that = this;
setTimeout(() => {
wx.getBluetoothDevices({
services: [],
allowDuplicatesKey: false,
interval: 0,
success: function(res) {
console.log(res)
if (res.devices.length > 0) {
if (JSON.stringify(res.devices).indexOf(name) !== -1) {
for (let i = 0; i < res.devices.length; i++) {
if (res.devices[i].name == name || res.devices[i].localName == name) {
/* 根据指定的蓝牙设备名称匹配到deviceId */
setTimeout(() => {
that.connectTO(res.devices[i].deviceId,type,data);
}, 2000);
};
};
} else {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '找不到指定蓝牙设备, 请重试。',
showCancel: false
})
}
} else {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '找不到指定蓝牙设备, 请重试。',
showCancel: false
})
}
},
fail(res) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '获取蓝牙设备列表失败, 请重试。',
showCancel: false
})
console.log(res, '获取蓝牙设备列表失败=====')
}
})
}, 2000)
},
connectTO(deviceId,type,data,isConnectionWithDeviceId) {
//isConnectionWithDeviceId 是否是重新连接
let that = this;
let str="";
wx.createBLEConnection({
deviceId: deviceId,
success: function(res) {
/* 4.获取连接设备的service服务 */
if(type == 1){
str = "wlDeviceId";
that.setData({
wlDeviceId: deviceId
})
}else{
str = "xDeviceId";
that.setData({
xDeviceId : deviceId
})
}
wx.setStorageSync(str,deviceId)
that.getBLEDeviceServices(deviceId,type,data);
wx.stopBluetoothDevicesDiscovery({
success: function(res) {
console.log(res, '停止搜索')
},
fail(res) {
}
})
},
fail: function(res) {
console.log(res);
if(!isConnectionWithDeviceId){
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}else{
if(type == 1){
wx.removeStorageSync({
key: 'wlDeviceId',
});
that.setData({
wlDeviceId:""
})
}else{
wx.removeStorageSync({
key: 'xDeviceId',
})
that.setData({
xDeviceId:""
})
}
if(res.errCode == -1){
//表示需要断开后再连接
wx.closeBLEConnection({
deviceId,
success (res) {
that.initBlue(type,data);
},
fail(res){
wx.hideLoading()
wx.showModal({
title: '错误',
content: '请关闭蓝牙重新打开',
showCancel: false
}) }
})
}else{
that.initBlue(type,data);
}
}
}
})
}, },
getBLEDeviceServices(deviceId,type,data) {
let that = this;
// setTimeout(() => {
wx.getBLEDeviceServices({
deviceId: deviceId,
success: function(res) {
/* 获取连接设备的所有特征值 */
for (let i = 0; i < res.services.length; i++) {
if (res.services[i].isPrimary) {
that.getBLEDeviceCharacteristics(deviceId, res.services[i].uuid,type,data)
break
}
}
},
fail: (res) => {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
// }, 2000)
},
getBLEDeviceCharacteristics(deviceId, serviceId,type,data) {
let that = this;
// setTimeout(() => {
wx.getBLEDeviceCharacteristics({
deviceId: deviceId,
serviceId: serviceId,
success: function(res) {
console.log('getBLEDeviceCharacteristics success', res.characteristics)
for (let i = 0; i < res.characteristics.length; i++) {
let item = res.characteristics[i]
if (item.properties.write) {
that.writeBLECharacteristicValue(deviceId,serviceId, item.uuid,data,type)
}
if (item.properties.notify || item.properties.indicate) {
wx.notifyBLECharacteristicValueChange({
deviceId,
serviceId,
characteristicId: item.uuid,
state: true,
})
}
}
},
fail: function(res) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
// }, 1000)
},
///重新连接
createBLEConnectionWithDeviceId(type,deviceId,data) {
// 小程序在之前已有搜索过某个蓝牙设备,并成功建立连接,可直接传入之前搜索获取的 deviceId 直接尝试连接该设备
let that = this;
if (!deviceId) {
return
}
wx.showLoading({
title: '打印设备连接中',
mask:true
})
console.log('createBLEConnectionWithDeviceId', type + ':' + deviceId)
wx.openBluetoothAdapter({
success: (res) => {
console.log('openBluetoothAdapter success', res)
that.connectTO(deviceId,type,data,true)
},
fail: (res) => {
console.log('openBluetoothAdapter fail', res)
if (res.errCode === 10001) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '未找到打印设备, 请打开蓝牙后重试。',
showCancel: false
})
}else{
if(type == 1){
wx.removeStorageSync({
key: 'wlDeviceId',
});
that.setData({
wlDeviceId:""
})
}else{
wx.removeStorageSync({
key: 'xDeviceId',
})
that.setData({
xDeviceId:""
})
}
that.initBlue(type,data);
}
}
})
},
writeBLECharacteristicValue(deviceId,services, writeId,data,type){
let printerJobs = new PrinterJobs();
printerJobs
.print(data);
let buffer = printerJobs.buffer();
console.log(data)
const maxChunk = 20;
const delay = 20;
for (let i = 0, j = 0, length = buffer.byteLength; i < length; i += maxChunk, j++) {
let subPackage = buffer.slice(i, i + maxChunk <= length ? (i + maxChunk) : length);
setTimeout(function(){
wx.writeBLECharacteristicValue({
// 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
deviceId: deviceId,
// 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取
serviceId: services,
// 这里的 characteristicId 需要在上面的 getBLEDeviceCharacteristics 接口中获取
characteristicId: writeId,//第二步写入的特征值
// 这里的value是ArrayBuffer类型
value: subPackage,
success: function (res) {
console.log("写入成功");
if(i+maxChunk>=length){
wx.hideLoading();
wx.closeBLEConnection({//安卓如果不断开导致重新连接失败 ios断开打印不了 这里只针对安卓平板开发,所以不做兼容性
deviceId,
success (res) {
console.log(res)
}
})
}
},
fail: function () {
wx.hideLoading();
console.log('写入失败');
wx.showModal({
title: '错误',
content: '打印失败, 请重试。',
showCancel: false
})
},
complete:function(){
console.log("调用结束");
}
})
}, j * delay);
}
},
onUnload:function(){
wx.closeBluetoothAdapter();
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
const wlDeviceId = wx.getStorageSync('wlDeviceId');
const xDeviceId = wx.getStorageSync('xDeviceId');
this.setData({
wlDeviceId,
xDeviceId
})
this.getMaskList(); this.getMaskList();
this.getCountryList() this.getCountryList()
}, },
...@@ -735,8 +1151,34 @@ Page({ ...@@ -735,8 +1151,34 @@ Page({
}) })
}, },
saveSaleTask:function(e){ saveSaleTask:function(e){
let str = "! 0 200 200 400 1 \n"+
"B QR 200 0 M 2 2 10 \n"+
"MA,QR code :'1','2','3','4'\n"+
"ENDQR\n"+
"TEXT 55 1 380 20 卡板号: \n"+
"TEXT 55 1 380 60 内含箱数: \n"+
"TEXT 55 1 380 100 净重: \n"+
"TEXT 55 1 480 20 卡板号 \n"+
"TEXT 55 1 480 60 内含箱数 \n"+
"TEXT 55 1 480 100 净重 \n"+
"FORM \n"+
"PRINT\n"+"! 0 200 200 400 1 \n"+
"B QR 200 0 M 2 2 10 \n"+
"MA,QR code :'1','2','3','4'\n"+
"ENDQR\n"+
"TEXT 55 1 380 20 卡板号: \n"+
"TEXT 55 1 380 60 内含箱数: \n"+
"TEXT 55 1 380 100 净重: \n"+
"TEXT 55 1 480 20 卡板号 \n"+
"TEXT 55 1 480 60 内含箱数 \n"+
"TEXT 55 1 480 100 净重 \n"+
"FORM \n"+
"PRINT";
//type为1表示生成上架任务 type为2表示装箱 //type为1表示生成上架任务 type为2表示装箱
let {type} = e.currentTarget.dataset; let {type} = e.currentTarget.dataset;
console.log(type)
this.initBlue(type,str)
return
let me = this; let me = this;
let obj = { let obj = {
"in_store_id": me.data.chooseOrder.in_store_id "in_store_id": me.data.chooseOrder.in_store_id
......
// pages/scanDelivery/scanDelivery.js // pages/scanDelivery/scanDelivery.js
import {
getData
} from '../../utils/axios.js';
import {
apis
} from '../../utils/api.js';
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
inputVal:"",
listArr:[],
}, },
/** /**
...@@ -14,7 +21,56 @@ Page({ ...@@ -14,7 +21,56 @@ Page({
onLoad: function (options) { onLoad: function (options) {
}, },
inputConfirm:function(e){
let {value} = e.detail ;
this.setData({
inputVal:value
})
this.getList()
},
getList:function(){
let me = this;
getData(apis.scan_out_store_list, 'post', {"pallet_box_sn":me.data.inputVal}, function(res) {
if (res.errcode === 0) {
let data = res.data;
me.setData({
listArr:data||[]
})
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, true,true)
},
fhFun:function(){
let arr = this.data.listArr;
let idArr = []
if(arr.length){
for(let i=0;i<arr.length;i++){
idArr.push(arr[i]['pick_task_detail_id'])
}
}
},
faAjax:function(arr){
let me = this;
getData(apis.deliver_goods, 'post', {"pick_task_detail_id":arr}, function(res) {
if (res.errcode === 0) {
me.getList()
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, true,true)
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
......
<nav-c title="扫描出库"> <nav-c title="扫描出库">
<view class="scan-delivery-view width-854px nav-view borderBox"> <view class="scan-delivery-view width-854px nav-view borderBox">
<view class="scan-delivery-wrapper "> <view class="scan-delivery-wrapper ">
<view class="view-top Bflex aic"> <view class="view-top Bflex aic">
<text class="desc">卡板号/箱号:</text> <text class="desc">卡板号/箱号:</text>
<input class="input input-border" placeholder="请输入用户名"></input> <input class="input input-border" bindconfirm="inputConfirm" value="{{inputVal}}"></input>
</view> </view>
<view class="table-view"> <view class="table-view">
<view class="scroll-view"> <view class="scroll-view">
<view class="data-table-view"> <view class="data-table-view">
<view class="data-table borderBox"> <view class="data-table borderBox">
<view class="head Bflex"> <view class="head Bflex">
<view class="td-1 td borderBox Iflex jcc aic"><text>操作</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>状态</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>卡板号</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>箱号</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>入仓单号 </text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>出库单号</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-58"><text>是否报关</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>确认人</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-125"><text>确认时间</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>仓库</text></view>
</view>
<view class="body">
<view class="body-data Bflex">
<view class="td-1 td borderBox Iflex jcc aic"><text>操作</text></view> <view class="td-1 td borderBox Iflex jcc aic"><text>操作</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>状态</text></view> <view class="td-2 td borderBox Iflex jcc aic"><text>状态</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>卡板号</text></view> <view class="td-2 td borderBox Iflex jcc aic td-119"><text>卡板号</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>箱号</text></view> <view class="td-2 td borderBox Iflex jcc aic td-119"><text>箱号</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>入仓单号 </text></view> <view class="td-2 td borderBox Iflex jcc aic td-119"><text>入仓单号</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>出库单号</text></view> <view class="td-2 td borderBox Iflex jcc aic td-119"><text>出库单号</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-58"><text>是否报关</text></view> <view class="td-2 td borderBox Iflex jcc aic td-58"><text>是否报关</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>确认人</text></view> <view class="td-2 td borderBox Iflex jcc aic"><text>确认人</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-125"><text>确认时间</text></view> <view class="td-2 td borderBox Iflex jcc aic td-125"><text>确认时间</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>仓库</text></view> <view class="td-2 td borderBox Iflex jcc aic"><text>仓库</text></view>
</view> </view>
<view class="body">
<block wx:if="{{!listArr.length}}">
<view class="body-data Bflex">
<view class="no-data-td ">暂无数据</view>
</view>
</block>
<block wx:else>
<view class="body-data Bflex" wx:for="{{listArr}}" wx:key="index">
<view class="td-1 td borderBox Iflex jcc aic"><text class="underline-text">
<block wx:if="{{item.confirm_time_cn == 1}}">取消确认</block>
<!-- <block wx:elif="{{item.confirm_time_cn == 1}}">
</block> -->
</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>
<block wx:if="{{item.confirm_time_cn == 0}}">未确认</block>
<block wx:elif="{{item.confirm_time_cn == 1}}">已确认</block>
</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>{{item.pallet_id_cn}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>{{item.box_id_cn}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>{{item.warehousing_sn}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>{{item.out_store_id}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-58"><text>
<block wx:if="{{item.is_apply_customs == 0}}">否</block>
<block wx:elif="{{item.is_apply_customs == 1}}">是</block></text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>{{item.confirm_user_id}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-125"><text>{{item.confirm_time_cn}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>{{item.store_id_cn}}</text></view>
</view>
</block>
</view>
</view> </view>
<view class="btn blue-btn fh-btn" bindtap="fhFun">发 货</view>
</view> </view>
<view class="btn blue-btn fh-btn">发 货</view>
</view>
</view>
</view> </view>
</view> </view>
</view> </view>
</view> </nav-c>
</nav-c> \ No newline at end of file
...@@ -15,7 +15,7 @@ Page({ ...@@ -15,7 +15,7 @@ Page({
if (this.data.token) { if (this.data.token) {
//登入 //登入
// wx.reLaunch({ // wx.reLaunch({
// url: '/pages/login/login' // url: '/pages/home/home'
// }); // });
wx.navigateTo({ wx.navigateTo({
url: '/pages/home/home' url: '/pages/home/home'
......
<nav-c title="系统设定">
<view class="system-setting-view width-854px nav-view borderBox"> <view class="system-setting-view width-854px nav-view borderBox">
<nav-c></nav-c>
<view class="system-setting-wrapper Bflex aic jcc"> <view class="system-setting-wrapper Bflex aic jcc">
<view class="items Bflex"> <view class="items Bflex">
<view class="item borderBox noMarginTop noMarginLeft c-FFF8F0"> <navigator class="item borderBox noMarginTop noMarginLeft c-FFF8F0" url="/pages/printer/printer">
打印机绑定 打印机绑定
</view> </navigator>
<view class="item borderBox noMarginTop "> <view class="item borderBox noMarginTop" >
</view> </view>
<view class="item borderBox noMarginLeft"> <view class="item borderBox noMarginLeft">
...@@ -22,4 +23,5 @@ ...@@ -22,4 +23,5 @@
</view> </view>
</view> </view>
</view> </view>
</view> </view>
\ No newline at end of file </nav-c>
\ No newline at end of file
...@@ -15,10 +15,24 @@ export const apis = { ...@@ -15,10 +15,24 @@ export const apis = {
update_receiving_status:in_store_url+'/in_store/update_receiving_status',//修改收货详情状态 update_receiving_status:in_store_url+'/in_store/update_receiving_status',//修改收货详情状态
delete_receiving:in_store_url+'/in_store/delete_receiving',//删除收货 delete_receiving:in_store_url+'/in_store/delete_receiving',//删除收货
save_sale_task:in_store_url+'/in_store/save_sale_task',//生成上架任务与装箱 save_sale_task:in_store_url+'/in_store/save_sale_task',//生成上架任务与装箱
store_printer_list:in_store_url+'/printer/store_printer_list',//添加打印机绑定列表
printer_list:in_store_url+"/printer/printer_list",//获取打印机列表
pallet_in_box_list:in_store_url+"/in_store/pallet_in_box_list",//根据卡板号查找箱子
get_box_info:in_store_url+"//get_box_info",//根据箱号查找箱子
put_on_pallet:in_store_url+"/in_store/put_on_pallet",//装卡板
// 入库结束 // 入库结束
//出库开始 //出库开始
pallet_box_list:out_store_url+'/out_store/pallet_box_list', pick_task_list:out_store_url+'/out_store/pick_task_list',//api_拣货任务明细
confirm_pick:out_store_url+'/out_store/confirm_pick',//api_拣货任务确认
pallet_box_list:out_store_url+'/out_store/pallet_box_list',//api_获取卡板箱子
pallet_active:out_store_url+"/out_store/pallet_active",//api_箱子装卡板
scan_out_store_list:out_store_url+"/out_store/scan_out_store_list",//扫描出库列表
confirm_out_store:out_store_url+"/out_store/confirm_out_store",//qpi_确认出库
cancel_out_store:out_store_url+"/out_store/cancel_out_store",//api_取消出库
deliver_goods:out_store_url+"/out_store/deliver_goods",//api_发货
//出库结束 //出库结束
get_store_list:in_store_url+"/store_account/get_store_list",//获取仓库列表 get_store_list:in_store_url+"/store_account/get_store_list",//获取仓库列表
change_store:in_store_url+'/store_account/change_store',//变更仓库 change_store:in_store_url+'/store_account/change_store',//变更仓库
} }
\ No newline at end of file
const app = getApp()
const axios = (url, type, params, callBack, loading, header) => { const axios = (url, type, params, callBack, loading, header) => {
let tokenInvalid; let tokenInvalid;
wx.request({ wx.request({
...@@ -29,6 +30,8 @@ const axios = (url, type, params, callBack, loading, header) => { ...@@ -29,6 +30,8 @@ const axios = (url, type, params, callBack, loading, header) => {
wx.removeStorageSync('access_token'); wx.removeStorageSync('access_token');
wx.removeStorageSync('userInfo'); wx.removeStorageSync('userInfo');
wx.removeStorageSync('userId'); wx.removeStorageSync('userId');
wx.removeStorageSync('storeInfo');
app.globalData.storeInfo = "";
wx.reLaunch({ wx.reLaunch({
url: '/pages/login/login' url: '/pages/login/login'
}); });
......
const PrinterJobs = require('printerjobs');
let deviceName = "L51 BT Printer";
let deviceId = "";
let connectedDeviceId = "";
let services = [];
let notifyCharacteristicsId = ""
let _deviceId ="";
let _serviceId="";
let _characteristicId = "";
function openBluetoothAdapter(){
console.log(11)
if (wx.openBluetoothAdapter) {
wx.openBluetoothAdapter({
success: function(res) {
/* 获取本机的蓝牙状态 */
setTimeout(() => {
getBluetoothAdapterState()
}, 1000)
},
fail: function(err) {
// 初始化失败
}
})
} else {
}
}
function getBluetoothAdapterState() {
// var that = this;
// that.toastTitle = '检查蓝牙状态'
wx.getBluetoothAdapterState({
success: function(res) {
startBluetoothDevicesDiscovery()
},
fail(res) {
console.log(res)
}
})
}
function startBluetoothDevicesDiscovery() {
// var that = this;
setTimeout(() => {
wx.startBluetoothDevicesDiscovery({
success: function(res) {
console.log(res)
/* 获取蓝牙设备列表 */
getBluetoothDevices()
},
fail(res) {
}
})
}, 1000)
}
function getBluetoothDevices() {
console.log(111)
setTimeout(() => {
wx.getBluetoothDevices({
services: [],
allowDuplicatesKey: false,
interval: 0,
success: function(res) {
if (res.devices.length > 0) {
if (JSON.stringify(res.devices).indexOf(deviceName) !== -1) {
for (let i = 0; i < res.devices.length; i++) {
if (deviceName === res.devices[i].name) {
/* 根据指定的蓝牙设备名称匹配到deviceId */
deviceId = res.devices[i].deviceId;
setTimeout(() => {
connectTO();
}, 2000);
};
};
} else {
}
} else {
}
},
fail(res) {
console.log(res, '获取蓝牙设备列表失败=====')
}
})
}, 2000)
}
function connectTO() {
wx.createBLEConnection({
deviceId: deviceId,
success: function(res) {
connectedDeviceId = deviceId;
/* 4.获取连接设备的service服务 */
getBLEDeviceServices();
wx.stopBluetoothDevicesDiscovery({
success: function(res) {
console.log(res, '停止搜索')
},
fail(res) {
}
})
},
fail: function(res) {
}
})
}
function getBLEDeviceServices() {
setTimeout(() => {
wx.getBLEDeviceServices({
deviceId: connectedDeviceId,
success: function(res) {
services = res.services
/* 获取连接设备的所有特征值 */
// getBLEDeviceCharacteristics()
for (let i = 0; i < res.services.length; i++) {
if (res.services[i].isPrimary) {
getBLEDeviceCharacteristics(deviceId, res.services[i].uuid)
return
}
}
},
fail: (res) => {
}
})
}, 2000)
}
function getBLEDeviceCharacteristics(deviceId, serviceId) {
setTimeout(() => {
wx.getBLEDeviceCharacteristics({
deviceId: deviceId,
serviceId: serviceId,
success: function(res) {
console.log('getBLEDeviceCharacteristics success', res.characteristics)
for (let i = 0; i < res.characteristics.length; i++) {
let item = res.characteristics[i]
if (item.properties.write) {
_deviceId = deviceId
_serviceId = serviceId
_characteristicId = item.uuid
writeBLECharacteristicValue()
}
if (item.properties.notify || item.properties.indicate) {
wx.notifyBLECharacteristicValueChange({
deviceId,
serviceId,
characteristicId: item.uuid,
state: true,
})
}
}
// console.log(res)
// for (var i = 0; i < res.characteristics.length; i++) {
// if ((res.characteristics[i].properties.notify || res.characteristics[i].properties.indicate) &&
// (res.characteristics[i].properties.read && res.characteristics[i].properties.write)) {
// console.log(res.characteristics[i].uuid, '蓝牙特征值 ==========')
// /* 获取蓝牙特征值 */
// notifyCharacteristicsId = res.characteristics[i].uuid
// // 启用低功耗蓝牙设备特征值变化时的 notify 功能
// // that.notifyBLECharacteristicValueChange()
// }
// }
},
fail: function(res) {
}
})
}, 1000)
}
function writeBLECharacteristicValue() {
let printerJobs = new PrinterJobs();
let str = "! 0 200 200 400 1 \n"+
"B QR 200 0 M 2 2 10 \n"+
"MA,QR code :'1','2','3','4'\n"+
"ENDQR\n"+
"TEXT 55 1 380 20 卡板号: \n"+
"TEXT 55 1 380 60 内含箱数: \n"+
"TEXT 55 1 380 100 净重: \n"+
"TEXT 55 1 480 20 卡板号 \n"+
"TEXT 55 1 480 60 内含箱数 \n"+
"TEXT 55 1 480 100 净重 \n"+
"FORM \n"+
"PRINT"
printerJobs
.print(str)
// await printerJobs.printQRCode('http://hqn.fun:9999/code.png');
// .print('2018年12月5日17:34')
// .print(printerUtil.fillLine())
// .setAlign('ct')
// .setSize(2, 2)
// .print('#20饿了么外卖')
// .setSize(1, 1)
// .print('切尔西Chelsea')
// .setSize(2, 2)
// .print('在线支付(已支付)')
// .setSize(1, 1)
// .print('订单号:5415221202244734')
// .print('下单时间:2017-07-07 18:08:08')
// .setAlign('lt')
// .print(printerUtil.fillAround('一号口袋'))
// .print(printerUtil.inline('意大利茄汁一面 * 1', '15'))
// .print(printerUtil.fillAround('其他'))
// .print('餐盒费:1')
// .print('[赠送康师傅冰红茶] * 1')
// .print(printerUtil.fillLine())
// .setAlign('rt')
// .print('原价:¥16')
// .print('总价:¥16')
// .setAlign('lt')
// .print(printerUtil.fillLine())
// .print('备注')
// .print("无")
// .print(printerUtil.fillLine())
// .println();
let buffer = printerJobs.buffer();
console.log('ArrayBuffer', 'length: ' + buffer.byteLength, ' hex: ' + ab2hex(buffer));
// 1.并行调用多次会存在写失败的可能性
// 2.建议每次写入不超过20字节
// 分包处理,延时调用
const maxChunk = 100;
const delay = 100;
for (let i = 0, j = 0, length = buffer.byteLength; i < length; i += maxChunk, j++) {
let subPackage = buffer.slice(i, i + maxChunk <= length ? (i + maxChunk) : length);
setTimeout(_writeBLECharacteristicValue, j * delay, subPackage);
}
}
function _writeBLECharacteristicValue(buffer) {
// 向蓝牙设备发送一个0x00的16进制数据
wx.writeBLECharacteristicValue({
deviceId: _deviceId,
serviceId: _serviceId,
characteristicId:_characteristicId,
value: buffer,
success:function(){
console.log('写入成功')
},
complete:function(res){
console.log(res)
},
fail:function(res){
console.log(res)
}
})
}
// ArrayBuffer转16进度字符串示例
function ab2hex(buffer) {
const hexArr = Array.prototype.map.call(
new Uint8Array(buffer),
function (bit) {
return ('00' + bit.toString(16)).slice(-2)
}
)
return hexArr.join(',')
}
module.exports = {
openBluetoothAdapter
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment