소스 검색

结账改造首次修改

shish 1 개월 전
부모
커밋
f7e9eef062

+ 29 - 0
.cursor/rules/chinese-code-comments.mdc

@@ -0,0 +1,29 @@
+---
+description: 业务代码必须用中文说明新增/改动部分的用途与要解决的问题
+alwaysApply: true
+---
+
+# 代码中文说明(必遵)
+
+在本仓库(`D:/front-end`)及关联后端 `D:/phpstudy_pro/WWW/huahuibao` 中,对**新增或实质改动**的代码补充清晰**简体中文**说明。完整细则见 `D:/understand-project/knowledge/code-comments-cn.md`。
+
+## 必须说明的对象
+
+- **新建文件**:文件顶部块注释 — 用途、谁调用、解决什么问题、与哪条 API/页面/表相关(若适用)。
+- **新增/改动的函数、方法、类、组件、导出**:定义上方 — 职责、入参/返回业务含义、副作用、关键边界。
+- **非显而易见的逻辑块**:分支、权限、库存/金额、状态流转 — 写清**业务规则**,不只复述代码。
+
+## 写法要求
+
+- 回答:**干什么** + **为什么(解决什么问题)**。
+- 与接口/表/产品相关时点名(如 `ghsApp`、`app-ghs`),便于用 `D:/understand-project` 的 `npm run context` 串联。
+- 不写空话(「优化」「处理」);不堆砌类型已表达的信息。
+- 仅格式/错别字/无行为变更时可不加新注释。
+
+## 全栈一致
+
+改 API 时,本仓库 `src/api` / `src/service` 与后端 Controller/Class 的中文说明应对同一业务行为,表述一致。
+
+## 例外
+
+用户当次明确要求不要注释或仅英文时,服从当次指令并在回复中简要说明。

+ 2 - 0
ghs/src/service/request.js

@@ -34,6 +34,8 @@ axios.interceptors.request.use(
 
 		config.headers['source'] = localStorage.getItem('source') || '';
 		config.headers['account'] = localStorage.getItem('account') || '';
+		// 3=会员列表等只展示净账户余额(后端 debtAmount 已废弃)
+		config.headers['appVersion'] = 3;
 
 		config.data = qs.stringify(config.data) || {};
 

+ 10 - 24
ghs/src/views/member/list.vue

@@ -49,19 +49,10 @@
 				</span>
 			</template>
 
-			<template #table-column-debtAmount="{scope}">
-				<span style="cursor: pointer;" @click="goDebtChange(scope.row)">{{ scope.row.debtAmount?parseFloat(scope.row.debtAmount):0 }}</span>
-			</template>
-
 			<template #table-column-balance="{scope}">
-				<span style="cursor: pointer;" @click="goBalanceChange(scope.row)">{{ scope.row.balance }}</span>
-			</template>
-
-			<template #table-column-actDebt="{scope}">
-				<span v-if="Number(scope.row.debtAmount) > Number(scope.row.balance)" style="cursor: pointer;" @click="goDebtChange(scope.row)">
-					{{ parseFloat((Number(scope.row.debtAmount)-Number(scope.row.balance)).toFixed(2)) }}
+				<span style="cursor: pointer;" @click="goBalanceChange(scope.row)" :style="Number(scope.row.balance) < 0 ? 'color:red;' : ''">
+					{{ formatMemberBalance(scope.row.balance) }}
 				</span>
-				<span v-else style="cursor: pointer;" @click="goDebtChange(scope.row)">-</span>
 			</template>
 
 			<template #table-column-debt="{scope}">
@@ -279,6 +270,13 @@ export default {
 				}
 			})
 		},
+		// 净 balance:负显示「待结 X」,正为可用余额
+		formatMemberBalance(balance) {
+			const n = parseFloat(balance)
+			if (isNaN(n)) return 0
+			if (n < 0) return '待结 ' + Math.abs(n)
+			return n
+		},
 		goDebtChange(data){
 			let query = {};
 			query.customId = data.id
@@ -471,21 +469,9 @@ export default {
 							align: 'center',
 							width: 110
 						},
-						{
-							prop: 'debtAmount',
-							label: '欠款',
-							align: 'center',
-							width: 90
-						},
 						{
 							prop: 'balance',
-							label: '余额',
-							align: 'center',
-							width: 90
-						},
-						{
-							prop: 'actDebt',
-							label: '实际欠款',
+							label: '账户余额',
 							align: 'center',
 							width: 100
 						},

+ 4 - 4
ghsApp/src/admin/custom/selectCustom.vue

@@ -22,12 +22,12 @@
               <div class="tui-msg-content">
                 <span>{{ item.visitTime.substr(5,11) }}</span>
                 <text style="margin-left:10upx;">{{ item.distName }}</text>
-                <span v-if="Number(item.remainDebtAmount) > 0" class="debt-amount">
-                  <span class="amount_num">{{item.remainDebtAmount}}</span>
+                <span v-if="Number(item.balance) < 0" class="debt-amount">
+                  <span class="amount_num">{{ Math.abs(parseFloat(item.balance)) }}</span>
                 </span>
 
-                <span v-if="Number(item.remainDebtAmount) < 0" class="debt-amount">
-                  <span class="amount_num" style="color:#3385FF;">{{Math.abs(item.remainDebtAmount)}}</span>
+                <span v-if="Number(item.balance) > 0" class="debt-amount">
+                  <span class="amount_num" style="color:#3385FF;">{{ parseFloat(item.balance) }}</span>
                 </span>
 
                 <text v-if="item.overTimeUnExpend && item.overTimeUnExpend == 10000" style="font-size:24upx;margin-left:15upx;color:green;font-weight:bold;">没有下过</text>

+ 4 - 4
ghsApp/src/admin/custom/visit.vue

@@ -15,12 +15,12 @@
               <div class="tui-msg-content">
                 <span>{{ item.visitTime.substr(5,11) }}</span>
 
-                <span v-if="Number(item.remainDebtAmount) > 0" class="debt-amount">
-                  欠款<span class="amount_num">{{item.remainDebtAmount}}</span>
+                <span v-if="Number(item.balance) < 0" class="debt-amount">
+                  欠款<span class="amount_num">{{ Math.abs(parseFloat(item.balance)) }}</span>
                 </span>
 
-                <span v-if="Number(item.remainDebtAmount) < 0" class="debt-amount">
-                  余额<span class="amount_num" style="color:#3385FF;">{{Math.abs(item.remainDebtAmount)}}</span>
+                <span v-if="Number(item.balance) > 0" class="debt-amount">
+                  余额<span class="amount_num" style="color:#3385FF;">{{ parseFloat(item.balance) }}</span>
                 </span>
 
                 <block v-if="item.passStatus == 1">

+ 4 - 4
ghsApp/src/admin/home/member.vue

@@ -43,11 +43,11 @@
                 <span>{{ item.visitTime.substr(5,11) }}</span>
                 <span v-if="tabIndex == 1" class="debt-amount">消费 <span class="amount_num">{{parseFloat(item.buyAmount)}}</span> </span>
                 <span v-else>
-                  <span v-if="Number(item.remainDebtAmount)>0" class="debt-amount">
-                    <span class="amount_num">{{ item.remainDebtAmount }}</span>
+                  <span v-if="Number(item.balance)<0" class="debt-amount">
+                    <span class="amount_num">{{ Math.abs(parseFloat(item.balance)) }}</span>
                   </span>
-                  <span v-if="Number(item.remainDebtAmount)<0" class="debt-amount">
-                    <span class="amount_num" style="color:#3385FF;">{{ Math.abs(item.remainDebtAmount) }}</span>
+                  <span v-if="Number(item.balance)>0" class="debt-amount">
+                    <span class="amount_num" style="color:#3385FF;">{{ parseFloat(item.balance) }}</span>
                   </span>
                 </span>
 

+ 13 - 20
ghsApp/src/pagesClient/member/detail.vue

@@ -31,15 +31,11 @@
             </view>
         </view>
         <view class="user-info_data order-wrap">
+            <!-- 待结已并入 balance:负数=待结(红),正数=可用余额;挂账变动明细入口仍保留查历史 -->
             <view class="total-blo">
-              <view class="total-list" @click="pageTo({url:'/pagesArrears/details',query: {id: userInfo.id}})">
-                <view class="app-color-3">待结</view>
-                <view class="list-num" style="color:red;">{{ parseFloat(userInfo.debtAmount) || 0 }}</view>
-              </view>
-
-              <view class="total-list">
+              <view class="total-list" @click="pageTo({ url: '/admin/custom/balanceChange?customId='+userInfo.id})">
                 <view class="app-color-3">余额</view>
-                <view class="list-num">{{ userInfo.balance ? parseFloat(userInfo.balance) : 0 }}</view>
+                <view class="list-num" :style="Number(userInfo.balance) < 0 ? 'color:red;' : ''">{{ formatAccountBalance(userInfo.balance) }}</view>
               </view>
 
               <view class="total-list" @click="showNum(userInfo)">
@@ -48,16 +44,6 @@
                 <view v-else class="list-num" style="color:#3385FF;" @click="refreshBuyAmount">拉取</view>
               </view>
             </view>
-            <block v-if="Number(userInfo.remainDebtAmount)>0">
-              <text v-if="Number(userInfo.debtAmount) > Number(userInfo.remainDebtAmount) && Number(userInfo.debtAmount)>0" style="font-size:34upx;color:red;font-weight:bold;width:450upx;text-align: center;display: inline-block;">
-                实际待结<text style="color:red;margin-left:10upx;">{{ userInfo.remainDebtAmount?parseFloat(userInfo.remainDebtAmount):0 }}</text>
-              </text>
-            </block>
-            <block v-else>
-              <text v-if="Number(userInfo.debtAmount) > Number(userInfo.remainDebtAmount) && Number(userInfo.debtAmount)>0" style="font-size:34upx;color:#3385FF;font-weight:bold;width:450upx;text-align: center;display: inline-block;">
-                余额<text style="color:#3385FF;margin-left:10upx;">{{ userInfo.remainDebtAmount?Math.abs(parseFloat(userInfo.remainDebtAmount)):0 }}</text>
-              </text>
-            </block>
         </view>
       </view>
       <view class="module-com user-address_bx">
@@ -508,6 +494,12 @@ export default {
 
   },
   methods: {
+    // 详情展示净 balance:负数取绝对值当待结,正数为可用余额
+    formatAccountBalance(balance) {
+      const n = parseFloat(balance)
+      if (isNaN(n)) return 0
+      return n < 0 ? Math.abs(n) : n
+    },
     downloadCode(){
       let that = this
       getGatheringCode({id:this.option.id}).then(res=>{
@@ -848,9 +840,10 @@ export default {
         this.form.staffName = this.userInfo.staffName
         this.form.debtLimitPay = this.userInfo.debtLimitPay||0
         this.discount = parseFloat(res.data.discount)
-        if(res.data.remainDebtAmount && Number(res.data.remainDebtAmount)>0){
-          let name = res.data.name && !this.$util.isEmpty(res.data.name) ? res.data.name+' 待结金额' : '待结金额'
-          this.title = name+' ¥'+res.data.remainDebtAmount
+        const bal = parseFloat(res.data.balance)
+        if (!isNaN(bal) && bal < 0) {
+          let name = res.data.name && !this.$util.isEmpty(res.data.name) ? res.data.name + ' 待结金额' : '待结金额'
+          this.title = name + ' ¥' + Math.abs(bal)
         }
       })
     },

+ 2 - 1
ghsApp/src/plugins/luch-request_0.0.7/request.js

@@ -69,7 +69,8 @@ class Request {
 		if (token) {
 			config.header['token'] = token
 		}
-		config.header['appVersion'] = 2
+		// appVersion 3:接口 balance 为净额(负=待结);2:后端仍拆成待结+余额两字段
+		config.header['appVersion'] = 3
 		// const token = uni.getStorageSync('token')
 		// config.data = JSON.stringify(config.data);
 		config.headers = {

+ 0 - 584
ghsPad/src/mixins/BLE.js

@@ -1,584 +0,0 @@
-/** -姜枫 2021.06.13- **/
-import { addPrintNum } from "@/api/order";
-var util = require("@/pagesOrder/js/util.js");
-import drawQrcode from "@/pagesOrder/js/weapp.qrcode.esm";
-var toArrayBuffer = require('to-array-buffer');
-
-var PrinterJobs = require("@/pagesOrder/js/printerjobs.js");
-var printerUtil = require("@/pagesOrder/js/printerutil.js");
-
-
-export default {
-	data() {
-		return {
-			BleVal:'',
-			nameBLE:'未连接',
-			devices: [],
-			currDev: null,
-			isAutoBle: false,
-			connId: "",
-			piaojuText: [''],
-		};
-	},
-	onShow() {
-		this.devices = [];
-		this.isAutoBle = false;
-		if(uni.getStorageSync('BLE')){
-			this.nameBLE = uni.getStorageSync('BLE').name;
-		}
-	},
-	methods: {
-		//断开蓝牙链接
-		destroyed(BleVal) {
-			this.BleVal = BleVal;
-			let that = this;
-			if(!uni.getStorageSync('BLE')){
-
-				that.$util.confirmModal({content:'请先连接蓝牙'},() => {
-					uni.navigateTo({url:'/pagesOrder/print'});
-				})
-
-				return;
-			}
-			uni.closeBLEConnection({deviceId: uni.getStorageSync('BLE').deviceId,complete(res) {
-					console.log(res);
-					that.autoLinkBle(BleVal);
-				}
-			});
-			// if (this.connId != "") {
-			// 	uni.closeBLEConnection({deviceId: uni.getStorageSync('BLE').deviceId,success(res) {
-			// 			this.autoLinkBle();
-			// 		}
-			// 	});
-			// }
-		},
-		//初始化蓝牙
-		searchBle() {
-			uni.showToast({
-				title: '搜索中...',
-				duration: 2000
-				});
-			var that = this;
-			that.isAutoBle = false;
-			uni.openBluetoothAdapter({
-				success(res) {
-					console.log(res,"打开 蓝牙模块");
-					//that.onDevice();//监听搜索新设备
-					//获取本机蓝牙适配器状态。
-					uni.getBluetoothAdapterState({
-						success: function(res) {
-							console.log(res);
-							if (res.available) {
-								if (res.discovering) {
-									that.stopFindBule();
-								}
-								//搜索蓝牙
-								//开始搜寻附近的蓝牙外围设备
-								console.log("开始搜寻附近的蓝牙外围设备");
-								uni.startBluetoothDevicesDiscovery({
-									success(res) {
-										console.log(res);
-										that.getBluetoothDevices()
-									}
-								});
-							} else {
-								console.log("本机蓝牙不可用");
-							}
-						}
-					});
-				}
-			});
-		},
-		getBluetoothDevices(){
-			let that = this;
-			uni.getBluetoothDevices({
-				success: re => {
-					//let devices = res.devices;
-					console.log(re,'设备列表');
-					//var re = JSON.parse(JSON.stringify(devices));
-					if(re.devices && re.devices.length > 0){
-
-						re.devices.forEach(function(item){
-							  
-						let name = item.name?item.name:'未知设备';
-						if (name != "未知设备" && name != "") {
-							let deviceId = item.deviceId;
-							switch(uni.getSystemInfoSync().platform){
-								case 'android':
-									that.devices.push({name: name,deviceId: deviceId,services: []});
-									break;
-								case 'ios':
-									for (let i=0;i<that.devices.length;i++){
-										console.log(that.devices[i].name,'----',name)
-										if (that.devices[i].name==name) {return}
-									}
-									that.devices.push({name: name,deviceId: deviceId,services: []});
-									break;
-							}
-		
-						}else{
-							console.log('name',name)
-							console.log('re.devices[0]',re.devices[0])
-						}
-
-					});
-
-					}
-
-				
-
-				}
-			});
-		},
-		// onDevice() {
-		// 	var that = this;
-		// 	//监听寻找到新设备的事件
-		// 	uni.onBluetoothDeviceFound(function(devices) {
-		// 		console.log(devices,'设备列表');
-		// 		var re = JSON.parse(JSON.stringify(devices));
-		// 		let name = re.devices[0].name?re.devices[0].name:'未知设备';
-		// 		if (name != "未知设备" && name != "") {
-		// 			let deviceId = re.devices[0].deviceId;
-		// 			switch(uni.getSystemInfoSync().platform){
-		// 				case 'android':
-		// 					that.devices.push({name: name,deviceId: deviceId,services: []});
-		// 					break;
-		// 				case 'ios':
-		// 					for (let i=0;i<that.devices.length;i++){
-		// 						console.log(that.devices[i].name,'----',name)
-		// 						if (that.devices[i].name==name) {return}
-		// 					}
-		// 					that.devices.push({name: name,deviceId: deviceId,services: []});
-		// 					break;
-		// 			}
-
-
-		// 			// that.$nextTick(()=>{
-		// 			// 	that.$util.unique(that.devices);
-		// 			// })
-
-		// 		}
-		// 	});
-		// },
-		//自动链接蓝牙-初始化蓝牙模块
-		autoLinkBle(BleVal){
-			this.BleVal = BleVal;
-			let that = this;
-			if(!uni.getStorageSync('BLE')){
-
-				that.$util.confirmModal({content:'请先连接蓝牙'},() => {
-					uni.navigateTo({url:'/pagesOrder/print'})
-				})
-
-				return;
-			}
-			uni.showLoading({title: '打印中...'});
-			that.isAutoBle = true;
-			let deviceId = uni.getStorageSync('BLE');
-			//初始化蓝牙模块
-			uni.openBluetoothAdapter({
-				success(res) {
-					console.log('初始化成功',res)
-					that.autoLinkBleFun(deviceId);
-				},fail(e){
-					console.log('初始化失败',e)
-				}
-			});
-		},
-		//自动链接蓝牙
-		autoLinkBleFun(item) {
-			console.log('自动链接 444444444444444444444444444444444444444444444444444')
-			var that = this;
-			let deviceId = item.deviceId;
-			uni.createBLEConnection({
-				deviceId: deviceId,
-				complete(res) {
-					console.log(res,'自动连接成功')
-					if (res.errMsg == "createBLEConnection:ok") {
-						uni.setStorageSync('BLE',item);
-						setTimeout(function() {
-							that.getBLEServices(deviceId);
-						}, 2000);
-					}
-				}
-			});
-		},
-		stopFindBule() {
-			console.log("停止搜寻附近的蓝牙外围设备---------------");
-			uni.stopBluetoothDevicesDiscovery({
-				success(res) {
-					console.log(res);
-				}
-			});
-		},
-		onConn(item) {
-			console.log('正在连接 333333333333333333333333333333333333333333333333333333333333333333333333')
-			uni.showLoading({title: '正在连接...'});
-			var that = this;
-			// console.log("连接蓝牙---------------" + item.deviceId);
-			let deviceId = item.deviceId;
-			uni.createBLEConnection({
-				deviceId: deviceId,
-				complete(res) {
-					if (res.errMsg == "createBLEConnection:ok") {
-						that.nameBLE = item.name;
-						// console.log("连接蓝牙-[" + item.name + "]--成功");
-						// that.$msg("连接蓝牙-[" + item.name + "]--成功");
-						that.connId = deviceId;
-						that.currDev = item;
-						setTimeout(function() {
-							that.getBLEServices(deviceId);
-						}, 2000);
-					} else {
-						console.log(res);
-					}
-					//连接成功 关闭搜索
-					that.stopFindBule();
-				}
-			});
-		},
-
-		getBLEServices(_deviceId) {
-			var that = this;
-			let deviceId = _deviceId;
-			console.log("获取蓝牙设备所有服务(service)");
-
-			console.log('获取蓝牙设备所有服务 222222222222222222222222222222222222222222222222222222222')
-
-			uni.getBLEDeviceServices({
-				// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
-				deviceId: deviceId,
-				success(res) {
-						console.log('getBLEDeviceServices成功:',res)
-						for (var s = 0; s < res.services.length; s++) {
-							console.log(res.services[s].uuid);
-							let serviceId = res.services[s].uuid;
-							uni.getBLEDeviceCharacteristics({
-								// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
-								deviceId: deviceId,
-								// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
-								serviceId: serviceId,
-								success(res) {
-									var re = JSON.parse(JSON.stringify(res));
-
-									console.log("deviceId = [" + deviceId + "]  serviceId = [" + serviceId + "]")
-
-									for (var c = 0; c < re.characteristics.length; c++) {
-										if (re.characteristics[c].properties.write == true) {
-											let uuid = re.characteristics[c].uuid;
-											console.log(" deviceId = [" +deviceId +"]  serviceId = [" +serviceId +"] characteristics = [" +uuid +"]");
-											//是否是直接打印
-											if(that.isAutoBle){
-												console.log('打印订单 11111111111111111111111111111111111111111111111111111111111111')
-												that.senBleLabel()
-												uni.hideLoading()
-												that.isAutoBle = false
-											}
-											for (var index in that.devices) {
-												if (that.devices[index].deviceId == deviceId) {
-													that.devices[index].services.push({serviceId: serviceId,characteristicId: uuid});
-													that.$nextTick(()=>{
-														uni.setStorageSync('BLE',that.devices[index]);
-														that.$msg("连接蓝牙-[" + that.devices[index].name + "]--成功");
-													})
-													break;
-												}
-											}
-											console.log(JSON.stringify(that.devices));
-										}
-									}
-								}
-							});
-						}
-				},
-				fail(res) {
-					console.log('getBLEDeviceServices失败:',res)
-					uni.hideLoading()
-					uni.showLoading({title:"打印失败..."})
-					setTimeout(function(){
-						uni.hideLoading()
-					},2000)
-					// if(res.errCode && res.errCode == 10004){
-					// 	uni.showLoading({title:"重打中..."})
-					// 	that.destroyed(that.BleVal)
-					// }
-				}
-			});
-		},
-		_writeBLECharacteristicValue(data) {
-			uni.writeBLECharacteristicValue({
-			  deviceId: data.deviceId,
-			  serviceId: data.serviceId,
-			  characteristicId: data.characteristicId,
-			  value: data.buffer,
-			  success(res) {
-				console.log('writeBLECharacteristicValue success', res)
-			  },
-			  fail(res) {
-				console.log('writeBLECharacteristicValue fail', res)
-			  }
-			})
-		  },
-
-		senBleLabel() {
-			let BleVal = this.BleVal;
-			let that = this;
-			console.log(BleVal,'BleValBleVal')
-			let currDev = uni.getStorageSync('BLE');
-			let deviceId = currDev.deviceId;
-			let serviceId = currDev.services[0].serviceId;
-			let characteristicId = currDev.services[0].characteristicId;
-
-			let currentRealPrice = BleVal.debt == 1 ? '0.00' : BleVal.realPrice;
-
-			let printerJobs = new PrinterJobs();
-			printerJobs
-			  .setSize(2, 2)
-			  .print(BleVal.sendNum)
-			  .setSize(1, 1)
-			  .print(printerUtil.fillLine())
-			  .setSize(2, 2)
-			  .print(BleVal.custom.fullAddress)
-			  .print(BleVal.custom.customName)
-			  .print(BleVal.custom.customMobile)
-
-				.setSize(1, 1)
-				.print("备注:")
-				.setSize(2, 2)
-				.print(BleVal.remark)
-				.setSize(1, 1)
-				
-
-				.setAlign('lt')
-				.print(printerUtil.fillAround('花材 数量 价格'));
-				
-				if(BleVal.product.length > 0){
-					BleVal.product.forEach(function(currentItem){
-						printerJobs.print(printerUtil.inline(currentItem.name+' '+currentItem.num, currentItem.price));
-					})
-				}
-				printerJobs.print(printerUtil.fillLine());
-				//printerJobs.setAlign('rt');
-				printerJobs.setAlign('lt')
-				if(BleVal.sendCost>0){
-					printerJobs.print('运费:¥'+BleVal.sendCost);
-				}
-				
-				printerJobs.print('总金额:¥'+BleVal.prePrice);
-
-				if(BleVal.discountAmount > 0){
-					printerJobs.print('优惠:¥'+BleVal.discountAmount);
-				}
-			
-				printerJobs.print('应付金额:¥'+BleVal.realPrice);
-				printerJobs.print('实付金额:¥'+currentRealPrice);
-			
-				if(BleVal.debtAmount > 0){
-					printerJobs.print('累计欠款:¥'+BleVal.debtAmount);
-				}
-
-				printerJobs.print(printerUtil.fillLine());
-				printerJobs.print('订单日期:'+BleVal.date);
-				printerJobs.print('订单编号:'+BleVal.orderSn);
-				printerJobs.print('门店名称:纯彩花艺');
-				printerJobs.print('门店地址:'+BleVal.address);
-				
-				printerJobs.println().println();
-			
-		
-			let buffer = printerJobs.buffer();
-			
-			// 1.并行调用多次会存在写失败的可能性
-			// 2.建议每次写入不超过20字节
-			// 分包处理,延时调用
-			const maxChunk = 20;
-			const delay = 20;
-			for (let i = 0, j = 0, length = buffer.byteLength; i < length; i += maxChunk, j++) {
-			  let subPackage = buffer.slice(i, i + maxChunk <= length ? (i + maxChunk) : length);
-			  setTimeout(this._writeBLECharacteristicValue, j * delay, {deviceId:deviceId, serviceId:serviceId, characteristicId:characteristicId,buffer:subPackage});
-			}
-
-			//增加打印次数
-			addPrintNum({id:that.orderId}).then(res=>{
-				if(!that.$util.isEmpty(that.detailInfo)){
-					that.detailInfo.printNum++;
-				}
-				if(!that.$util.isEmpty(that.list.data)){
-					that.list.data.forEach(ele=>{
-						if (ele.id==that.orderId) {
-							ele.printNum++;
-						}
-					})
-				}
-			})
-
-			// let arrPrint = [];
-			// //初始化打印机
-			// arrPrint.push(util.sendDirective([0x1B, 0x40])); //16进制
-			// //正文
-			// arrPrint.push(util.sendDirective([0x1B, 0x0E]));
-			// //字体宽高加倍
-			// arrPrint.push(util.sendDirective([0x1d, 0x21, 0x11]));
-			// arrPrint.push(util.hexStringToBuff(BleVal.sendNum));
-			// //字体不放大,宽高不再加倍
-			// arrPrint.push(util.sendDirective([0x1d, 0x21, 0x00]));
-
-			// arrPrint.push(util.sendDirective([0x1B, 0x14]));
-			// arrPrint.push(util.hexStringToBuff(" |纯彩花艺\n"));
-			// arrPrint.push(util.sendDirective([0x1B, 0x14]));
-			
-			// arrPrint.push(util.hexStringToBuff("--------------------------------\n"));
-			// arrPrint.push(util.sendDirective([0x1B, 0x0E]));
-
-			// //字体宽高加倍
-			// arrPrint.push(util.sendDirective([0x1d, 0x21, 0x11]));
-
-			// arrPrint.push(util.hexStringToBuff(BleVal.custom.fullAddress+ "\n"));	
-			// arrPrint.push(util.sendDirective([0x1B, 0x0E]));
-			// arrPrint.push(util.hexStringToBuff(BleVal.custom.customName+"\n"+BleVal.custom.customMobile+ "\n"));
-
-			// //字体不放大,宽高不再加倍
-			// arrPrint.push(util.sendDirective([0x1d, 0x21, 0x00]));
-
-			// if(BleVal.remark.length > 0){
-			// 	arrPrint.push(util.sendDirective([0x1B, 0x14]));
-			// 	arrPrint.push(util.hexStringToBuff("--------------------------------\n"));
-			// 	arrPrint.push(util.hexStringToBuff("备注:\n"));
-			// 	arrPrint.push(util.sendDirective([0x1B, 0x0E]));
-			// 	//字体宽高加倍
-			// 	arrPrint.push(util.sendDirective([0x1d, 0x21, 0x11]));
-			// 	arrPrint.push(util.hexStringToBuff(BleVal.remark+"\n"));
-			// 	//字体不放大,宽高不再加倍
-			// 	arrPrint.push(util.sendDirective([0x1d, 0x21, 0x00]));
-			// }
-
-			// arrPrint.push(util.sendDirective([0x1B, 0x14]));
-			// arrPrint.push(util.hexStringToBuff("--------------------------------\n"));
-			// arrPrint.push(util.hexStringToBuff(util.printThreeData('花材', '数量', '价格')));
-			// if(BleVal.product.length > 0){
-			// 	BleVal.product.forEach(function(currentItem){
-			// 		arrPrint.push(util.hexStringToBuff(util.printThreeData(currentItem.name, currentItem.num, currentItem.price)))
-			// 	})
-			// }
-			// arrPrint.push(util.hexStringToBuff("--------------------------------\n"));
-			// arrPrint.push(util.hexStringToBuff(util.printTwoData("运费:", BleVal.sendCost)));
-			// arrPrint.push(util.hexStringToBuff(util.printTwoData("总金额:", BleVal.prePrice)));
-			// arrPrint.push(util.hexStringToBuff(util.printTwoData("优惠:", BleVal.discountAmount)));
-			// arrPrint.push(util.hexStringToBuff(util.printTwoData("应付金额:", BleVal.realPrice)));
-			// arrPrint.push(util.hexStringToBuff(util.printTwoData("实付金额:", BleVal.debt == 1 ? '0.00' : BleVal.realPrice)));
-			// if(BleVal.debtAmount > 0){
-			// 	//加粗
-			// 	//arrPrint.push(util.sendDirective([0x1b, 0x45, 0x01]));
-			// 	arrPrint.push(util.hexStringToBuff(util.printTwoData("累计欠款:", BleVal.debtAmount)));
-			// 	//取消加粗	
-			// 	//arrPrint.push(util.sendDirective([0x1b, 0x45, 0x00]));
-			// }
-			// arrPrint.push(util.hexStringToBuff(util.printTwoData("订单日期:", BleVal.date)));
-			// arrPrint.push(util.hexStringToBuff(util.printTwoData("订单编号:", BleVal.orderSn)));
-			// arrPrint.push(util.sendDirective([0x1B, 0x61, 0x00]));
-			// arrPrint.push(util.hexStringToBuff("门店地址:"+BleVal.address+"\n"));
-			// arrPrint.push(util.hexStringToBuff("\n\n\n\n"));
-
-			// const ctx = uni.createCanvasContext('canvas');
-			// ctx.clearRect(0, 0, 130, 130);
-			// let tthis = this;
-			// drawQrcode({
-			// 	canvasId: 'canvas',
-			// 	text: 'https://shop.huahb.cn/#/main/index',
-			// 	width: 130,
-			// 	height: 130,
-			// 	callback(e) {
-			// 		console.log(111111123)
-			// 		setTimeout(() => {
-			// 			// 获取图片数据
-			// 			uni.canvasGetImageData({
-			// 				canvasId: 'canvas',
-			// 				x: 0,
-			// 				y: 0,
-			// 				width: 130,
-			// 				height: 130,
-			// 				success(res) {
-			// 					let arr = tthis.convert4to1(res.data);
-			// 					let data = tthis.convert8to1(arr);
-			// 					const cmds = [].concat([27, 97, 1], [29, 118, 48, 0, 20, 0, 160, 0], data, [27, 74, 3], [27, 64]);
-			// 					const buffer = toArrayBuffer(Buffer.from(cmds, 'gb2312'));
-			// 					console.log(123456789)
-			// 					arrPrint.push(util.sendDirective([0x1B, 0x40]));
-			// 					for (let i = 0; i < buffer.byteLength; i = i + 20) {
-			// 						arrPrint.push(buffer.slice(i, i + 20));
-			// 					}
-			// 					arrPrint.push(util.hexStringToBuff("\n"));
-			// 					arrPrint.push(util.sendDirective([0x1B, 0x61, 0x01])); //居中
-			// 					arrPrint.push(util.hexStringToBuff("扫码采购花材\n"));
-			// 					arrPrint.push(util.hexStringToBuff("\n"));
-			// 					arrPrint.push(util.hexStringToBuff("\n"));
-			// 				}
-			// 			})
-			// 		}, 3000);
-			// 	}
-			// });
-			// this.printInfo({deviceId:deviceId, serviceId:serviceId, characteristicId:characteristicId}, arrPrint);
-
-		},
-
-			//4合1
-	convert4to1(res) {
-		let arr = [];
-		for (let i = 0; i < res.length; i++) {
-			if (i % 4 == 0) {
-				let rule = 0.29900 * res[i] + 0.58700 * res[i + 1] + 0.11400 * res[i + 2];
-				if (rule > 200) {
-					res[i] = 0;
-				} else {
-					res[i] = 1;
-				}
-				arr.push(res[i]);
-			}
-		}
-		return arr;
-	},
-
-	//8合1
-	convert8to1(arr) {
-		let data = [];
-		for (let k = 0; k < arr.length; k += 8) {
-			let temp = arr[k] * 128 + arr[k + 1] * 64 + arr[k + 2] * 32 + arr[k + 3] * 16 + arr[k + 4] * 8 + arr[k + 5] * 4 +
-				arr[k + 6] * 2 + arr[k + 7] * 1
-			data.push(temp);
-		}
-		return data;
-	},
-
-		printInfo(device, arr, callback) {
-			let tthis = this;
-			if (arr.length > 0) {
-				tthis.sendStr(device, arr[0], function(success) {
-					arr.shift();
-					tthis.printInfo(device, arr, callback);
-				}, function(error) {
-					console.log(error);
-				});
-			} else {
-				callback ? callback() : '';
-			}
-		},
-		//发送数据
-		sendStr(device, bufferstr, success, fail) {
-			let tthis = this;
-			uni.writeBLECharacteristicValue({
-				deviceId: device.deviceId,
-				serviceId: device.serviceId,
-				characteristicId: device.characteristicId,
-				value: bufferstr,
-				success: function(res) {
-					success(res);
-					console.log('sendStr', bufferstr)
-				},
-				failed: function(res) {
-					fail(res)
-					console.log("数据发送失败:" + JSON.stringify(res))
-				}
-			})
-		},
-	}
-}

+ 2 - 1
ghsPad/src/plugins/luch-request_0.0.7/request.js

@@ -69,7 +69,8 @@ class Request {
 		if (token) {
 			config.header['token'] = token
 		}
-		config.header['appVersion'] = 2
+		// 3=净余额;小票打印见 mixins/BLE.js
+		config.header['appVersion'] = 3
 		// const token = uni.getStorageSync('token')
 		// config.data = JSON.stringify(config.data);
 		config.headers = {

+ 16 - 20
hdApp/src/admin/home/components/purchase-ghs-panel.vue

@@ -121,29 +121,25 @@
                   </view>
                 </view>
 
-                <block v-if="Number(ghsInfo.balance) > 0">
-                  <view class="box_6 box_6--blue flex-row" v-if="ghsInfo.remainDebtAmount > 0"
-                    @click.stop="recharge(ghsInfo)">
-                    <view class="show_clear_area flex-row justify-between">
-                      <text class="waite_clear_order waite_clear_order--blue">
-                        <text v-if="Number(ghsInfo.balance) > 0">减去余额¥{{ ghsInfo.balance ? parseFloat(ghsInfo.balance) : 0
-                          }}</text>
-                        <text v-if="ghsInfo.remainDebtAmount > 0" class="ml-15">实欠¥{{ ghsInfo.remainDebtAmount }}</text>
-                      </text>
-                      <text class="clear-action clear-action--blue">按金额结算 ></text>
-                    </view>
+                <view class="box_6 box_6--blue flex-row" v-if="Number(ghsInfo.balance) < 0"
+                  @click.stop="recharge(ghsInfo)">
+                  <view class="show_clear_area flex-row justify-between">
+                    <text class="waite_clear_order waite_clear_order--blue">
+                      账户待结 ¥{{ Math.abs(parseFloat(ghsInfo.balance)) }}
+                    </text>
+                    <text class="clear-action clear-action--blue">按金额结算 ></text>
                   </view>
+                </view>
 
-                  <view class="box_6 box_6--blue flex-row" v-if="ghsInfo.remainDebtAmount < 0"
-                    @click.stop="recharge(ghsInfo)">
-                    <view class="show_clear_area flex-row justify-between">
-                      <text class="waite_clear_order waite_clear_order--blue">
-                        <text>账户余额¥{{ Math.abs(ghsInfo.remainDebtAmount) }}</text>
-                      </text>
-                      <text class="clear-action clear-action--blue">已结清</text>
-                    </view>
+                <view class="box_6 box_6--blue flex-row" v-if="Number(ghsInfo.balance) > 0"
+                  @click.stop="recharge(ghsInfo)">
+                  <view class="show_clear_area flex-row justify-between">
+                    <text class="waite_clear_order waite_clear_order--blue">
+                      账户余额¥{{ parseFloat(ghsInfo.balance) }}
+                    </text>
+                    <text class="clear-action clear-action--blue">充值/结算 ></text>
                   </view>
-                </block>
+                </view>
 
                 <block v-if="ghsInfo.live == 1">
                   <view class="button_7 flex-col" @click.stop="goKmCg(ghsInfo)"

+ 2 - 1
hdApp/src/plugins/luch-request_0.0.7/request.js

@@ -60,7 +60,8 @@ class Request {
 		if (token) {
 			config.header['token'] = token
 		}
-		config.header['appVersion'] = 2
+		// 3=净余额协议,与后端 AccountMoneyClass 一致(采购供货商卡片等)
+		config.header['appVersion'] = 3
 		// const token = uni.getStorageSync('token')
 		// config.data = JSON.stringify(config.data);
 		config.headers = {