This commit is contained in:
weipengfei 2024-05-30 18:06:30 +08:00
parent 2c55e72f39
commit 72ea67e75e
6 changed files with 32 additions and 26 deletions

0
config/config.js Normal file
View File

View File

@ -181,6 +181,10 @@ function searchDevices(address = '', vlist1 = [], vlist2 = []) {
address: n_address address: n_address
}); });
BAdapter.cancelDiscovery(); BAdapter.cancelDiscovery();
}else {
setTimeout(()=>{
BAdapter.cancelDiscovery();
}, 12*1000)
} }
}) })
@ -221,7 +225,7 @@ const connect = (mac_address, callback)=>{
callback(false); callback(false);
} }
bluetoothSocket.close(); bluetoothSocket.close();
}, 300) },200)
} }
//开始连接打印 //开始连接打印

View File

@ -2,8 +2,8 @@
"name" : "采购收银系统", "name" : "采购收银系统",
"appid" : "__UNI__D15002B", "appid" : "__UNI__D15002B",
"description" : "", "description" : "",
"versionName" : "1.0.0", "versionName" : "1.0.2",
"versionCode" : "100", "versionCode" : 102,
"transformPx" : false, "transformPx" : false,
"globalStyle" : { "globalStyle" : {
"navigationBarTextStyle" : "black", "navigationBarTextStyle" : "black",

View File

@ -1,5 +1,5 @@
<template> <template>
<web-view src="http://192.168.1.55:5178/" @message="onmessage"></web-view> <web-view :src="src" @message="onmessage"></web-view>
</template> </template>
<script setup> <script setup>
@ -11,6 +11,9 @@
import * as pos from "@/utils/EscPostUtils.js" import * as pos from "@/utils/EscPostUtils.js"
const vw = ref(null); // web-view const vw = ref(null); // web-view
const src = ref("https://erp-cashier.lihaink.cn/#/login");
// const src = ref("http://192.168.1.55:5178/#/");
onLoad(() => { onLoad(() => {
// #ifdef APP-PLUS // #ifdef APP-PLUS
// plus.screen.lockOrientation('default'); // // plus.screen.lockOrientation('default'); //

View File

@ -200,6 +200,10 @@ if (uni.restoreGlobal) {
address: n_address address: n_address
}); });
BAdapter.cancelDiscovery(); BAdapter.cancelDiscovery();
} else {
setTimeout(() => {
BAdapter.cancelDiscovery();
}, 12 * 1e3);
} }
}); });
} }
@ -228,14 +232,14 @@ if (uni.restoreGlobal) {
} }
setTimeout(() => { setTimeout(() => {
if (bluetoothSocket.isConnected()) { if (bluetoothSocket.isConnected()) {
formatAppLog("log", "at js_sdk/wangqingzhou311-android-blueTooth/searchDevices.js:216", "已连接=====", mac_address); formatAppLog("log", "at js_sdk/wangqingzhou311-android-blueTooth/searchDevices.js:220", "已连接=====", mac_address);
callback(true); callback(true);
} else { } else {
formatAppLog("log", "at js_sdk/wangqingzhou311-android-blueTooth/searchDevices.js:220", "未连接", mac_address); formatAppLog("log", "at js_sdk/wangqingzhou311-android-blueTooth/searchDevices.js:224", "未连接", mac_address);
callback(false); callback(false);
} }
bluetoothSocket.close(); bluetoothSocket.close();
}, 300); }, 200);
}; };
function print(mac_address, data, callback) { function print(mac_address, data, callback) {
if (!mac_address) { if (!mac_address) {
@ -255,7 +259,7 @@ if (uni.restoreGlobal) {
plus.android.importClass(device); plus.android.importClass(device);
bluetoothSocket = device.createInsecureRfcommSocketToServiceRecord(uuid); bluetoothSocket = device.createInsecureRfcommSocketToServiceRecord(uuid);
plus.android.importClass(bluetoothSocket); plus.android.importClass(bluetoothSocket);
formatAppLog("log", "at js_sdk/wangqingzhou311-android-blueTooth/searchDevices.js:249", "蓝牙", bluetoothSocket.isConnected()); formatAppLog("log", "at js_sdk/wangqingzhou311-android-blueTooth/searchDevices.js:253", "蓝牙", bluetoothSocket.isConnected());
if (!bluetoothSocket.isConnected()) { if (!bluetoothSocket.isConnected()) {
uni.showToast({ uni.showToast({
title: "正在打印小票, 请耐心等待", title: "正在打印小票, 请耐心等待",
@ -298,6 +302,7 @@ if (uni.restoreGlobal) {
__name: "index", __name: "index",
setup(__props) { setup(__props) {
const vw = vue.ref(null); const vw = vue.ref(null);
const src = vue.ref("http://192.168.1.55:5178/#/");
onLoad(() => { onLoad(() => {
plus.navigator.setFullscreen(true); plus.navigator.setFullscreen(true);
getLocationManager(() => { getLocationManager(() => {
@ -330,14 +335,14 @@ if (uni.restoreGlobal) {
title: "不可打印空内容", title: "不可打印空内容",
icon: "exception" icon: "exception"
}); });
formatAppLog("log", "at pages/index/index.vue:63", "打印内容", stringData); formatAppLog("log", "at pages/index/index.vue:66", "打印内容", stringData);
let deviceId = uni.getStorageSync("deviceId"); let deviceId = uni.getStorageSync("deviceId");
if (!deviceId) if (!deviceId)
return uni.showToast({ return uni.showToast({
title: "蓝牙未连接到T58打印机, 请检查是否已配对T58打印机", title: "蓝牙未连接到T58打印机, 请检查是否已配对T58打印机",
icon: "exception" icon: "exception"
}); });
formatAppLog("log", "at pages/index/index.vue:79", "打印机地址=>", deviceId); formatAppLog("log", "at pages/index/index.vue:82", "打印机地址=>", deviceId);
print(deviceId, stringData, () => { print(deviceId, stringData, () => {
uni.showToast({ uni.showToast({
title: "打印成功", title: "打印成功",
@ -348,7 +353,7 @@ if (uni.restoreGlobal) {
}; };
const onmessage = (e) => { const onmessage = (e) => {
var _a, _b, _c, _d, _e, _f, _g, _h; var _a, _b, _c, _d, _e, _f, _g, _h;
formatAppLog("log", "at pages/index/index.vue:97", "收到消息", e); formatAppLog("log", "at pages/index/index.vue:100", "收到消息", e);
if (((_b = (_a = e.detail) == null ? void 0 : _a.data[0]) == null ? void 0 : _b.type) == "print") { if (((_b = (_a = e.detail) == null ? void 0 : _a.data[0]) == null ? void 0 : _b.type) == "print") {
if ((_d = (_c = e.detail) == null ? void 0 : _c.data[0]) == null ? void 0 : _d.content) { if ((_d = (_c = e.detail) == null ? void 0 : _c.data[0]) == null ? void 0 : _d.content) {
onPrintClick((_f = (_e = e.detail) == null ? void 0 : _e.data[0]) == null ? void 0 : _f.content); onPrintClick((_f = (_e = e.detail) == null ? void 0 : _e.data[0]) == null ? void 0 : _f.content);
@ -371,23 +376,17 @@ if (uni.restoreGlobal) {
address: e2.address address: e2.address
} }
}; };
formatAppLog("log", "at pages/index/index.vue:121", "连接成功", e2); formatAppLog("log", "at pages/index/index.vue:124", "连接成功", e2);
uni.setStorageSync("deviceId", e2.address); uni.setStorageSync("deviceId", e2.address);
vw.value.evalJS(`receiveData('${JSON.stringify(obj)}')`); vw.value.evalJS(`receiveData('${JSON.stringify(obj)}')`);
}); });
} }
}; };
return (_ctx, _cache) => { return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock( return vue.openBlock(), vue.createElementBlock("web-view", {
"web-view", src: src.value,
{ onMessage: onmessage
src: "http://192.168.1.55:5178/", }, null, 40, ["src"]);
onMessage: onmessage
},
null,
32
/* NEED_HYDRATION */
);
}; };
} }
}; };

View File

@ -4,11 +4,11 @@
"iPhone", "iPhone",
"iPad" "iPad"
], ],
"id": "__UNI__D15002B", "id": "__UNI__3A527D1",
"name": "采购收银系统", "name": "采购收银测试",
"version": { "version": {
"name": "1.0.0", "name": "1.0.1",
"code": "100" "code": 101
}, },
"description": "", "description": "",
"developer": { "developer": {