From 66b2cdf8f2713ff1e60748a5074c3d6dccaf21ff Mon Sep 17 00:00:00 2001 From: qcl_123 <5212384+qcl_123@user.noreply.gitee.com> Date: Tue, 10 Feb 2026 11:20:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=BE=E5=A4=87C06/C09PRO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/bluetooth.vue | 209 +++++++++++------- components/bluetooth_food.vue | 1 - pageTwo/count/everyMeal.vue | 7 +- pageTwo/me/menuEdit.vue | 6 +- pageTwo/me/menudetail.vue | 20 +- pageTwo/me/mymenu.vue | 2 +- pages/add/add.vue | 4 +- pages/count/count.vue | 7 +- .../.sourcemap/mp-weixin/common/main.js.map | 2 +- .../mp-weixin/components/bluetooth.js.map | 2 +- .../components/bluetooth_food.js.map | 2 +- .../mp-weixin/components/search.js.map | 2 +- .../mp-weixin/components/search2.js.map | 2 +- .../mp-weixin/pageTwo/count/KcalEdit.js.map | 2 +- .../mp-weixin/pageTwo/count/everyDay.js.map | 2 +- .../mp-weixin/pageTwo/count/everyMeal.js.map | 2 +- .../mp-weixin/pageTwo/count/search.js.map | 2 +- .../mp-weixin/pageTwo/count/setting.js.map | 2 +- .../pageTwo/login/forgetPassword.js.map | 2 +- .../mp-weixin/pageTwo/login/login.js.map | 2 +- .../mp-weixin/pageTwo/me/feedBack.js.map | 2 +- .../mp-weixin/pageTwo/me/foodlist.js.map | 2 +- .../mp-weixin/pageTwo/me/menuEdit.js.map | 2 +- .../mp-weixin/pageTwo/me/menudetail.js.map | 2 +- .../mp-weixin/pageTwo/me/mymenu.js.map | 2 +- .../mp-weixin/pageTwo/me/record.js.map | 2 +- .../mp-weixin/pageTwo/me/recordetail.js.map | 2 +- .../mp-weixin/pageTwo/me/userEdit.js.map | 2 +- .../mp-weixin/pageTwo/setting/email.js.map | 2 +- .../mp-weixin/pageTwo/setting/password.js.map | 2 +- .../mp-weixin/pageTwo/setting/phone.js.map | 2 +- .../mp-weixin/pageTwo/setting/setting.js.map | 2 +- .../mp-weixin/pages/add/Preview.js.map | 2 +- .../.sourcemap/mp-weixin/pages/add/add.js.map | 2 +- .../mp-weixin/pages/count/count.js.map | 2 +- .../mp-weixin/pages/index/index.js.map | 2 +- .../.sourcemap/mp-weixin/pages/me/me.js.map | 2 +- .../mp-weixin/pages/menu/menu.js.map | 2 +- .../mp-weixin/pages/search/list.js.map | 2 +- .../mp-weixin/pages/search/search.js.map | 2 +- .../llt-slider-range/llt-slider-range.js.map | 2 +- .../components/qiun-data-charts.js.map | 2 +- .../components/uni-icons/uni-icons.js.map | 2 +- .../uni-popup-dialog/uni-popup-dialog.js.map | 2 +- .../components/uni-popup/uni-popup.js.map | 2 +- .../uni-swipe-action-item.js.map | 2 +- .../dev/mp-weixin/components/bluetooth.js | 202 ++++++++++------- .../dev/mp-weixin/components/bluetooth.wxml | 2 +- .../dev/mp-weixin/components/bluetooth.wxss | 9 + .../mp-weixin/components/bluetooth_food.js | 1 - .../mp-weixin/pageTwo/count/everyMeal.wxss | 4 + .../dist/dev/mp-weixin/pageTwo/me/menuEdit.js | 4 + .../dev/mp-weixin/pageTwo/me/menudetail.js | 10 +- .../dev/mp-weixin/pageTwo/me/menudetail.wxml | 2 +- .../dist/dev/mp-weixin/pageTwo/me/mymenu.wxml | 2 +- unpackage/dist/dev/mp-weixin/pages/add/add.js | 4 +- .../dist/dev/mp-weixin/pages/count/count.wxss | 4 + .../dev/mp-weixin/project.private.config.json | 2 +- 58 files changed, 364 insertions(+), 214 deletions(-) diff --git a/components/bluetooth.vue b/components/bluetooth.vue index 8de34e0..088b2b9 100644 --- a/components/bluetooth.vue +++ b/components/bluetooth.vue @@ -5,13 +5,16 @@ {{bleTipsText}} + + 断开连接 + {{name}} {{weight == '' ? '0.0':weight}} - {{unit}} + {{unitConversion(unit)}} {{kcal?kcal:0}} @@ -22,7 +25,7 @@ - 单位 @@ -52,26 +55,12 @@ data() { return { kcal: "", - // weight: "", weightALL: "", bleTipsText: "", unit: 'g', - weight0: 0, + unitA: [], stopblue: false, - devicesList: [], - unitList: [{ - name: "克", - id: '00', - unit: "g" - }, { - name: "盎司", - id: "08", - unit: "oz" - }], unitListIndex: 0, - units: ['kg', '斤', 'st:lb', 'lb', 'g', 'ml', 'Waterml', - 'milkml', 'oz', 'floz', 'lboz' - ] } }, props: { @@ -91,15 +80,18 @@ computed: { ...mapState(["user", "isBluetoothTyle", "bleValue"]), weight() { - let kcal = (Number(this.weightKcal) * this.bleValue.countWeight).toFixed(2) - this.unit = this.unitConversion(this.bleValue.unit) - this.kcal = this.convertToGrams(kcal, this.bleValue.unit).toFixed(2) + let weightNew = this.convertToGrams(this.bleValue.countWeight, this.bleValue.unit) + this.kcal = (Number(this.weightKcal) * weightNew).toFixed(1) + this.unit = this.bleValue.unit return this.bleValue.countWeight }, isConnection() { this.bleTipsText = this.bleValue.bleTipsText return this.bleValue.isConnectStatus }, + isShow() { + return this.bleValue.serviceId != '' ? true : false + }, }, mounted() { let that = this @@ -114,10 +106,22 @@ that.handleBack() } }, - isLast: function() { - let that = this - that.stopblue = that.isLast - } + isLast: { + handler(newVal, oldVal) { + this.stopblue = newVal + }, + // deep: true, + immediate: true + + }, + bleValue: { + handler(newVal, oldVal) { + this.unitA = newVal.unitList + this.unitListIndex = newVal.unitList.findIndex(ite => ite.unit == newVal.unit) + }, + deep: true, + immediate: true + }, }, methods: { // 初始化蓝牙 @@ -131,6 +135,8 @@ notify: '', write: '', unit: "g", + type: 1, + unitList: that.$json.unitMinus, countWeight: "", bleTipsText: "蓝牙搜索中", isConnectStatus: 0, @@ -139,17 +145,63 @@ }, changleUnits(e) { let that = this - let name = that.unitList[e.detail.value].name - console.log("单位切换", name, that.unit) - if (that.unit != name) { - that.handletoggleUnit(name == '盎司' ? 0x08 : 0x04) + let name = that.unitA[e.detail.value].name + let val = that.unitA[e.detail.value].unit + if (that.isShow && that.unit != name) { + that.handletoggleUnit(that.unitConversion2(val)) + } + if (that.bleValue.serviceId == '') { + that.unitListIndex = [e.detail.value] + that.$store.commit('changeBluetoothValue', { + unit: that.unitA[e.detail.value].unit, + }) } - that.unitListIndex = [e.detail.value] - that.$store.commit('changeBluetoothValue', { - unit: that.unitList[e.detail.value].unit - }) - }, + convertToGrams(value, fromUnit) { + const conversionFactors = { + 'lb': 453.59237, // 1磅 = 453.59237克 + 'oz': 28.349523125, // 1盎司 = 28.349523125克 + 'kg': 1000, // 1公斤 = 1000克 + 'g': 1, + 'ml': 1, + '斤': 500, + 'Waterml': 1, + 'milkml': 1.03 + }; + + if (!conversionFactors.hasOwnProperty(fromUnit)) { + return '' + } + + return value * conversionFactors[fromUnit]; + }, + unitConversion2(unit) { + if (unit == 'kg') { + return 0x00 + } else if (unit == '斤') { + return 0x01 + } else if (unit == 'st:lb') { + return 0x02 + } else if (unit == 'lb') { + return 0x03 + } else if (unit == 'g') { + return 0x04 + } else if (unit == 'ml') { + return 0x05 + } else if (unit == 'Waterml') { + return 0x06 + } else if (unit == 'milkml') { + return 0x07 + } else if (unit == 'oz') { + return 0x08 + } else if (unit == 'floz') { + return 0x09 + } else if (unit == 'lboz') { + return 0x0A + } + return unit + }, + // 下发单位 handletoggleUnit(unit) { let that = this let checksum = 0; @@ -184,30 +236,43 @@ }, }) }, - // 保存测量结果 - handlesub() { + handleBack() { let that = this - console.log("测量保存", that.weight, that.unit, that.kcal) - if (Number(that.weight) > 0) { - that.$emit("handleBle", that.weight, that.unit, that.kcal) - } else { - that.$tools.msg("数据异常,请清零后重新测量!") - } - + that.$store.commit("changeBluetoothValue", { + bleTipsText: "连接失败,点击重新连接", + unitList: that.$json.unitMinus, + isConnectStatus: 1, + }) + that.$ble.stopBluetoothDevicesDiscovery() //取消蓝牙搜索 + that.$ble.closeBLEConnection(that.bleValue.deviceId) + that.$ble.closeBluetoothAdapter() }, - convertToGrams(value, fromUnit) { - const conversionFactors = { - 'lb': 453.59, // 1磅 = 453.59237克 - 'oz': 28.35, // 1盎司 = 28.349523125克 - 'kg': 1000, // 1公斤 = 1000克 - 'g': 1 - }; - if (!conversionFactors.hasOwnProperty(fromUnit)) { - return '' + unitConversion(unit) { + if (unit == 'kg') { + return '千克' + } else if (unit == '斤') { + return '斤' + } else if (unit == 'stlb') { + return 'stlb' + } else if (unit == 'lb') { + return '磅' + } else if (unit == 'g') { + return '克' + } else if (unit == 'ml') { + return '毫升' + } else if (unit == 'Waterml') { + return 'Waterml' + } else if (unit == 'milkml') { + return 'milkml' + } else if (unit == 'oz') { + return '盎司' + } else if (unit == 'floz') { + return 'floz' + } else if (unit == 'lboz') { + return 'lboz' } - - return value * conversionFactors[fromUnit]; + return unit }, // 备料完成 handleDetailSub() { @@ -215,7 +280,7 @@ if (Number(that.weight) > 0) { that.$emit("handleDetailSub", that.weight, that.unit, that.kcal) } else { - that.$tools.msg("数据异常,请重新测量!") + that.$tools.msg("数据异常,请清零后重新测量!") } }, //备料下一个 @@ -227,33 +292,12 @@ that.$tools.msg("数据异常,请清零后重新测量!") } }, - unitConversion(unit) { - if (unit == 'kcal') { - return '千卡' - } else if (unit == 'g') { - return '克' - } else if (unit == 'lb') { - return '磅' - } else if (unit == 'oz') { - return '盎司' - } - return unit - }, - handleBack() { - let that = this - that.$store.commit("changeBluetoothValue", { - bleTipsText: "连接失败,点击重新连接", - isConnectStatus: 1 - }) - that.$ble.stopBluetoothDevicesDiscovery() //取消蓝牙搜索 - that.$ble.closeBLEConnection(that.bleValue.deviceId) - that.$ble.closeBluetoothAdapter() - }, confirm(value) { - console.log("手动输入", value) + console.log(value) + let that = this this.$store.commit("changeBluetoothValue", { countWeight: value, - unit: this.unitList[this.unitListIndex].unit + unit: this.unitA[this.unitListIndex].unit }) this.$refs.popup.close() }, @@ -395,6 +439,15 @@ } } + .duan { + width: fit-content; + background: linear-gradient(-90deg, #d4f5c4, #a7d5e4 80%, ); + border-radius: 5px; + text-align: center; + padding: 3px 10px; + font-size: 12px; + } + .name { width: 100%; text-align: center; diff --git a/components/bluetooth_food.vue b/components/bluetooth_food.vue index f49615d..bdc2126 100644 --- a/components/bluetooth_food.vue +++ b/components/bluetooth_food.vue @@ -110,7 +110,6 @@ handler(newVal, oldVal) { this.unitA = newVal.unitList this.unitListIndex = newVal.unitList.findIndex(ite => ite.unit == newVal.unit) - console.log("2222222222", newVal.unit) }, deep: true, immediate: true diff --git a/pageTwo/count/everyMeal.vue b/pageTwo/count/everyMeal.vue index a29a355..0b01fcc 100644 --- a/pageTwo/count/everyMeal.vue +++ b/pageTwo/count/everyMeal.vue @@ -1,5 +1,5 @@