Browse Source

打印配置文件

master
tianyi@bogon 3 years ago
parent
commit
efb4d3ada9
  1. 13
      common/httpRequest.js
  2. 45
      components/kk-printer/index.vue
  3. 11
      components/kk-printer/utils/bluetoolth.js
  4. 65
      package.json
  5. 9
      pages.json
  6. BIN
      static/images/pyq.png
  7. 35
      uni_modules/uni-popup/components/uni-popup-share/uni-popup-share.vue

13
common/httpRequest.js

@ -6,12 +6,12 @@
const tui = {
//接口地址
interfaceUrl: function() {
// return 'https://storage.xenjoyou.com/hiver'
return 'https://storage.xenjoyou.com/hiver'
// return 'http://172.22.14.0:8888/hiver'
// return 'http://172.22.175.84:8888/hiver'
// return 'http://172.22.116.195:8888/hiver'
// return 'http://192.168.0.13:8888/hiver'
return 'http://154.8.162.157:8888/hiver'
// return 'http://154.8.162.157:8888/hiver'
},
toast: function(text, duration, success) {
uni.showToast({
@ -109,7 +109,14 @@ const tui = {
},
method: method, //'GET','POST'
dataType: 'json',
success: (res) => {
success: (res) => {
console.log(res.data.code)
if(res.data.code == 401){
uni.clearStorage()
uni.navigateTo({
url: '/pages/login/login'
})
}
clearTimeout(tui.delayed)
tui.delayed = null;
if (tui.loadding && !hideLoading) {

45
components/kk-printer/index.vue

@ -83,7 +83,8 @@
//获取特征值时返回的三要素
serviceId: '',
writeId: '',
readId: ''
readId: '',
iosNo:false
}
},
props:{
@ -164,12 +165,48 @@
//打开蓝牙适配器
blesdk.openBlue().then((res)=>{
//获取已连接设备
blesdk.getConnectedBluetoothDevices().then((res)=>{
blesdk.getConnectedBluetoothDevices().then((res)=>{
if(this.iosNo){
let datalen=20;
// #ifdef APP-PLUS
if (plus.os.name != 'Android')
{
datalen=180;
}
// #endif
this.isPrinting = true;
this.$emit('onPrint');
this.$nextTick(()=>{
if(this.bufferData!=''){
let buffer = gbk.strToGBKByte(this.bufferData)
let opt = {
deviceId: this.deviceId,
serviceId: this.serviceId,
characteristicId: this.writeId,
value:buffer,
lasterSuccess: this.onPrintSuccess,
onceLength:datalen
}
console.log("开始打印了")
console.log(opt)
blesdk.sendDataToDevice(opt);
this.isPrinting = false;
//打印成功跳转页面
}
})
return
}
//若没有已连接设备,弹框搜索设备
console.log(res,this.deviceId,this.serviceId,this.writeId,this.bufferData,this.onPrintSuccess,'res,this.deviceId,this.serviceId,this.writeId,this.bufferData,this.onPrintSuccess’')
if(res.devices.length == 0){
if(res.devices.length == 0){
console.log("没有设备连接")
this.iosNo = true
this.isShowSearch = true
}else{
}else{
console.log("有设备连接")
let datalen=20;
// #ifdef APP-PLUS
if (plus.os.name != 'Android')

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

@ -227,7 +227,8 @@ export function getDeviceCharacteristics(deviceId, services, success, fail) {
export function onGetBLECharacteristicValueChange(options, onChange = function() {}) {
console.log('deviceId ', options.deviceId);
console.log('serviceId ', options.serviceId);
console.log('characteristicId ', options.characteristicId);
console.log('characteristicId ', options.characteristicId);
console.log('苹果手机看这里');
uniAsyncPromise('notifyBLECharacteristicValueChange', {
state: true,
...options,
@ -262,7 +263,8 @@ export function sendDataToDevice(options) {
...options,
value: options.value.slice(0, byteLength > speed ? speed : byteLength),
})
.then((res) => {
.then((res) => {
console.log("发送信息到蓝牙成功")
if (byteLength > speed) {
sendDataToDevice({
...options,
@ -428,7 +430,7 @@ function Hex2Str(num) {
* printNum: 打印张数,默认为1
* rotation:页面整体旋转 1-90度 2-180度 3-270度 其他-不旋转
*/
export function CreatCPCLPage(width, height, printNum, rotation = 0, offset = 0) {
export function CreatCPCLPage(width, height, printNum, rotation, offset = 0) {
var strCmd = '! ' + offset + ' 200 200 ' + height + ' ' + printNum + '\n';
strCmd += "PAGE-WIDTH " + width + '\n';
if (rotation == 1)
@ -451,7 +453,8 @@ export function CreatCPCLPage(width, height, printNum, rotation = 0, offset = 0)
* content: 文字内容
*/
export function addCPCLText(x, y, fontName, fontSize, rotation, content) {
//console.log(fontName,fontSize,rotation, content);
//console.log(fontName,fontSize,rotation, content);
// alert(content);
var strCmd = '';
if (rotation == 1) {
strCmd += 'T90 ';

65
package.json

@ -1,31 +1,34 @@
{
"name": "uView",
"version": "1.8.6",
"description": "uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
"main": "index.js",
"keywords": [
"uview",
"ui",
"uni-app"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": ""
},
"devDependencies": {
"node-sass": "^4.14.0",
"sass-loader": "^8.0.2"
},
"author": "uView",
"license": "MIT",
"id": "uview-v1",
"dcloudext": {
"category": [
"前端组件",
"通用组件"
]
}
}
{
"name": "uView",
"version": "1.8.6",
"description": "uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
"main": "index.js",
"keywords": [
"uview",
"ui",
"uni-app"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": ""
},
"devDependencies": {
"node-sass": "^4.14.0",
"sass-loader": "^8.0.2"
},
"author": "uView",
"license": "MIT",
"id": "uview-v1",
"dcloudext": {
"category": [
"前端组件",
"通用组件"
]
},
"dependencies": {
"uniapp-qrcode": "^1.0.2"
}
}

9
pages.json

@ -100,7 +100,14 @@
"navigationBarTitleText": "订单列表",
"enablePullDownRefresh": false
}
},
},
{
"path": "pages/index/downStearmList",
"style": {
"navigationBarTitleText": "客户下单页",
"enablePullDownRefresh": false
}
},
{
"path": "pages/index/logistics",
"style": {

BIN
static/images/pyq.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

35
uni_modules/uni-popup/components/uni-popup-share/uni-popup-share.vue

@ -3,10 +3,10 @@
<view class="uni-share-title"><text class="uni-share-title-text">{{shareTitleText}}</text></view>
<view class="uni-share-content">
<view class="uni-share-content-box">
<view class="uni-share-content-item" v-for="(item,index) in bottomData" :key="index" @click.stop="select(item,index)">
<button class="uni-share-content-item" open-type="share" v-for="(item,index) in bottomData" :key="index" @click.stop="select(item,index)">
<image class="uni-share-image" :src="item.icon" mode="aspectFill"></image>
<text class="uni-share-text">{{item.text}}</text>
</view>
</button>
</view>
</view>
@ -45,30 +45,10 @@
name: 'wx'
},
{
text: '支付宝',
icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/d684ae40-50be-11eb-8ff1-d5dcf8779628.png',
name: 'wx'
},
{
text: 'QQ',
icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/e7a79520-50be-11eb-b997-9918a5dda011.png',
name: 'qq'
},
{
text: '新浪',
icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/0dacdbe0-50bf-11eb-8ff1-d5dcf8779628.png',
name: 'sina'
},
// {
// text: '百度',
// icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/1ec6e920-50bf-11eb-8a36-ebb87efcf8c0.png',
// name: 'copy'
// },
// {
// text: '其他',
// icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/2e0fdfe0-50bf-11eb-b997-9918a5dda011.png',
// name: 'more'
// }
text: '朋友圈',
icon: '/static/images/pyq.png',
name: 'pyq'
}
]
}
},
@ -85,9 +65,8 @@
/**
* 选择内容
*/
select(item, index) {
select(index) {
this.$emit('select', {
item,
index
})
this.close()

Loading…
Cancel
Save