This commit is contained in:
aihe 2024-05-10 09:25:24 +08:00
parent 2e99e87872
commit 2755a03bd8
8 changed files with 108 additions and 61 deletions

View File

@ -220,8 +220,10 @@
async initData() {
this.checkedGoodId = ''
let res = await apiService.getHotGoodsList({ customerCode: this.modelInfo.customerCode, pageSize: 5 })
debugger
this.hotGoods = transListKeyTitle({ valKey: 'goodsCode',titleKey: 'goodsName', list: [] })
let list = res.rows || []
// 截取前5个热门商品
list.splice(5, list.length - 5)
this.hotGoods = transListKeyTitle({ valKey: 'goodsCode',titleKey: 'goodsName', list })
},
handleCloseModal() {
this.$emit('update:show', false)

View File

@ -11,11 +11,11 @@
</u-row>
<u-row justify="between" custom-style="margin-top: 20rpx;">
<u-col span="6" align="center">
<view class="clr-prm font-34 font-weight">2129</view>
<view class="clr-prm font-34 font-weight">{{staticInfo.parcelQty}}</view>
<view class="mt-20 clr-sub font-28">总件数</view>
</u-col>
<u-col span="6" align="center">
<view class="clr-prm font-34 font-weight">2129</view>
<view class="clr-prm font-34 font-weight">{{staticInfo.billWeight}}</view>
<view class="mt-20 clr-sub font-28">总重量(KG)</view>
</u-col>
</u-row>
@ -37,12 +37,23 @@
},
userInfo() {
return this.$store.getters.userInfo
},
staticInfo(){
let data = {
parcelQty: 0,
billWeight: 0,
}
this.list.map(t=> {
data.parcelQty += t.parcelQty
data.billWeight += t.billWeight
})
return data
}
},
props: {
value: {
list: {
default () {
return { }
return []
}
}
},

View File

@ -26,7 +26,7 @@
</view>
<view class="blcok-white-noradius">
<bo-operator-tmp>
<bo-operator-tmp :list="resData.list">
<template v-slot:titleRight>
<button size="mini">查看历史发件</button>
</template>

View File

@ -16,7 +16,7 @@
</view>
<view class="blcok-white-noradius">
<bo-operator-tmp>
<bo-operator-tmp :list="resData.list">
<template v-slot:titleRight>
<button size="mini">查看历史到件</button>
</template>

View File

@ -26,7 +26,7 @@
</view>
<view class="blcok-white-noradius">
<bo-operator-tmp>
<bo-operator-tmp :list="resData.list">
<template v-slot:titleRight>
<button size="mini">查看历史发件</button>
</template>

View File

@ -23,7 +23,7 @@
</view>
<view class="blcok-white-noradius">
<bo-operator-tmp>
<bo-operator-tmp :list="resData.list">
<template v-slot:titleRight>
<button size="mini">查看历史发件</button>
</template>

View File

@ -22,6 +22,7 @@ export const getScanParams = (type, model = {})=> {
export const ansScanResponse = ({ res, title })=> {
let resItem = res?.data?.scanResult?.[0] || {}
resItem.data && ( Object.assign(resItem, { ...resItem.data }) )
let result = resItem?.result
let bl = false
if(result == "success") {

View File

@ -119,11 +119,11 @@ export default {
canvas_height: 240,
curTab: 0,
devices: [],
deviceId: 'dda',
deviceId: '',
serverList: [],
serviceId: 'dda',
serviceId: '',
characteristics: [],
characteristicId: 'dd'
characteristicId: ''
}
},
mounted () {
@ -136,7 +136,7 @@ export default {
},
openBluetoothAdapter () {
var _this = this
uni.openBluetoothAdapter({
uni?.openBluetoothAdapter?.({
complete (e) {
console.log(e);
if (!e.errCode) {
@ -154,6 +154,7 @@ export default {
discoveryPrinter () {
var _this = this
_this.devices = []
_this.curTab = 0
uni.startBluetoothDevicesDiscovery({
complete (e) {
console.log(e)
@ -280,26 +281,28 @@ export default {
})
})
},
// 发送二进制数据
// 打印-发送二进制数据
async writeBLECharacteristicValue(){
let errmsg = ''
if (!this.deviceId) {
showToast('请选择设备')
return
errmsg = '请选择设备'
}
if (!this.serviceId) {
showToast('请选择设备服务')
return
errmsg = '请选择设备服务'
}
if (!this.characteristicId) {
showToast('请选择特征值')
return
errmsg = '请选择特征值'
}
if(errmsg){
showToast(errmsg)
return
}
try{
let pic_res = await this.renderPic();
showToast('图片获取成功')
}catch(e){
showToast('图片获取失败')
}
let pic_res = await this.renderPic();
uni.showToast({
icon: 'none',
title: '图片获取成功'
})
let printerJobs = new PrinterJobs()
var arr = [{
title: '阿根廷车厘子',
@ -344,37 +347,63 @@ export default {
let buffer = printerJobs.buffer();
console.log('buffer>>>',buffer)
this.printbuffs(buffer)
},
printbuffs(buffer) {
// 1.并行调用多次会存在写失败的可能性
// 2.建议每次写入不超过20字节
// 分包处理,延时调用
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(this.printbuff, j * delay, subPackage);
showLoading('正在打印')
try{
await this.printbuffs(buffer)
hideLoading()
showToast('打印成功')
}catch(e){
hideLoading()
console.log('打印异常', e)
}
},
printbuffs(buffer) {
let _this = this
return new Promise(async (resolve, reject)=> {
// 1.并行调用多次会存在写失败的可能性
// 2.建议每次写入不超过20字节
// 分包处理,延时调用
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);
await new Promise((resolve)=> {
setTimeout(resolve, j * delay)
})
try{
await _this.printbuff(subPackage)
}catch(msg){
console.log("printbuffs:异常==", msg)
showToast('分段printbuff异常', msg)
return reject(msg)
}
}
resolve()
})
},
getImageInfo(params = {}) {
return new Promise((resolve)=> {
return new Promise((resolve, reject)=> {
uni.canvasGetImageData({
x: 0,
y: 0,
...params,
success(res) {
console.log("img====",res);
let data = util.zip_image(res)
console.log("zip====", data);
resolve(data);
if(res.data) {
let data = util.zip_image(res)
console.log("zip====", data);
resolve(data);
} else {
showToast('获取图片信息异常:getImageInfo')
reject('获取图片信息异常:getImageInfo')
}
}
})
})
},
renderPic() {
let filePath = 'http://oss-emis.tanex56.com/sapp/sdg/hdbg.png'
let filePath = 'http://oss-emis.tanex56.com/sapp/sdg/hdbg.png' // TODO
let that = this
return new Promise((resolve, reject)=> {
const cxt = uni.createCanvasContext(that.canvasId, that);
@ -401,24 +430,28 @@ export default {
},
printbuff(buffer) {
var _this = this
uni.writeBLECharacteristicValue({
// 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
deviceId: _this.deviceId,
// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
serviceId: _this.serviceId,
// 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
characteristicId: _this.characteristicId,
// 这里的value是ArrayBuffer类型
value: buffer,
success:(res)=> {
console.log('writeBLECharacteristicValue success', res.errMsg)
},
fail:(res)=> {
console.log('writeBLECharacteristicValue fail', res.errMsg)
},
complete (e) {
console.log('writeBLECharacteristicValue complete', e)
}
return new Promise((resolve, reject)=> {
uni.writeBLECharacteristicValue({
// 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
deviceId: _this.deviceId,
// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
serviceId: _this.serviceId,
// 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
characteristicId: _this.characteristicId,
// 这里的value是ArrayBuffer类型
value: buffer,
success:(res)=> {
console.log('writeBLECharacteristicValue success', res.errMsg)
resolve()
},
fail:(res)=> {
console.log('writeBLECharacteristicValue fail', res.errMsg)
reject(res.errMsg)
},
complete (e) {
console.log('writeBLECharacteristicValue complete', e)
}
})
})
}
}