tianyi 1 day ago
parent
commit
fa19d8a338
  1. 100
      components/print/index.js
  2. 6
      components/tab-bar/delivery.vue

100
components/print/index.js

@ -6,12 +6,41 @@
import Bluetooth from '@/components/print/bluetooth.js'
let bluetooth = new Bluetooth();
let isPrint= false
let data1 = {}
export default {
getData() {
var that = this;
if(uni.getStorageSync('bluetoothDeviceId')){
let id = uni.getStorageSync('bluetoothDeviceId')
this.bindViewTap(id,false)
const baseUrl = getApp().globalData.mainurl
uni.request({
url: baseUrl + "/mall/order/detail/"+ getApp().globalData.printData[0].order_id,
data: {},
method:'GET',
header: {
"content-type": 'application/x-www-form-urlencoded',
'accessToken':uni.getStorageSync('hiver_token')
},
success: function(res) {
console.log('连接成功了!!!!!!!!!!!!',res)
if (res.data.code == 200) {
data1 = res.data.result
that.bindViewTap(id,false)
} else {
uni.showToast({
title: res.data.message,
icon: 'none'
});
return;
}
uni.hideLoading();
},
fail: function(err) {
console.log(err)
uni.hideLoading();
}
})
}else{
uni.showModal({
title: '提示',
@ -74,66 +103,53 @@
},
//写入控制命令
async writeBLECharacteristicValue() {
let data = {
"settled_name": "#0112配送",
"detail": {
"total_amount": "137.00",
"other_amount": "0.00",
"discount_amount": "0.00",
"actual_amount": "137.00",
"order_sn": "20220512165337",
"goods_count": 3,
"order_time": "2022-05-12 16:53:00",
"supplier_id": 1
},
"code": "https://www.oulaisong.com/purchase?id=8",
"list": [{
"id": 8,
"goods_name": "红烧带鱼",
"article_number": "1",
'sum_price':'16.00'
}, {
"id": 9,
"goods_name": "女童外套",
"article_number": "2",
console.log("走到这里已经拿到数据了",data1)
if(data1.receiverName == null){
console.log("22222")
data1.receiverName = "***"
}
if(data1.receiverAddress == null){
console.log("3333")
data1.receiverAddress = '***'
}
if(data1.deliveryInfo == null){
"sum_price": "34.00"
}, {
"id": 10,
"goods_name": "25",
"article_number": "3",
"sum_price": "3.00"
}]
data1.deliveryInfo = {
mustFinishTime:"***"
}
console.log("111111111")
}
let printerJobs = new PrinterJobs();
printerJobs.setAlign('ct').setSize(2, 2).setLineSpacing(80).print('#0112配送')
.setAlign('lt').setSize(1, 1).setLineSpacing(40).print('预计时间:2026-02-01 13:41:00')
.setAlign('lt').setSize(1, 1).setLineSpacing(40).print('七里香快餐明珠店')
printerJobs.setAlign('ct').setSize(2, 2).setLineSpacing(80).print(data1.numberCode + (data1.deliveryType == 1?'配送':'自取'))
.setAlign('lt').setSize(1, 1).setLineSpacing(40).print('预计时间:'+ data1.deliveryInfo == null?'暂无':data1.deliveryInfo.mustFinishTime)
.setAlign('lt').setSize(1, 1).setLineSpacing(40).print(data1.shopName)
.print(printerUtil.fillLine('-', 1, 50))
.setAlign('lt').setSize(2, 2).setLineSpacing(80).print('王先生')
.setAlign('lt').setSize(1, 1).setLineSpacing(40).print('联系电话: *******0775')
.setAlign('lt').setSize(2, 2).setLineSpacing(80).print('地址:黑背生东川建设集团有限公司黑恶生运河区****')
.setAlign('lt').setSize(2, 2).setLineSpacing(80).print(data1.receiverName == null?'暂无':data1.receiverName)
.setAlign('lt').setSize(1, 1).setLineSpacing(40).print('联系电话: '+data1.receiverPhone)
.setAlign('lt').setSize(2, 2).setLineSpacing(80).print('地址:'+(data1.receiverAddress == null?'暂无':data1.receiverAddress))
.setAlign('lt').setSize(1, 1).setLineSpacing(40).print('为保护隐私,顾客电话及地址已被隐藏,您可登录商家端或骑手端查看')
.print(printerUtil.fillLine('-', 1, 50));
for (var i = 0; i < data.list.length; i++) {
printerJobs.setAlign('lt').setSize(1, 1).setLineSpacing(40).print(data.list[i].goods_name)
for (var i = 0; i < data1.goodsList.length; i++) {
printerJobs.setAlign('lt').setSize(1, 1).setLineSpacing(40).print(data1.goodsList[i].productName)
let setLineSpacing = 40
printerJobs.setLineSpacing(setLineSpacing).print(printerUtil.inlineArr([{
'text': 'X' + data.list[i].article_number,
'text': 'X' + data1.goodsList[i].quantity,
'width': 20,
}, {
'text': data.list[i].sum_price,
'text': data1.goodsList[i].price,
'width': 10,
}], 1, 50));
}
printerJobs.print(printerUtil.fillLine('-', 1, 50))
.setAlign('lt').setSize(1, 1).setLineSpacing(40).print('配送费:1圆')
.setAlign('lt').setSize(1, 1).setLineSpacing(40).print('合计金额:17圆')
.setAlign('lt').setSize(1, 1).setLineSpacing(40).print('配送费:'+ data1.deliveryFee)
.setAlign('lt').setSize(1, 1).setLineSpacing(40).print('合计金额:'+ data1.totalAmount)
.print(printerUtil.fillLine('-', 1, 50))
.setAlign('lt').setSize(1, 1).setLineSpacing(40).print('商品取到后,如有任何商品问题,请及时联系商家和平台,客服将为您服务,客服电话15533910775,谢谢您的惠顾')
.println();

6
components/tab-bar/delivery.vue

@ -238,7 +238,7 @@
}
that.NB.sendRequest(url, {
orderId:item.id
}, true, 'post', 'application/json').then((res) => {
}, false, 'post', 'application/x-www-form-urlencoded').then((res) => {
if (res.code == 200) {
that.getList()
} else {
@ -252,7 +252,7 @@
});
},
getGroupOrders(id){
this.NB.sendRequest("/mall/order/selectAllOrderByOrderId/"+id, {}, true, 'GET', 'application/json').then((res) => {
this.NB.sendRequest("/mall/order/selectAllOrderByOrderId/"+id, {}, false, 'GET', 'application/json').then((res) => {
if (res.code == 200) {
this.tuanzhangOrder = res.result;
this.$refs.pintuanPopup.open()
@ -287,7 +287,7 @@
}else{
url = "/mall/order/page"
}
that.NB.sendRequest(url, this.currentIndex == 11?data : this.searchForm, true, 'POST', 'application/json').then((res) => {
that.NB.sendRequest(url, this.currentIndex == 11?data : this.searchForm, false, 'POST', 'application/json').then((res) => {
if (res.code == 200) {
if (that.searchForm.pageNum == 1) {
that.orderList = res.result.records;

Loading…
Cancel
Save