Commit 55a52af1 by liangjianmin

js

parent b3022af1
...@@ -46,17 +46,16 @@ ...@@ -46,17 +46,16 @@
</template> </template>
<script> <script>
import { API } from '@/util/api.js'; import { API } from '@/util/api.js';
import zyGrid from '../../components/zy-grid/zy-grid.vue'; import zyGrid from '../../components/zy-grid/zy-grid.vue';
export default { export default {
data() { data() {
return { return {
is_login: false, is_login: false,
userInfo: {}, userInfo: {},
rawData: '', rawData: '',
gridList: [ gridList: [{
{
name: '快递回单上传', name: '快递回单上传',
iconfont: 'icon-a-juxing1', iconfont: 'icon-a-juxing1',
tips: '' tips: ''
...@@ -100,6 +99,7 @@ export default { ...@@ -100,6 +99,7 @@ export default {
name: '补打标签', name: '补打标签',
iconfont: 'icon-a-juxing4', iconfont: 'icon-a-juxing4',
tips: '' tips: ''
} }
] ]
}; };
...@@ -173,9 +173,9 @@ export default { ...@@ -173,9 +173,9 @@ export default {
components: { components: {
zyGrid zyGrid
} }
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import '../../assets/css/home/index.scss'; @import '../../assets/css/home/index.scss';
</style> </style>
...@@ -35,11 +35,15 @@ ...@@ -35,11 +35,15 @@
</template> </template>
<script> <script>
import { API } from '@/util/api.js'; import { API } from '@/util/api.js';
import { getPlatform } from '@/util/util.js'
const ToBase64 = require('../../util/base64gb2312.js');
const cpclExp = require('../../util/cpcl-exp.js');
export default { export default {
data() { data() {
return { return {
num: 1,
uuid: '', uuid: '',
deviceId: '', deviceId: '',
characteristics: '', characteristics: '',
...@@ -50,6 +54,8 @@ export default { ...@@ -50,6 +54,8 @@ export default {
items_erp_order_sn_pre: ['A单号', 'B单号', 'D单号'], items_erp_order_sn_pre: ['A单号', 'B单号', 'D单号'],
items_print_type: ['卡板', '散箱'], items_print_type: ['卡板', '散箱'],
traySelectOption: [], traySelectOption: [],
sendData64: '',
platform: 'android',
form: { form: {
erp_order_sn_pre: '', erp_order_sn_pre: '',
print_type: 1, print_type: 1,
...@@ -60,6 +66,7 @@ export default { ...@@ -60,6 +66,7 @@ export default {
}; };
}, },
created() { created() {
this.platform = getPlatform();
this.getTraySelectOption(); this.getTraySelectOption();
}, },
methods: { methods: {
...@@ -76,6 +83,8 @@ export default { ...@@ -76,6 +83,8 @@ export default {
this.form.tray_remark = this.traySelectOption[e.target.value].wstylt_id; this.form.tray_remark = this.traySelectOption[e.target.value].wstylt_id;
}, },
submit() { submit() {
this.openBluetoothAdapter();
return false;
if (!this.form.erp_order_sn_pre) { if (!this.form.erp_order_sn_pre) {
uni.showToast({ uni.showToast({
icon: 'error', icon: 'error',
...@@ -123,7 +132,7 @@ export default { ...@@ -123,7 +132,7 @@ export default {
return false; return false;
} }
this.request(API.printLabel, 'POST', this.form,true).then(res => { this.request(API.printLabel, 'POST', this.form, true).then(res => {
if (res.err_code === 0) { if (res.err_code === 0) {
this.openBluetoothAdapter(); this.openBluetoothAdapter();
} else { } else {
...@@ -204,6 +213,47 @@ export default { ...@@ -204,6 +213,47 @@ export default {
uni.hideLoading(); uni.hideLoading();
that.characteristics = res.characteristics[0].uuid; that.characteristics = res.characteristics[0].uuid;
console.log('服务功能', res); console.log('服务功能', res);
//包装数据
var data = "! 0 200 200 450 1\r\n" +
"T 8 0 10 10 入仓号:" + new Date().getTime() + "\r\n" +
"T 8 0 10 56 箱号:01/20\r\n" +
"T 8 0 10 96 时间:202201101627\r\n" +
"T 8 0 10 142 仓库代码:HK01\r\n" +
"B QR 290 10 M 2 U 10\r\n" +
"MA,SB\r\n" +
"ENDQR\r\n" +
"PRINT\r\n";
var arrayBuffer = uni.base64ToArrayBuffer(ToBase64.encode64gb2312(data))
that.sendData64 = arrayBuffer;
that.writeBLECharacteristicValue();
},
fail: res => {
console.log('失败', res);
}
});
},
writeBLECharacteristicValue() {
let that = this;
uni.writeBLECharacteristicValue({
deviceId: that.deviceId,
serviceId: that.uuid,
characteristicId: that.characteristics,
value: that.sendData64,
success(res) {
console.log('writeBLECharacteristicValue success', res.errMsg)
that.num++;
if (that.num < 3) {
uni.closeBLEConnection({
deviceId: that.deviceId,
success(res) {
console.log(res)
setTimeout(function() {
that.openBluetoothAdapter();
}, 1000);
}
})
} else {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '提交成功,打印中,请查看标签打印机', content: '提交成功,打印中,请查看标签打印机',
...@@ -212,16 +262,20 @@ export default { ...@@ -212,16 +262,20 @@ export default {
success: function(res) { success: function(res) {
if (res.confirm) { if (res.confirm) {
console.log('用户点击确定'); console.log('用户点击确定');
uni.closeBLEConnection({
deviceId: that.deviceId,
success(res) {
console.log(res)
}
})
} else if (res.cancel) { } else if (res.cancel) {
console.log('用户点击取消'); console.log('用户点击取消');
} }
} }
}); });
},
fail: res => {
console.log('失败', res);
} }
}); }
})
}, },
change(index, type) { change(index, type) {
if (type == 'erp_order_sn_pre') { if (type == 'erp_order_sn_pre') {
...@@ -247,9 +301,9 @@ export default { ...@@ -247,9 +301,9 @@ export default {
} }
} }
} }
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import '../../assets/css/tag/print.scss'; @import '../../assets/css/tag/print.scss';
</style> </style>
exports.val = "! 0 200 200 450 1\r\n" +
"T 8 0 10 10 入仓号:B00001\r\n" +
"T 8 0 10 56 箱号:01/20\r\n" +
"T 8 0 10 96 时间:202201101627\r\n" +
"T 8 0 10 142 仓库代码:HK01\r\n" +
"B QR 290 10 M 2 U 10\r\n" +
"MA,SB\r\n" +
"ENDQR\r\n" +
"PRINT\r\n";
...@@ -40,6 +40,24 @@ const request = (url = '', type = 'GET', param = {}, Loading) => { ...@@ -40,6 +40,24 @@ const request = (url = '', type = 'GET', param = {}, Loading) => {
}); });
} }
/**
* 平台判断
*/
const getPlatform = () => {
let platform = uni.getSystemInfoSync().platform
if (platform == 'ios') {
platform = 'ios';
} else if (platform == 'android') {
platform = 'android';
}
return platform;
}
module.exports = { module.exports = {
request request,
getPlatform
} }
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