diff --git a/Food/count/search.vue b/Food/count/search.vue index 13c8241..71673e3 100644 --- a/Food/count/search.vue +++ b/Food/count/search.vue @@ -302,9 +302,9 @@ watch: { bleValue: { handler(newVal, oldVal) { - this.realTimeWeight(newVal.countWeight, newVal.unit) - if (newVal.type == 2 && Number(newVal.countWeight) > 0) { - this.handletoggleUnit(newVal.countWeight, newVal.unit, this.activeType.nutrients_four) + this.realTimeWeight(newVal.foodWeight, newVal.foodUnit) + if (newVal.foodType == 2 && Number(newVal.foodWeight) > 0) { + this.handletoggleUnit(newVal.foodWeight, newVal.foodUnit, this.activeType.nutrients_four) } }, deep: true @@ -384,7 +384,7 @@ //实时重量 realTimeWeight(weight, unit) { this.activeType = Object.assign({}, this.activeType, { - weight: this.convertToGrams(weight, unit) + weight: this.$ble.convertToGrams(weight, unit) }) }, // 食物选择 @@ -398,17 +398,17 @@ that.activeType = ite that.weightKcal = ite.kcal if (that.bleValue.serviceId != "") { - that.realTimeWeight(that.bleValue.countWeight, that.bleValue.unit) - if (that.bleValue.type == 2 && Number(that.bleValue.countWeight) > 0) { - that.handletoggleUnit(that.bleValue.countWeight, that.bleValue.unit, ite.nutrients_four) + that.realTimeWeight(that.bleValue.foodWeight, that.bleValue.foodUnit) + if (that.bleValue.foodType == 2 && Number(that.bleValue.foodWeight) > 0) { + that.handletoggleUnit(that.bleValue.foodWeight, that.bleValue.foodUnit, ite.nutrients_four) } } else { - let weight = Number(that.bleValue.countWeight) > 0 ? Number(that.bleValue.countWeight) : 100 + let weight = Number(that.bleValue.foodWeight) > 0 ? Number(that.bleValue.foodWeight) : 100 that.$store.commit("changeBluetoothValue", { - countWeight: weight, - unit: that.bleValue.unit + foodWeight: weight, + foodUnit: that.bleValue.foodUnit }) - that.realTimeWeight(weight, that.bleValue.unit) + that.realTimeWeight(weight, that.bleValue.foodUnit) } }, @@ -523,14 +523,10 @@ eat_log_id: ite.food_id }).then(res => { that.ActiveList.splice(that.ActiveList.indexOf(ite), 1); - if (that.time == that.countFoodInfo.date) { - that.$store.dispatch("getUserInfoFood") - } else { - that.$store.dispatch("getCountFoodInfo", { - aud_id: that.user.aud_id, - time: that.time - }) - } + that.$store.dispatch("getCountFoodInfo", { + aud_id: that.user.aud_id, + time: that.time + }) that.handleAddEveryMealFood() }) } @@ -570,30 +566,10 @@ } return 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 - // "stlb": "floz": "lboz": - }; - - if (!conversionFactors.hasOwnProperty(fromUnit)) { - return '' - } - - return value * conversionFactors[fromUnit]; - }, - // 下发营养含量 handletoggleUnit(val, unit, ite) { let that = this - let weight = Number(that.convertToGrams(val, unit)) / 100 + let weight = Number(that.$ble.convertToGrams(val, unit)) / 100 const dataArray = that.buildNutritionData({ fat: weight * ite[2].value, calorie: weight * ite[0].value, @@ -676,7 +652,7 @@ uni.writeBLECharacteristicValue({ deviceId: that.bleValue.deviceId, serviceId: that.bleValue.serviceId, - characteristicId: that.bleValue.write, + characteristicId: that.bleValue.foodWrite, value: buffer, success: res => { console.log('下发指令成功', res.errMsg) @@ -1246,7 +1222,6 @@ justify-content: space-between; border-bottom: 1px solid #f1f1f1; padding: 16rpx 0; - font-size: 24rpx; margin-top: 10rpx; } diff --git a/Food/me/menudetail.vue b/Food/me/menudetail.vue index 1b68c47..0b619cc 100644 --- a/Food/me/menudetail.vue +++ b/Food/me/menudetail.vue @@ -298,14 +298,18 @@ time: that.$tools.getDate("start") }).then(res => { if (res.code != 0) return - that.$store.dispatch("getUserInfoFood") + that.$store.dispatch("getCountFoodInfo", { + aud_id: that.user.aud_id, + time: that.$tools.getDate("start") + }) uni.showToast({ title: '保存成功', icon: 'success' }) - // uni.switchTab({ - // url: "/pages/count/count" - // }) + that.$store.commit("changehomeCard", 1); + uni.switchTab({ + url: "/pages/index/index" + }) }) } that.showSaveFood = false diff --git a/body/login/login.vue b/body/login/login.vue index bb5fbd5..6b6f0e2 100644 --- a/body/login/login.vue +++ b/body/login/login.vue @@ -137,7 +137,7 @@ }) setTimeout(function() { uni.reLaunch({ - url: "/pages/home/home" + url: "/pages/index/index" }) }, 1000) }).catch(err => {}) @@ -285,7 +285,6 @@ button { line-height: initial; - background: #fff; display: flex; flex-wrap: wrap; padding: 0; diff --git a/components/bodyIndex/drawer.vue b/components/bodyIndex/drawer.vue index 0cc87d0..27d1e32 100644 --- a/components/bodyIndex/drawer.vue +++ b/components/bodyIndex/drawer.vue @@ -58,6 +58,7 @@ that.$store.dispatch("getResult", { aud_id: val.id }) + that.$store.commit("changehomeCard", 0); that.$store.commit("changeDrawe", false); // that.handlePublicRecord(val.id) }, diff --git a/components/bodyIndex/record.vue b/components/bodyIndex/record.vue index 6b09773..f4e0e9b 100644 --- a/components/bodyIndex/record.vue +++ b/components/bodyIndex/record.vue @@ -26,7 +26,7 @@ kg - + 头围 cm diff --git a/components/foodIndex/bluetooth.vue b/components/foodIndex/bluetooth.vue index d8af33e..b349011 100644 --- a/components/foodIndex/bluetooth.vue +++ b/components/foodIndex/bluetooth.vue @@ -1,7 +1,7 @@