|
@@ -110,7 +110,7 @@ import NavBar from "@/components/nav-bar/nav-bar.vue"
|
|
|
import OrderCard from "@/components/order-card/order-card.vue"
|
|
|
import { onMounted,ref, getCurrentInstance } from 'vue'
|
|
|
import { onLoad, onPullDownRefresh } from "@dcloudio/uni-app"
|
|
|
-import {receiveOrderList, selectDepartment } from "@/static/js/api.js"
|
|
|
+import {receiveOrderList, selectDepartment, getIp } from "@/static/js/api.js"
|
|
|
import {releaseOrder} from "@/static/js/request.js"
|
|
|
import debounce from 'lodash.debounce'
|
|
|
|
|
@@ -183,6 +183,8 @@ const today =ref({
|
|
|
leng: 0,
|
|
|
})
|
|
|
|
|
|
+const plug= uni.requireNativePlugin('Html5app-Gprinter')
|
|
|
+
|
|
|
|
|
|
// app.provide(ID_INJECTION_KEY, {
|
|
|
// prefix: Math.floor(Math.random() * 10000),
|
|
@@ -190,9 +192,45 @@ const today =ref({
|
|
|
// })
|
|
|
const {proxy} = getCurrentInstance()
|
|
|
|
|
|
-
|
|
|
-onMounted(() => {
|
|
|
-
|
|
|
+// 进入index页面,首先获取ip和port,然后连接打印机
|
|
|
+onMounted(async() => {
|
|
|
+ // userInfo.value.username = uni.getStorageSync('userId')
|
|
|
+ // userInfo.value.password = uni.getStorageSync('password')
|
|
|
+ // 获取ip,port
|
|
|
+ console.log('获取ip,port>>>>>>',uni.getStorageSync('userId'))
|
|
|
+ const {data: res} = await getIp({
|
|
|
+ token:uni.getStorageSync('token'),
|
|
|
+ data:JSON.stringify({
|
|
|
+ userId: uni.getStorageSync('userId')+''
|
|
|
+ })
|
|
|
+ })
|
|
|
+ if(res.code === 200){
|
|
|
+ userInfo.value.ip = res.data.ip || ''
|
|
|
+ userInfo.value.port = res.data.port || ''
|
|
|
+ console.log('userInfo.value', userInfo.value)
|
|
|
+
|
|
|
+ const ipReg = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
|
|
|
+ if(ipReg.test(userInfo.value.ip)){
|
|
|
+ if(RegExp.$1<256 && RegExp.$2<256 && RegExp.$3<256 && RegExp.$4<256){
|
|
|
+
|
|
|
+ plug.connectIP({"ip":userInfo.value.ip,"port":userInfo.value.port},ret=>{
|
|
|
+ console.log('connectPrint>>ret',ret)
|
|
|
+ const res = JSON.parse(JSON.stringify(ret))
|
|
|
+ console.log('connectPrint>>res',res.code)
|
|
|
+ if(res.code==3){
|
|
|
+ // initPrint.value = true
|
|
|
+ uni.setStorageSync('hasPrinter', '1')
|
|
|
+
|
|
|
+ uni.setStorageSync('printerIp', userInfo.value.ip)
|
|
|
+ console.log('已经连接打印机:',userInfo.value.ip)
|
|
|
+ // _this.tip=JSON.stringify(ret);
|
|
|
+ // console.log(_this.tip);
|
|
|
+ // 关闭配置页操作
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
onLoad(async () => {
|