From 7c568a83831dad5cbe2a20d63b98dc6d087a92be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=95=BE?= <1144797966@qq.com> Date: Sat, 11 May 2024 18:26:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/js/EscPosUtil.js | 262 +++++++++++++++++++ common/js/api.js | 9 + pages.json | 12 + pages/index/drawer.vue | 374 ++++++++++++++++++++++++++++ pages/index/index.vue | 7 + pages/index/information.vue | 72 ++++-- pages/index/notificationdd.vue | 282 +++++++++++++++++++++ static/item5.png | Bin 0 -> 2996 bytes unpackage/dist/build/web/index.html | 2 +- 9 files changed, 999 insertions(+), 21 deletions(-) create mode 100644 common/js/EscPosUtil.js create mode 100644 pages/index/drawer.vue create mode 100644 pages/index/notificationdd.vue create mode 100644 static/item5.png diff --git a/common/js/EscPosUtil.js b/common/js/EscPosUtil.js new file mode 100644 index 0000000..e967c4a --- /dev/null +++ b/common/js/EscPosUtil.js @@ -0,0 +1,262 @@ +// 打印机纸宽58mm,页的宽度384,字符宽度为1,每行最多盛放32个字符 +// 打印机纸宽80mm,页的宽度576,字符宽度为1,每行最多盛放48个字符 +const PAGE_WIDTH = 576; +const MAX_CHAR_COUNT_EACH_LINE = 48; + +//字符串转字节序列 +function stringToByte(str) { + var bytes = new Array(); + var len, c; + len = str.length; + for (var i = 0; i < len; i++) { + c = str.charCodeAt(i); + if (c >= 0x010000 && c <= 0x10FFFF) { + bytes.push(((c >> 18) & 0x07) | 0xF0); + bytes.push(((c >> 12) & 0x3F) | 0x80); + bytes.push(((c >> 6) & 0x3F) | 0x80); + bytes.push((c & 0x3F) | 0x80); + } else if (c >= 0x000800 && c <= 0x00FFFF) { + bytes.push(((c >> 12) & 0x0F) | 0xE0); + bytes.push(((c >> 6) & 0x3F) | 0x80); + bytes.push((c & 0x3F) | 0x80); + } else if (c >= 0x000080 && c <= 0x0007FF) { + bytes.push(((c >> 6) & 0x1F) | 0xC0); + bytes.push((c & 0x3F) | 0x80); + } else { + bytes.push(c & 0xFF); + } + } + return bytes; +} + +//字节序列转ASCII码 +//[0x24, 0x26, 0x28, 0x2A] ==> "$&C*" +function byteToString(arr) { + if (typeof arr === 'string') { + return arr; + } + var str = '', + _arr = arr; + for (var i = 0; i < _arr.length; i++) { + var one = _arr[i].toString(2), + v = one.match(/^1+?(?=0)/); + if (v && one.length == 8) { + var bytesLength = v[0].length; + var store = _arr[i].toString(2).slice(7 - bytesLength); + for (var st = 1; st < bytesLength; st++) { + store += _arr[st + i].toString(2).slice(2); + } + str += String.fromCharCode(parseInt(store, 2)); + i += bytesLength - 1; + } else { + str += String.fromCharCode(_arr[i]); + } + } + return str; +} +//居中 +function Center() { + var Center = []; + Center.push(27); + Center.push(97); + Center.push(1); + var strCenter = byteToString(Center); + return strCenter; +} + +//居左 +function Left() { + var Left = []; + Left.push(27); + Left.push(97); + Left.push(0); + var strLeft = byteToString(Left); + return strLeft; +} +//居右 +function Right() { + var right = []; + Left.push(27); + Left.push(97); + Left.push(2); + var strRight = byteToString(right); + return strRight; +} +//标准字体 +function Size1() { + var Size1 = []; + Size1.push(29); + Size1.push(33); + Size1.push(0); + var strSize1 = byteToString(Size1); + return strSize1; +} +//大号字体 +/* 放大1倍 n = 0 + * 长宽各放大2倍 n = 17 */ +function Size2(n) { + var Size2 = []; + Size2.push(29); + Size2.push(33); + Size2.push(n); + var strSize2 = byteToString(Size2); + return strSize2; +} + +// 字体加粗 +function boldFontOn() { + var arr = [] + arr.push(27) + arr.push(69) + arr.push(1) + var cmd = byteToString(arr); + return cmd +} +// 取消字体加粗 +function boldFontOff() { + var arr = [] + arr.push(27) + arr.push(69) + arr.push(0) + var cmd = byteToString(arr); + return cmd +} +// 打印并走纸n行 +function feedLines(n = 1) { + var feeds = [] + feeds.push(27) + feeds.push(100) + feeds.push(n) + var printFeedsLines = byteToString(feeds); + return printFeedsLines +} +// 切纸 +function cutPaper() { + var cut = [] + cut.push(29) + cut.push(86) + cut.push(49) + var cutType = byteToString(cut); + return cutType +} + +// 开钱箱 +function open_money_box() { + var open = [] + open.push(27) + open.push(112) + open.push(0) + open.push(60) + open.push(255) + var openType = byteToString(open) + return openType +} + +// 初始化打印机 +function init() { + var arr = [] + arr.push(27) + arr.push(68) + arr.push(0) + var str = byteToString(arr) + return str +} +/* + 设置左边距 + len: + */ + +function setLeftMargin(len = 1) { + var arr = [] + arr.push(29) + arr.push(76) + arr.push(len) + var str = byteToString(arr) + return str +} + +// 设置打印区域宽度 +function setPrintAreaWidth(width) { + var arr = [] + arr.push(29) + arr.push(87) + arr.push(width) + var str = byteToString(arr) + return str +} + +/** + * @param str + * @returns {boolean} str是否全是中文 + */ +function isChinese(str) { + return /^[\u4e00-\u9fa5]$/.test(str); +} + +// str是否全含中文或者中文标点 +function isHaveChina(str) { + if (escape(str).indexOf("%u") < 0) { + return 0 + } else { + return 1 + } +} +/** + * 返回字符串宽度(1个中文=2个英文字符) + * @param str + * @returns {number} + */ +function getStringWidth(str) { + let width = 0; + for (let i = 0, len = str.length; i < len; i++) { + width += isHaveChina(str.charAt(i)) ? 2 : 1; + } + return width; +} + +/** + * 同一行输出str1, str2,str1居左, str2居右 + * @param {string} str1 内容1 + * @param {string} str2 内容2 + * @param {string} fillWith str1 str2之间的填充字符 + * @param {number} fontWidth 字符宽度 1/2 + * + */ +function inline(str1, str2, fillWith = ' ', fontWidth = 1) { + const lineWidth = MAX_CHAR_COUNT_EACH_LINE / fontWidth; + // 需要填充的字符数量 + let fillCount = lineWidth - (getStringWidth(str1) + getStringWidth(str2)) % lineWidth; + let fillStr = new Array(fillCount).fill(fillWith.charAt(0)).join(''); + return str1 + fillStr + str2; +} +/** + * 用字符填充一整行 + * @param {string} fillWith 填充字符 + * @param {number} fontWidth 字符宽度 1/2 + */ +function fillLine(fillWith = '-', fontWidth = 1) { + const lineWidth = MAX_CHAR_COUNT_EACH_LINE / fontWidth; + return new Array(lineWidth).fill(fillWith.charAt(0)).join(''); +} + +/** + * 文字内容居中,左右用字符填充 + * @param {string} str 文字内容 + * @param {number} fontWidth 字符宽度 1/2 + * @param {string} fillWith str1 str2之间的填充字符 + */ +function fillAround(str, fillWith = '-', fontWidth = 1) { + const lineWidth = MAX_CHAR_COUNT_EACH_LINE / fontWidth; + let strWidth = getStringWidth(str); + // 内容已经超过一行了,没必要填充 + if (strWidth >= lineWidth) { + return str; + } + // 需要填充的字符数量 + let fillCount = lineWidth - strWidth; + // 左侧填充的字符数量 + let leftCount = Math.round(fillCount / 2); + // 两侧的填充字符,需要考虑左边需要填充,右边不需要填充的情况 + let fillStr = new Array(leftCount).fill(fillWith.charAt(0)).join(''); + return fillStr + str + fillStr.substr(0, fillCount - leftCount); +} \ No newline at end of file diff --git a/common/js/api.js b/common/js/api.js index f0d9a7e..3606199 100644 --- a/common/js/api.js +++ b/common/js/api.js @@ -14,4 +14,13 @@ export default { storeinvoicelist(data) { //记录 return uni.api.post("store/invoicelist", data); }, + szzpyaddinvoicer(data) { //新增开票人 + return uni.api.post("szzpy/addinvoicer", data); + }, + szzpytypeofinvoicer(data) { //开票员类型列表 + return uni.api.post("szzpy/typeofinvoicer", data); + }, + szzpyaddinvoicersendsms(data) { //上传验证码(新增开票员) + return uni.api.post("szzpy/addinvoicersendsms", data); + }, } \ No newline at end of file diff --git a/pages.json b/pages.json index 5269ceb..c08a8e4 100644 --- a/pages.json +++ b/pages.json @@ -15,12 +15,24 @@ "navigationBarTitleText": "完善商户信息", "navigationStyle": "custom" } + }, { + "path": "pages/index/drawer", + "style": { + "navigationBarTitleText": "新增开票员", + "navigationStyle": "custom" + } }, { "path": "pages/index/notification", "style": { "navigationBarTitleText": "绑定通知", "navigationStyle": "custom" } + }, { + "path": "pages/index/notificationdd", + "style": { + "navigationBarTitleText": "绑定通知", + "navigationStyle": "custom" + } }, { "path": "pages/index/merchant", "style": { diff --git a/pages/index/drawer.vue b/pages/index/drawer.vue new file mode 100644 index 0000000..d4dfea1 --- /dev/null +++ b/pages/index/drawer.vue @@ -0,0 +1,374 @@ + + + + \ No newline at end of file diff --git a/pages/index/index.vue b/pages/index/index.vue index a225ba7..ec18032 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -16,6 +16,10 @@ 绑定通知 + + + 新增开票员 + + + \ No newline at end of file diff --git a/static/item5.png b/static/item5.png new file mode 100644 index 0000000000000000000000000000000000000000..4b6b22e9aa527515f147643c8fa17a8f962c9afa GIT binary patch literal 2996 zcmV;l3rqBgP)|zK}3i8pA2$)I`*^i$nCK{v+63{{{i7};# zXhBI5A!zvQEEorsnKhsw@t=>9s;!DzsQ^MSDaw#C6^TY=W*0C96{Uj4#6p4)c6VOi zoZb&LyUgtNdwcuMTgz8av#|Z{J$>GNw{PFR-6KT|uW>7=Hlg%nKpP{8K7-Fs3MoH} z&rcHxUrO-~5xtFn|4T}VpT$4gwA!$HnS3*b-D!s;;{vRzfu<_0FC{512dI%DaqT1_ zHfpIhHP^|%gp}drwz3j^_QNzNe?ZTLMJ@x7PjU7TgzqM)l1+7T1E<`uvdTtuO(y>> zBAJ037#$Y8&3z>3&m_DBO-cEpO?y{uA}4zM9dw%V{72ziFLc$ZVsi1;tjo8mn|7t- z2T|(n(iJJuRhj%ODdc@nI;0$(h0eXC)s?xW@};QtM@Do_#{VfgcT?0IETXTCNX^XE z%Z*WDiG*m7{0nsIhA2DMmoAcYU9K+itG?QC{oXmz)oFhv2E2t_fVt$rXKO?yQ!q$w z<&xQ(9H&HArSo%?l#fKwkuW+y_6OQi=Qb~qyTjZc647WoWyn ztwo*bIvR08bZv@G(v`ZYA2Ym2`G#fxI#=&~+oe(`MAxMKhcLOn(Is$h*;=T{F8wt- z(Qp~#h0-|)W|z%PZV!2TvMuU#k&<~Adf3URN#~zIrfrf7u+C*lF+W@9nRuW5VkNpd zP3KA3J^&8Pi^SWB;p)^EZqkF;8u-9yiidR z!>tS1zOA`r!Yn$lUTj2Tnr-qJ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df80369..ade218f 100644 --- a/unpackage/dist/build/web/index.html +++ b/unpackage/dist/build/web/index.html @@ -1,2 +1,2 @@ 发票
\ No newline at end of file + document.write('')
\ No newline at end of file