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

View File

@ -11,11 +11,11 @@
</u-row> </u-row>
<u-row justify="between" custom-style="margin-top: 20rpx;"> <u-row justify="between" custom-style="margin-top: 20rpx;">
<u-col span="6" align="center"> <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> <view class="mt-20 clr-sub font-28">总件数</view>
</u-col> </u-col>
<u-col span="6" align="center"> <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> <view class="mt-20 clr-sub font-28">总重量(KG)</view>
</u-col> </u-col>
</u-row> </u-row>
@ -37,12 +37,23 @@
}, },
userInfo() { userInfo() {
return this.$store.getters.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: { props: {
value: { list: {
default () { default () {
return { } return []
} }
} }
}, },

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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