|
@@ -118,7 +118,10 @@ import debounce from 'lodash.debounce'
|
|
|
|
|
|
const trigger = ref(false)
|
|
|
|
|
|
-const userInfo = ref({})
|
|
|
+const userInfo = ref({
|
|
|
+ ip:'',
|
|
|
+ port:'9100'
|
|
|
+})
|
|
|
const workStatus = ref('0')
|
|
|
const tabList = ref([
|
|
|
{title:"今日待完成", status: '0', leng:0},
|
|
@@ -198,44 +201,52 @@ onMounted(async() => {
|
|
|
// 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')+''
|
|
|
+ console.log('获取ip,port>>>>>>',uni.getStorageSync('printerIp'))
|
|
|
+ userInfo.value.ip = uni.getStorageSync('printerIp')
|
|
|
+ console.log('userInfo.value.ip',userInfo.value.ip)
|
|
|
+ console.log('userInfo.value.port',userInfo.value.port)
|
|
|
+ if (userInfo.value.ip =='') {
|
|
|
+ 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);
|
|
|
- // 关闭配置页操作
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ if(res.code === 200){
|
|
|
+ console.log('index onmounted res.data', res.data)
|
|
|
+ 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 () => {
|
|
|
const token = uni.getStorageSync('token')
|
|
|
- userInfo.value.name = uni.getStorageSync('username')
|
|
|
+ userInfo.value.username = uni.getStorageSync('username')
|
|
|
+ userInfo.value.ip = uni.getStorageSync('printerIp') || ''
|
|
|
workStatus.value = uni.getStorageSync('workStatus') || '0'
|
|
|
const params = {
|
|
|
token: token,
|