wangfukang 3 years ago
parent
commit
d52b78aeea
  1. 20
      components/kk-printer/index.vue
  2. 2
      components/kk-printer/utils/bluetoolth.js
  3. 113
      components/password-login/password-login.vue

20
components/kk-printer/index.vue

@ -28,7 +28,7 @@
<view class="kk-devices-wrap">
<view class="empty-wrap" v-if="filterDeviceList.length <= 0">
<view class="empty-icon"></view>
<view class="empty-text">~ 无可搜索到的设备 ~</view>
<view class="empty-text">无可搜索到的设备</view>
</view>
<view class="" v-else>
<view class="kk-devices-item" v-for="(item,index) in filterDeviceList" :key="index" @tap="handleConnectDevice(item)">
@ -164,17 +164,21 @@
blesdk.openBlue().then((res)=>{
//获取已连接设备
blesdk.getConnectedBluetoothDevices().then((res)=>{
console.log('看res',res)
if(uni.getStorageSync('deviceId') != '' && uni.getStorageSync('serviceId') != ''){
if(res.devices.length==0){
if(res.devices.length==0 || res.length==0){
blesdk.createBLEConnection(uni.getStorageSync('deviceId'), this.onConnectSuccess, this.onConnectFail);
}else{
let datalen=20;
// #ifdef APP-PLUS
if (plus.os.name != 'Android')
{
datalen=180;
}
// #endif
// uni.getSystemInfo({
// success: function (res) {
// console.log(res.osName)
// if (res.osName != 'android')
// {
// datalen=180;
// }
// }
// });
this.isPrinting = true;
this.$emit('onPrint');

2
components/kk-printer/utils/bluetoolth.js

@ -188,7 +188,6 @@ export function getDeviceCharacteristics(deviceId, services, success, fail) {
break;
}
}
if (!finished) {
getDeviceCharacteristics(deviceId, services, success, fail);
}
@ -244,7 +243,6 @@ export function sendDataToDevice(options) {
let byteLength = options.value.byteLength;
//这里默认一次20个字节发送
const speed = options.onceLength; //20;
console.log("send data 20");
console.log(options);
if (byteLength > 0) {
uniAsyncPromise('writeBLECharacteristicValue', {

113
components/password-login/password-login.vue

@ -1,113 +0,0 @@
<template>
<view>
<view class="main">
<view class="code">
<uni-easyinput v-model="ret.phone" :maxlength="11" :placeholder="plad"/>
<com-zw/>
<uni-easyinput v-model="ret.password" :maxlength="25" placeholder="请输入密码" type="password"/>
<com-zw/>
<view class="flex">
<uni-easyinput v-model="ret.code" :clearable="false" :maxlength="4" placeholder="请输入验证码"/>
<img :src="captchaImg" alt="加载验证码失败" style="width: 70px; height: 21px; cursor: pointer; display: block"
@click="getCaptchaImg"/>
</view>
</view>
<u-button type="primary" @tap.stop="confirm(ret)">登录</u-button>
</view>
</view>
</template>
<script>
import {
mapMutations,
mapActions,
mapState
} from 'vuex';
export default {
name: "phone-verify",
props: {
ret: {
type: Object,
default() {
return {
phone: 'delicacylee',
code: '',
password: '1qazxsw2#',
}
}
},
plad: {type: String, default: '请输入手机号'},
},
computed:mapState(['type']),
data() {
return {
captchaId: '',
captchaImg: '',
}
},
created() {
this.getCaptchaImg();
},
methods: {
...mapMutations(['login']),
...mapActions(['getUserInfo']),
getCaptchaImg() {
this.tui.request("/common/captcha/init", "GET", null).then((res) => {
if (res.code == 200) {
this.captchaId = res.result
this.captchaImg = this.tui.interfaceUrl() + '/common/captcha/draw/' + this
.captchaId
}
}).catch((res) => {
})
},
async confirm(form) { // 提
this.isChoose = true;
this.tui.request("/auth/login", "POST", {
username: form.phone,
password: form.password,
code: form.code,
captchaId: this.captchaId,
saveLogin: true
}, true, true).then((res) => {
if (res.code == 200) {
uni.setStorageSync("hiver_token", res.result)
let state = {
token: res.result
}
this.login(state)
this.getUserInfo().then((type) => {
console.log('this.type',type)
if (type == 2) {
setTimeout(() => {
uni.reLaunch({
// url: '/pages/index/logistics'
url: '/pages/other/custom'
})
}, 200)
} else {
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/index'
// url: '/pages/index/logistics'
})
}, 200)
}
})
this.tui.toast('登录成功', 2000, true)
} else {
this.tui.toast(res.message)
return
}
}).catch((res) => {
})
},
}
}
</script>
<style lang="scss" scoped>
@import '@/scss/phone-verify.scss';
</style>
Loading…
Cancel
Save