首页搜索蓝牙跳计食页面

This commit is contained in:
qcl_123 2025-11-29 10:02:33 +08:00
parent 761d0f997a
commit d00d45873a
77 changed files with 1744 additions and 1635 deletions

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@
<view class="weight-wrap">
<!-- 蓝牙称重 -->
<view class="weight" @click="inputDialogToggle">
<text class="val">{{weight == '' ? '--':weight}}</text>
<text class="val">{{weight == '' ? '0.0':weight}}</text>
<text class="unit">{{unit}}</text>
</view>
</view>
@ -90,6 +90,7 @@
computed: {
...mapState(["bleValue", "isBluetoothTyle", "countFoodInfo"]),
weight() {
this.kcal = (Number(this.weightKcal) / 100 * this.bleValue.countWeight).toFixed(2)
this.unit = this.unitConversion(this.bleValue.unit)
return this.bleValue.countWeight
},
@ -97,10 +98,10 @@
this.bleTipsText = this.bleValue.bleTipsText
return this.bleValue.isConnectStatus
},
isShow(){
isShow() {
return this.bleValue.serviceId != '' ? true : false
}
},
mounted() {
let that = this
@ -133,7 +134,7 @@
notify: '',
write: '',
unit: "g",
countWeight:"",
countWeight: "",
bleTipsText: "蓝牙搜索中",
isConnectStatus: 0,
})
@ -189,7 +190,7 @@
//
handlesub() {
let that = this
console.log("weight", that.weight)
console.log("测量保存", that.weight, that.unit, that.kcal)
if (Number(that.weight) > 0) {
that.$emit("handleBle", that.weight, that.unit, that.kcal)
} else {

View File

@ -17,7 +17,7 @@
<view class="progress">
<div class="chart-wrap">
<qiun-data-charts type="ring" :opts="opts" canvasId="foodCharts" :chartData="chartData"
:cHeight="280" :cWidth="280" />
:cHeight="280" :cWidth="280" :canvas2d="true" />
</div>
<view class="info" v-if="info.nutrients_four">
<view class="info-item" v-for="(item,index) in info.nutrients_four.slice(1)" :key="index">
@ -145,7 +145,11 @@
bgimage: "",
page: "",
index: "",
info: {}
info: {
date: "",
list: [],
nutrients_four: [],
}
}
},
components: {
@ -443,6 +447,6 @@
width: 100%;
text-align: center;
font-weight: bold;
margin-top: 10px;
margin: 30rpx 0;
}
</style>

View File

@ -81,7 +81,7 @@
<view class="title">热量和营养</view>
<view class="progress">
<div class="chart-wrap">
<qiun-data-charts type="ring" :opts="opts" :canvas2d="true" canvasId="foodCharts" :chartData="chartData" :cHeight="250"
<qiun-data-charts type="ring" :opts="opts" :canvas2d="true" canvasId="foodCharts2" :chartData="chartData" :cHeight="250"
:cWidth="250" />
<view class="uchart-kcal">{{Math.floor(activeType.kcal*activeType.weight/100)}}</view>
</div>

View File

@ -133,7 +133,7 @@
<view class="foodContent">
<view class="tips">
<text>营养素</text>
<text>{{Math.floor(activeType.weight)}}含量</text>
<text>{{Math.floor(activeType.weight)}}含量</text>
</view>
<view class="foodDetailList">
<view class="foodDetailItem" v-for="(item,index) in activeType.nutrients_list"
@ -284,7 +284,7 @@
},
//
realTimeWeight(weight, unit) {
console.log("实时重量", weight, unit)
// console.log("", weight, unit)
this.activeType = Object.assign({}, this.activeType, {
weight: this.convertToGrams(weight, unit)
})
@ -299,8 +299,8 @@
},
convertToGrams(value, fromUnit) {
const conversionFactors = {
'lb': 453.59237, // 1 = 453.59237
'oz': 28.349523125, // 1 = 28.349523125
'lb': 453.59, // 1 = 453.59237
'oz': 28.35, // 1 = 28.349523125
'kg': 1000, // 1 = 1000
'g': 1
};
@ -318,6 +318,8 @@
that.isShop = false
that.IsWeight = true
that.activeType = ite
that.weightKcal = ite.kcal
console.log("111111", ite, that.bleValue)
if (that.bleValue.serviceId != "") {
that.realTimeWeight(that.bleValue.countWeight, that.bleValue.unit)
} else {
@ -327,7 +329,6 @@
})
that.realTimeWeight(100, "g")
// that.activeType.weight = 100
// that.weightKcal = that.activeType.kcal
// let chart_data = []
// that.opts.color = []
// for (let i = 1; i < ite.nutrients_four.length; ++i) {
@ -354,6 +355,7 @@
that.activeType.weight = weight
that.activeType.meals_type = that.foodName
list.push(that.activeType)
console.log("list", list)
that.$model.getAddIntakeFood({
aud_id: that.user.aud_id,
food_list: list,
@ -1145,13 +1147,14 @@
width: 100%;
height: 45px;
display: flex;
padding: 5px 0;
position: relative;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid #f7f7f7;
.item-left {
width: 80%;
width: calc(100% - 40px);
display: flex;
align-items: center;
@ -1163,10 +1166,14 @@
}
.name {
width: calc(100% - 100rpx);
display: flex;
flex-direction: column;
margin-left: 10px;
height: 40px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
justify-content: space-between;
text {

View File

@ -149,6 +149,7 @@
}).then(res => {
if (res.code == 0) {
that.$tools.msg("设置成功")
that.$store.dispatch("getUserInfo")
setTimeout(function() {
uni.switchTab({
url: '/pages/count/count'

View File

@ -6,11 +6,6 @@
<view class="searchInput">
<input placeholder="请输入..." class="city-serach-input" v-model="search_value" />
<icon v-if="search_value" class="iconfont icon-error" @click="handlecolse"></icon>
<view class="voice" v-if="!search_value">
<uni-icons class="mic" type="mic-filled" size="26" @click="onShowSearchType(1)"></uni-icons>
<uni-icons class="camera" type="camera-filled" size="26"
@click="onShowSearchType(2)"></uni-icons>
</view>
</view>
<view class="searchBtn">
<view @click="handleSerach">搜索</view>
@ -23,12 +18,12 @@
<view class="title">
<view class="quan mr-5"></view>历史搜索
</view>
<view class="button-container" @click="showAll =! showAll" v-if="history_food.length>10">
<view class="button-container" @click="showAll =! showAll" v-if="history_food.length>8">
<image :src="showAll?'/static/arrow-up.png':'/static/arrow-down.png'"></image>
</view>
<view class="history-list">
<view class="history-list-item"
v-for="(item,index) in showAll?history_food:history_food.slice(0, 10)"
v-for="(item,index) in showAll?history_food:history_food.slice(0, 8)"
@click="handleSearchHistory(item.keyword)">
{{item.keyword}}
</view>
@ -62,30 +57,19 @@
</view>
<view class="endtext" v-if="!lastPage || page >= lastPage"> 到底了看看别的吧 </view>
</view>
<!-- 语音描述 -->
<view class="auto-search-dialog" v-if="showAutoSearchDlg">
<view class="auto-search-inner">
<text>{{autoSearchContent != '' ? `识别到你描述的食材为“${autoSearchContent}”,是否查找食材“${autoSearchContent}` : "长安麦克风图标开始说话,松开后结束"}}</text>
<view class="mic-icon" :style="{'border-color':mic_touch ? '#18bc37' : '#777777'}"
@touchstart="onVoiceTouchStart" @touchend="onVoiceTouchEnd"
v-if="autoSearchContent == ''">
<uni-icons type="mic-filled" size="80" :color="mic_touch ? '#18bc37' : '#777777'"></uni-icons>
</view>
<view class="btn-wrap" v-else>
<view class="retry" @click="retrySearch">重试</view>
<view class="confirm" @click="handleVoiceSearch(autoSearchContent)">确定</view>
</view>
<uni-icons class="close" type="close" color="#ffffff" size="45"
@click="showAutoSearchDlg=false"></uni-icons>
</view>
</view>
<!-- 底部购物车 -->
<view class="groupbtn" v-if="ActiveList.length">
<view class="che" @click="isShop =! isShop">
<text v-if="ActiveList.length">{{ActiveList.length}}</text>
<icon class="t-icon t-icon-canpan"></icon>
<view class="groupbtn">
<view class="jilu">
<view class="che" @click="isShop =! isShop">
<text>{{ActiveList.length||0}}</text>
<icon class="t-icon t-icon-canpan"></icon>
</view>
<view class="subbtn" @click="handlesubbtn"> 确定</view>
</view>
<view class="mic-icon" @touchstart="onVoiceTouchStart" @touchend="onVoiceTouchEnd">
<uni-icons type="mic-filled" size="20" :color="mic_touch ? '#777777' : '#fff'"></uni-icons>
语音搜索
</view>
<view class="subbtn" @click="handlesubbtn"> 确定</view>
</view>
<!-- 购物车列表 -->
<view class="wrapper activeList" v-if="isShop">
@ -185,20 +169,13 @@
}
}
},
onShowSearchType(type) {
let that = this
console.log("autoSearchType", type, that.autoSearchContent)
this.autoSearchType = type
if (type == 1) {
that.showAutoSearchDlg = true
} else if (type == 2) {
that.selectPhoto()
}
},
//
handleSerach() {
let that = this
if (that.search_value == "") {
that.$tools.msg("输入关键字后搜索")
return
}
that.search_list = []
that.$model.getFoodSearch({
page: that.page,
@ -219,15 +196,6 @@
this.search_value = ""
this.search_list = []
},
handleVoiceSearch() {
let that = this
if (that.autoSearchContent != '') {
that.search_value = that.autoSearchContent
that.showAutoSearchDlg = false
that.autoSearchContent = ''
that.handleSerach()
}
},
//
handleSearchHistory(text) {
let that = this
@ -236,15 +204,6 @@
that.autoSearchContent = ''
that.handleSerach()
},
//
retrySearch() {
let that = this
that.autoSearchContent = ''
if (that.autoSearchType == 2) {
that.showAutoSearchDlg = false
that.selectPhoto()
}
},
//
onVoiceTouchStart() {
let that = this
@ -260,46 +219,6 @@
that.mic_touch = false
that.voiceManager.stop()
},
selectPhoto() {
let that = this
uni.chooseMedia({
count: 1,
mediaType: ['image'],
sourceType: ['album', 'camera'],
sizeType: ['compressed'],
camera: 'back',
success(res) {
const tempFilePath = res.tempFiles[0].tempFilePath
uni.getFileSystemManager().readFile({
filePath: tempFilePath,
encoding: 'base64',
success: (res) => {
const base64 = 'data:image/jpeg;base64,' + res.data
uni.showLoading({
title: '图片识别中...',
mask: true
})
that.$model.getPhotoSearch({
img_str: base64,
}).then(res => {
uni.hideLoading()
if (res.code != 0) return
that.autoSearchContent = res.data.name
that.showAutoSearchDlg = true
})
},
fail: (err) => {
console.error('读取文件失败:', err)
}
})
},
fail(err) {
console.error('拍照失败:', err)
}
})
},
//
handlesubbtn() {
let that = this
@ -457,7 +376,7 @@
.popular-container {
width: 100%;
margin-top: 30rpx;
margin-bottom: 80px;
margin-bottom: 120px;
.popular-food-item {
display: flex;
@ -499,7 +418,7 @@
display: flex;
padding: 0 20rpx;
flex-wrap: wrap;
margin: 75px 20rpx 90px;
margin: 75px 20rpx 120px;
width: calc(100% - 80rpx);
justify-content: space-between;
background: #fff;
@ -606,7 +525,7 @@
.activeList {
z-index: 12;
bottom: 100rpx;
bottom: 200rpx;
.box2 {
height: 500rpx;
@ -614,7 +533,7 @@
position: absolute;
width: 100%;
bottom: 70px;
padding-bottom: 90px;
padding-bottom: 120px;
border-radius: 20rpx 20rpx 0 0;
}
@ -642,21 +561,29 @@
bottom: 0;
left: 0;
right: 0;
height: 55px;
height: 90px;
z-index: 99;
flex-wrap: wrap;
background-color: #fff;
overflow: hidden;
box-shadow: 0px 1px 5px 2px #dfe2e1fc;
.subbtn {
color: #fff;
width: 40%;
width: 60%;
text-align: center;
border-radius: 20rpx;
height: 35px;
line-height: 35px;
background-color: #f0ae43;
}
.jilu{
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
.che {
width: 120rpx;
@ -694,6 +621,17 @@
background-color: #f0ae43;
}
.mic-icon {
color: #fff;
width: 100%;
padding: 8px 0;
background: $maincolor;
display: flex;
align-items: center;
justify-content: center;
border-radius: 20rpx;
}
.button-container {
position: absolute;
top: 20rpx;

File diff suppressed because it is too large Load Diff

View File

@ -81,7 +81,7 @@
<view class="title">热量和营养</view>
<view class="progress">
<div class="chart-wrap">
<qiun-data-charts type="ring" :opts="opts" :canvas2d="true" canvasId="foodCharts"
<qiun-data-charts type="ring" :opts="opts" :canvas2d="true" canvasId="recordetailCharts"
:chartData="chartData2" :cHeight="250" :cWidth="250" />
<view class="uchart-kcal">{{activeFoodDetail.val}}</view>
</div>

View File

@ -36,7 +36,7 @@
<view class="left">
<view class="chart-wrap">
<qiun-data-charts type="arcbar" :chartData="chartData" :cHeight="280" :cWidth="280"
:canvas2d="true" canvasId="count1" />
:canvas2d="true" canvasId="countCharts" v-if="handTrue" />
<view class="center">
摄入
<text>{{foodInfo.nutrients_four[0].today_intake}}</text>
@ -132,7 +132,7 @@
<view class="progress">
<div class="chart-wrap">
<qiun-data-charts type="ring" :opts="opts" :chartData="chartData2" :cHeight="280"
:cWidth="280" :canvas2d="true" canvasId="count2"/>
:cWidth="280" />
</div>
<view class="info" v-if="activeFoodDetail.nutrients_four">
<view class="info-item" v-for="(item,index) in activeFoodDetail.nutrients_four.slice(1)"
@ -186,7 +186,7 @@
}]
},
isBle: true,
// countWeight: 0,
handTrue: false,
chartData2: {},
activeFoodDetail: {},
actionOptions: [{
@ -206,7 +206,11 @@
...mapState(["user", "countFoodInfo"]),
foodInfo() {
let that = this
that.chartData.series[0].data = that.countFoodInfo.nutrients_four[0].proportion / 100
that.handTrue = false
this.$nextTick(() => {
that.handTrue = true
that.chartData.series[0].data = Number(that.countFoodInfo.nutrients_four[0].proportion) / 100
})
return that.countFoodInfo
},
endDate() {
@ -217,6 +221,16 @@
let that = this
that.token = uni.getStorageSync('token')
},
onPullDownRefresh() {
let that = this
that.$store.dispatch("getCountFoodInfo", {
aud_id: that.user.aud_id,
time: that.tools.getDate("start")
})
setTimeout(function() {
uni.stopPullDownRefresh();
}, 500);
},
methods: {
//
showFoodDetail(item) {
@ -294,13 +308,14 @@
aud_id: that.user.aud_id,
eat_log_id: item.id
}).then(res => {
that.$store.dispatch("getCountFoodInfo", {
aud_id: that.user.aud_id,
time: that.foodInfo.date
})
//
if (that.foodInfo.date == that.user.food_count.date) {
that.$store.dispatch("getUserInfo")
} else {
that.$store.dispatch("getCountFoodInfo", {
aud_id: that.user.aud_id,
time: that.foodInfo.date
})
}
})
}

View File

@ -48,8 +48,8 @@
</view>
<view class="left">
<view class="chart-wrap">
<qiun-data-charts type="arcbar" :chartData="chartData" :cHeight="280" :cWidth="280" :canvas2d="true"
canvasId="home1" />
<qiun-data-charts v-if="handTrue" type="arcbar" :chartData="chartData" :cHeight="280"
:cWidth="280" />
<view class="center">
摄入
<text>{{foodInfo.nutrients_four[0].today_intake}}</text>
@ -95,7 +95,6 @@
添加
</view>
<view class="add" @click="navTo('/pageTwo/count/everyMeal?page=home&index='+ind)">
<!-- <uni-icons type="forward" size="18" color="#999"></uni-icons> -->
<image src="/static/xiangqing.png"></image>
</view>
</view>
@ -134,14 +133,15 @@
data() {
return {
token: "",
foodInfo: {
date: "",
list: [],
details: {},
remaining_kcal: 0,
nutrients_four: [],
trace_elements_all_day: []
},
handTrue: false,
// foodInfo: {
// date: "",
// list: [],
// details: {},
// remaining_kcal: 0,
// nutrients_four: [],
// trace_elements_all_day: []
// },
unwatch: null,
chartData: {
series: [{
@ -162,6 +162,15 @@
kcalVal() {
return this.configInfo.kcal_data
},
foodInfo() {
let that = this
this.handTrue = false
this.$nextTick(() => {
this.handTrue = true
that.chartData.series[0].data = this.user.aud_id != "" ? Number(this.user.food_count.nutrients_four[0].proportion) / 100 : 0
})
return this.user.aud_id != "" ? this.user.food_count : this.configInfo.default_count_foot
}
},
onLoad() {
let that = this
@ -175,34 +184,37 @@
that.$store.commit("changeBluetooth", res.available);
})
},
watch: {
user: {
handler(newVal, oldVal) {
let that = this
that.foodInfo = that.user.aud_id != "" ? that.user.food_count : that.configInfo.default_count_foot
that.chartData.series[0].data = newVal.aud_id != "" ? newVal.food_count.nutrients_four[0].proportion /
100 : 0
},
immediate: true,
deep: true
},
},
onPullDownRefresh() {
let that = this
that.index = 0
that.footlist = []
that.chartData.series[0].data = 0
that.$store.dispatch("getHomeConfig")
setTimeout(function() {
uni.stopPullDownRefresh();
}, 500);
},
onShow() {
let that = this
that.handTrue = false
this.$nextTick(() => {
that.handTrue = true
that.chartData.series[0].data = that.user.aud_id != ""?Number(that.user.food_count.nutrients_four[0].proportion) / 100:0
})
this.startWatching()
},
onHide() {
this.stopWatching()
},
methods: {
handleInfo() {
let that = this
this.$nextTick(() => {
that.chartData.series[0].data = that.user.aud_id == "" ? 0 : Number(that.user.food_count
.nutrients_four[0]
.proportion) / 100
})
},
startWatching() {
this.unwatch = this.$watch('bleValue', (newVal, oldVal) => {
//

View File

@ -38,6 +38,7 @@ export default new Vuex.Store({
cookbook: [],
food: []
},
cookbook_label: [],
activity_level: [],
default_count_foot: {},
business_cooperation: {}

View File

@ -133,15 +133,8 @@ function getBLEDeviceCharacteristics(deviceId, serviceId) {
notify = item.uuid
}
}
$store.commit('changeBluetoothValue', {
deviceId: deviceId,
serviceId: serviceId,
notify: notify,
write: write,
unit: "g",
countWeight: "",
})
getBLECharacteristicValueChange(deviceId, serviceId, notify)
getBLECharacteristicValueChange(deviceId, serviceId, notify,write)
},
fail: res => {
console.log('获取特征值失败:', JSON.stringify(res))
@ -149,7 +142,7 @@ function getBLEDeviceCharacteristics(deviceId, serviceId) {
})
}
function getBLECharacteristicValueChange(deviceId, serviceId, notify) {
function getBLECharacteristicValueChange(deviceId, serviceId, notify,write) {
let that = this
uni.notifyBLECharacteristicValueChange({
deviceId: deviceId,
@ -157,7 +150,13 @@ function getBLECharacteristicValueChange(deviceId, serviceId, notify) {
characteristicId: notify,
state: true,
success: () => {
$store.commit("changeBluetoothValue", {
$store.commit('changeBluetoothValue', {
deviceId: deviceId,
serviceId: serviceId,
notify: notify,
write: write,
unit: "g",
countWeight: "",
bleTipsText: "测量中,请将食物放到秤上",
isConnectStatus: 0
})
@ -194,7 +193,7 @@ function getBLECharacteristicValueChange(deviceId, serviceId, notify) {
if (isNegative) finalWeight = -finalWeight
$store.commit("changeBluetoothValue", {
countWeight: finalWeight,
unit: units[unitIndex]
unit: units[unitIndex],
})
break

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -28069,6 +28069,7 @@ var _default = new _vuex.default.Store({
cookbook: [],
food: []
},
cookbook_label: [],
activity_level: [],
default_count_foot: {},
business_cooperation: {}
@ -29226,22 +29227,14 @@ function getBLEDeviceCharacteristics(deviceId, serviceId) {
notify = item.uuid;
}
}
_store.default.commit('changeBluetoothValue', {
deviceId: deviceId,
serviceId: serviceId,
notify: notify,
write: write,
unit: "g",
countWeight: ""
});
getBLECharacteristicValueChange(deviceId, serviceId, notify);
getBLECharacteristicValueChange(deviceId, serviceId, notify, write);
},
fail: function fail(res) {
console.log('获取特征值失败:', JSON.stringify(res));
}
});
}
function getBLECharacteristicValueChange(deviceId, serviceId, notify) {
function getBLECharacteristicValueChange(deviceId, serviceId, notify, write) {
var that = this;
uni.notifyBLECharacteristicValueChange({
deviceId: deviceId,
@ -29249,7 +29242,13 @@ function getBLECharacteristicValueChange(deviceId, serviceId, notify) {
characteristicId: notify,
state: true,
success: function success() {
_store.default.commit("changeBluetoothValue", {
_store.default.commit('changeBluetoothValue', {
deviceId: deviceId,
serviceId: serviceId,
notify: notify,
write: write,
unit: "g",
countWeight: "",
bleTipsText: "测量中,请将食物放到秤上",
isConnectStatus: 0
});

View File

@ -150,8 +150,7 @@ var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/run
var _vuex = __webpack_require__(/*! vuex */ 30);
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var myTime;
var nextCnt = 0;
var searchTimer = null;
var _default = {
data: function data() {
return {
@ -159,8 +158,10 @@ var _default = {
kcal: "",
weight: "",
weightALL: "",
msgText: "蓝牙连接中",
unit: '',
weight0: 0,
devicesList: [],
stopblue: false,
isConnection: 0,
//是否连接成功
@ -170,7 +171,7 @@ var _default = {
props: {
weightKcal: {
type: Number,
default: 0 //当前测量食物每100g含的kcal
default: 0 //当前测量食物每g含的kcal
},
weightType: {
@ -183,17 +184,33 @@ var _default = {
default: false
}
},
computed: _objectSpread({}, (0, _vuex.mapState)(["user", 'isConnected', "isBluetoothTyle"])),
computed: _objectSpread({}, (0, _vuex.mapState)(["user", "isBluetoothTyle", "bleValue"])),
mounted: function mounted() {
var that = this;
console.log("mounted_new", that.weightType);
that.openBluetoothAdapter();
if (that.bleValue.serviceId != "") {
that.closeBLEConnection();
that.closeBluetoothAdapter();
that.openBluetoothAdapter();
} else {
that.openBluetoothAdapter();
}
that.onBLEConnectionStateChange();
uni.onBluetoothAdapterStateChange(function (res) {
that.$store.commit("changeBluetooth", res.available);
});
},
destroyed: function destroyed() {
this.$store.commit('changeBluetoothValue', {
deviceId: "",
serviceId: '',
notify: '',
write: "",
unit: "g",
oldCountWeight: 0,
countWeight: 100,
bleTipsText: "连接超时,点击重新连接",
isConnectStatus: 1
});
this.isConnection = 1;
this.closeBLEConnection();
this.closeBluetoothAdapter();
@ -221,11 +238,20 @@ var _default = {
var that = this;
that.weight = "";
that.kcal = "";
that.msgText = '蓝牙连接中';
uni.openBluetoothAdapter({
success: function success(e) {
that.isConnection = 0;
that.startBluetoothDeviceDiscovery();
searchTimer = setTimeout(function () {
uni.stopBluetoothDevicesDiscovery();
if (!that.devicesList.length) {
clearTimeout(searchTimer);
that.isConnection = 1;
}
}, 30000); // 30秒超时
},
fail: function fail(e) {
that.isConnection = 1;
console.log('openBluetoothAdapter', e);
@ -293,6 +319,7 @@ var _default = {
}
if (device.name.indexOf("EL") !== -1 && device.advertisServiceUUIDs != '') {
that.isConnection = 3;
clearTimeout(searchTimer);
var _value = that.$tools.ab2hex(device.advertisData);
var parseDataRes = plugin.parseBroadcastData(device.advertisData);
var analyzeData = plugin.analyzeBroadcastScaleData(parseDataRes);
@ -339,16 +366,28 @@ var _default = {
data2 = "-" + data2;
}
that.weight = data2;
that.kcal = (Number(that.weightKcal) / 100 * data2).toFixed(2);
var kcal = (Number(that.weightKcal) * data2).toFixed(2);
that.kcal = that.convertToGrams(kcal, that.dw);
console.log("analyzeData", _data.weight, data2);
}
} else if (device.name.indexOf('Chipsea-BLE') != -1 || device.localName.indexOf('Chipsea-BLE') != -1 || id == 'a5fe') {
} else if (device.name.indexOf('Chipsea-BLE') != -1 || device.localName && device.localName.indexOf('Chipsea-BLE') != -1 || id == 'a5fe') {
clearTimeout(searchTimer);
that.stopBluetoothDevicesDiscovery();
that.connectDevice(device.deviceId);
that.Bluetoothfilter(device.deviceId);
}
});
});
},
// 过滤蓝牙
Bluetoothfilter: function Bluetoothfilter(deviceId) {
var that = this;
var foundDevices = that.devicesList;
var idx = that.$ble.inArray(foundDevices, "deviceId", deviceId);
if (idx === -1) {
that.devicesList.push(deviceId);
that.connectDevice(deviceId);
}
},
//连接设备
connectDevice: function connectDevice(device_id) {
var _this = this;
@ -422,34 +461,39 @@ var _default = {
notify = item.uuid;
}
}
uni.notifyBLECharacteristicValueChange({
deviceId: deviceId,
serviceId: serviceId,
characteristicId: notify,
state: true,
success: function success() {
that.isConnection = 3;
that.$emit('connect_success');
uni.onBLECharacteristicValueChange(function (res) {
var value = res.value;
var dataView = new DataView(value);
var header = dataView.getUint8(0);
that.notifyBLECharacteristicValueChange(deviceId, serviceId, notify);
},
fail: function fail(res) {
console.log('获取特征值失败:', JSON.stringify(res));
}
});
},
notifyBLECharacteristicValueChange: function notifyBLECharacteristicValueChange(deviceId, serviceId, notify) {
var that = this;
uni.notifyBLECharacteristicValueChange({
deviceId: deviceId,
serviceId: serviceId,
characteristicId: notify,
state: true,
success: function success() {
that.isConnection = 3;
that.$emit('connect_success');
that.msgText = "测量中,请将食物放到秤上";
uni.onBLECharacteristicValueChange(function (res) {
var value = res.value;
var dataView = new DataView(value);
var header = dataView.getUint8(0);
// MCU主动上报数据
if (header === 0xC7) {
var cmd = dataView.getUint8(2);
switch (cmd) {
case 0x02:
that.parseWeightData(dataView);
break;
case 0x03:
break;
}
}
});
},
fail: function fail(res) {
console.log('获取特征值失败:', JSON.stringify(res));
// MCU主动上报数据
if (header === 0xC7) {
var cmd = dataView.getUint8(2);
switch (cmd) {
case 0x02:
that.parseWeightData(dataView);
break;
case 0x03:
break;
}
}
});
},
@ -474,11 +518,12 @@ var _default = {
// 计算实际重量
var finalWeight = weightValue / Math.pow(10, precision);
if (isNegative) finalWeight = -finalWeight;
// 更新状态
this.weight = finalWeight;
this.dw = this.units[unitIndex] || 'g';
this.kcal = (Number(this.weightKcal) / 100 * finalWeight).toFixed(2);
// this.kcal = (Number(this.weightKcal) / 100 * finalWeight).toFixed(2)
var kcal = (Number(this.weightKcal) * finalWeight).toFixed(2);
this.kcal = this.convertToGrams(kcal, this.dw).toFixed(2);
// console.log('重量:' + finalWeight)
// console.log('单位:' + this.unit)
@ -500,6 +545,21 @@ var _default = {
that.$tools.msg("数据异常,请清零后重新测量!");
}
},
convertToGrams: function convertToGrams(value, fromUnit) {
var conversionFactors = {
'lb': 453.59,
// 1磅 = 453.59237克
'oz': 28.35,
// 1盎司 = 28.349523125克
'kg': 1000,
// 1公斤 = 1000克
'g': 1
};
if (!conversionFactors.hasOwnProperty(fromUnit)) {
return '';
}
return value * conversionFactors[fromUnit];
},
// 备料完成
handleDetailSub: function handleDetailSub() {
var that = this;

View File

@ -1 +1 @@
<view class="weightPages data-v-53fa6103"><block wx:if="{{isConnection==0}}"><view class="table data-v-53fa6103">测量中,请将食物放到秤上</view></block><block wx:if="{{isConnection==1}}"><view data-event-opts="{{[['tap',[['openBluetoothAdapter',['$event']]]]]}}" class="table data-v-53fa6103" bindtap="__e">连接失败,点击重新连接</view></block><block wx:if="{{isConnection!=3}}"><view class="image data-v-53fa6103"><image src="../static/cheng.png" class="data-v-53fa6103"></image></view></block><block wx:if="{{isConnection==3}}"><view class="data-v-53fa6103"><view class="weight data-v-53fa6103"><view class="data-v-53fa6103">重量<text class="data-v-53fa6103">{{weight}}</text>{{dw}}</view><view class="data-v-53fa6103">热量<text class="data-v-53fa6103">{{kcal}}</text>千卡</view></view><view class="tips data-v-53fa6103">注:重新测量可更新当前数据</view><block wx:if="{{weightType!=2}}"><view class="groupbtn data-v-53fa6103"><view data-event-opts="{{[['tap',[['handleDetailSub',['$event']]]]]}}" class="btn data-v-53fa6103" bindtap="__e">完成</view><block wx:if="{{!stopblue}}"><view data-event-opts="{{[['tap',[['handleDetailNext',['$event']]]]]}}" class="btn data-v-53fa6103" bindtap="__e">下一位</view></block></view></block><block wx:if="{{weightType==2}}"><view data-event-opts="{{[['tap',[['handlesub',['$event']]]]]}}" class="btn data-v-53fa6103" bindtap="__e">确认添加</view></block></view></block><block wx:if="{{isConnection==1}}"><view class="tips data-v-53fa6103"><uni-icons vue-id="2b524063-1" type="info-filled" color="#dd524d" size="20" class="data-v-53fa6103" bind:__l="__l"></uni-icons>请确定设备是开机状态、手机蓝牙权限已打开!</view></block></view>
<view class="weightPages data-v-53fa6103"><block wx:if="{{isConnection==0}}"><view class="table data-v-53fa6103">{{msgText}}</view></block><block wx:if="{{isConnection==1}}"><view data-event-opts="{{[['tap',[['openBluetoothAdapter',['$event']]]]]}}" class="table data-v-53fa6103" bindtap="__e">连接失败,点击重新连接</view></block><block wx:if="{{isConnection!=3}}"><view class="image data-v-53fa6103"><image src="../static/cheng.png" class="data-v-53fa6103"></image></view></block><block wx:if="{{isConnection==3}}"><view class="data-v-53fa6103"><view class="weight data-v-53fa6103"><view class="data-v-53fa6103">重量<text class="data-v-53fa6103">{{weight}}</text>{{dw=='g'?'克':'盎司'}}</view><view class="data-v-53fa6103">热量<text class="data-v-53fa6103">{{kcal}}</text>千卡</view></view><view class="tips data-v-53fa6103">注:重新测量可更新当前数据</view><block wx:if="{{weightType!=2}}"><view class="groupbtn data-v-53fa6103"><view data-event-opts="{{[['tap',[['handleDetailSub',['$event']]]]]}}" class="btn data-v-53fa6103" bindtap="__e">完成</view><block wx:if="{{!stopblue}}"><view data-event-opts="{{[['tap',[['handleDetailNext',['$event']]]]]}}" class="btn data-v-53fa6103" bindtap="__e">下一位</view></block></view></block><block wx:if="{{weightType==2}}"><view data-event-opts="{{[['tap',[['handlesub',['$event']]]]]}}" class="btn data-v-53fa6103" bindtap="__e">确认添加</view></block></view></block><block wx:if="{{isConnection==1}}"><view class="tips data-v-53fa6103"><uni-icons vue-id="2b524063-1" type="info-filled" color="#dd524d" size="20" class="data-v-53fa6103" bind:__l="__l"></uni-icons>请确定设备是开机状态、手机蓝牙权限已打开!</view></block></view>

View File

@ -80,8 +80,8 @@
margin: 30rpx 0;
}
.weightPages .image.data-v-53fa6103 {
width: 1120rpx;
height: 1120rpx;
width: 112rpx;
height: 112rpx;
margin: auto;
}
.weightPages .image image.data-v-53fa6103 {

View File

@ -192,6 +192,7 @@ var _default = {
computed: _objectSpread(_objectSpread({}, (0, _vuex.mapState)(["bleValue", "isBluetoothTyle", "countFoodInfo"])), {}, {
weight: function weight() {
this.kcal = (Number(this.weightKcal) / 100 * this.bleValue.countWeight).toFixed(2);
this.unit = this.unitConversion(this.bleValue.unit);
return this.bleValue.countWeight;
},
@ -289,7 +290,7 @@ var _default = {
// 保存测量结果
handlesub: function handlesub() {
var that = this;
console.log("weight", that.weight);
console.log("测量保存", that.weight, that.unit, that.kcal);
if (Number(that.weight) > 0) {
that.$emit("handleBle", that.weight, that.unit, that.kcal);
} else {

View File

@ -1 +1 @@
<view class="weightPages data-v-5fc22dca"><view class="table data-v-5fc22dca"><view class="text data-v-5fc22dca"><image src="/static/zhong.png" class="data-v-5fc22dca"></image><text data-event-opts="{{[['tap',[['openBluetoothAdapter',['$event']]]]]}}" bindtap="__e" class="data-v-5fc22dca">{{bleTipsText}}</text></view><block wx:if="{{isShow&&isConnection==0}}"><view data-event-opts="{{[['tap',[['handleBack',['$event']]]]]}}" class="duan data-v-5fc22dca" bindtap="__e">断开连接</view></block></view><view class="weight-wrap data-v-5fc22dca"><view data-event-opts="{{[['tap',[['inputDialogToggle',['$event']]]]]}}" class="weight data-v-5fc22dca" bindtap="__e"><text class="val data-v-5fc22dca">{{weight==''?'--':weight}}</text><text class="unit data-v-5fc22dca">{{unit}}</text></view></view><view class="groupbtn data-v-5fc22dca"><view class="btn danwei data-v-5fc22dca"><view class="lan border-bottom data-v-5fc22dca"><view class="right data-v-5fc22dca"><picker mode="selector" range="{{unitList}}" range-key="name" value="{{unitListIndex}}" data-event-opts="{{[['change',[['changleUnits',['$event']]]]]}}" bindchange="__e" class="data-v-5fc22dca"><view class="uni-input data-v-5fc22dca">单位</view></picker></view></view></view><block wx:if="{{weightType==2&&btnType==2}}"><view data-event-opts="{{[['tap',[['handlesub',['$event']]]]]}}" class="btn addbtn size14 data-v-5fc22dca" bindtap="__e">保存</view></block><block wx:if="{{weightType==2&&btnType==1}}"><view data-event-opts="{{[['tap',[['handleAddFood',['$event']]]]]}}" class="btn addbtn data-v-5fc22dca" bindtap="__e">+</view></block><view data-event-opts="{{[['tap',[['handleqingling',['$event']]]]]}}" class="btn qingling data-v-5fc22dca" bindtap="__e">清零</view></view><view class="data-v-5fc22dca"><uni-popup vue-id="cef7e708-1" type="dialog" data-ref="popup" class="data-v-5fc22dca vue-ref" bind:__l="__l" vue-slots="{{['default']}}"><uni-popup-dialog vue-id="{{('cef7e708-2')+','+('cef7e708-1')}}" mode="input" title="重量" placeholder="请输入食物重量" data-event-opts="{{[['^close',[['close']]],['^confirm',[['confirm']]]]}}" bind:close="__e" bind:confirm="__e" class="data-v-5fc22dca" bind:__l="__l"></uni-popup-dialog></uni-popup></view></view>
<view class="weightPages data-v-5fc22dca"><view class="table data-v-5fc22dca"><view class="text data-v-5fc22dca"><image src="/static/zhong.png" class="data-v-5fc22dca"></image><text data-event-opts="{{[['tap',[['openBluetoothAdapter',['$event']]]]]}}" bindtap="__e" class="data-v-5fc22dca">{{bleTipsText}}</text></view><block wx:if="{{isShow&&isConnection==0}}"><view data-event-opts="{{[['tap',[['handleBack',['$event']]]]]}}" class="duan data-v-5fc22dca" bindtap="__e">断开连接</view></block></view><view class="weight-wrap data-v-5fc22dca"><view data-event-opts="{{[['tap',[['inputDialogToggle',['$event']]]]]}}" class="weight data-v-5fc22dca" bindtap="__e"><text class="val data-v-5fc22dca">{{weight==''?'0.0':weight}}</text><text class="unit data-v-5fc22dca">{{unit}}</text></view></view><view class="groupbtn data-v-5fc22dca"><view class="btn danwei data-v-5fc22dca"><view class="lan border-bottom data-v-5fc22dca"><view class="right data-v-5fc22dca"><picker mode="selector" range="{{unitList}}" range-key="name" value="{{unitListIndex}}" data-event-opts="{{[['change',[['changleUnits',['$event']]]]]}}" bindchange="__e" class="data-v-5fc22dca"><view class="uni-input data-v-5fc22dca">单位</view></picker></view></view></view><block wx:if="{{weightType==2&&btnType==2}}"><view data-event-opts="{{[['tap',[['handlesub',['$event']]]]]}}" class="btn addbtn size14 data-v-5fc22dca" bindtap="__e">保存</view></block><block wx:if="{{weightType==2&&btnType==1}}"><view data-event-opts="{{[['tap',[['handleAddFood',['$event']]]]]}}" class="btn addbtn data-v-5fc22dca" bindtap="__e">+</view></block><view data-event-opts="{{[['tap',[['handleqingling',['$event']]]]]}}" class="btn qingling data-v-5fc22dca" bindtap="__e">清零</view></view><view class="data-v-5fc22dca"><uni-popup vue-id="cef7e708-1" type="dialog" data-ref="popup" class="data-v-5fc22dca vue-ref" bind:__l="__l" vue-slots="{{['default']}}"><uni-popup-dialog vue-id="{{('cef7e708-2')+','+('cef7e708-1')}}" mode="input" title="重量" placeholder="请输入食物重量" data-event-opts="{{[['^close',[['close']]],['^confirm',[['confirm']]]]}}" bind:close="__e" bind:confirm="__e" class="data-v-5fc22dca" bind:__l="__l"></uni-popup-dialog></uni-popup></view></view>

View File

@ -225,7 +225,11 @@ var _default = {
bgimage: "",
page: "",
index: "",
info: {}
info: {
date: "",
list: [],
nutrients_four: []
}
};
},
components: {

View File

@ -1 +1 @@
<view class="content data-v-1c5f368e"><view class="content_box data-v-1c5f368e"><view class="box data-v-1c5f368e"><view class="top data-v-1c5f368e"><image src="{{bgimage}}" mode="aspectFill" class="data-v-1c5f368e"></image><view class="name data-v-1c5f368e">{{info.name}}</view><view class="time data-v-1c5f368e">{{time}}</view></view><view class="everyDay data-v-1c5f368e"><view class="title data-v-1c5f368e"><view class="data-v-1c5f368e"><text class="quan data-v-1c5f368e"></text>成分统计</view></view><view class="progress data-v-1c5f368e"><view class="chart-wrap _div data-v-1c5f368e"><qiun-data-charts vue-id="6f881c38-1" type="ring" opts="{{opts}}" canvasId="foodCharts" chartData="{{chartData}}" cHeight="{{280}}" cWidth="{{280}}" class="data-v-1c5f368e" bind:__l="__l"></qiun-data-charts></view><block wx:if="{{info.nutrients_four}}"><view class="info data-v-1c5f368e"><block wx:for="{{$root.l0}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view class="info-item data-v-1c5f368e"><view class="data-v-1c5f368e"><view class="color data-v-1c5f368e" style="{{'background-color:'+(''+item.color)+';'}}"></view><view class="data-v-1c5f368e">{{item.name}}</view></view><view class="data-v-1c5f368e"><view class="data-v-1c5f368e">{{item.value+item.unit}}<text class="data-v-1c5f368e">|</text>{{item.proportion+"%"}}</view></view></view></block></view></block></view></view><view class="foodtools data-v-1c5f368e"><view class="type data-v-1c5f368e"><view class="title data-v-1c5f368e"><view class="data-v-1c5f368e"><text class="quan data-v-1c5f368e"></text>食物类型</view></view><block wx:if="{{$root.g0}}"><view class="list data-v-1c5f368e"><uni-swipe-action vue-id="6f881c38-2" class="data-v-1c5f368e" bind:__l="__l" vue-slots="{{['default']}}"><block wx:for="{{info.list}}" wx:for-item="ite" wx:for-index="ind" wx:key="ind"><uni-swipe-action-item vue-id="{{('6f881c38-3-'+ind)+','+('6f881c38-2')}}" right-options="{{actionOptions}}" data-event-opts="{{[['^click',[['delAcitionItem',['$0'],[[['info.list','',ind]]]]]]]}}" bind:click="__e" class="data-v-1c5f368e" bind:__l="__l" vue-slots="{{['default']}}"><view data-event-opts="{{[['tap',[['showFoodDetail',['$0'],[[['info.list','',ind]]]]]]]}}" class="item data-v-1c5f368e" bindtap="__e"><image src="{{ite.pic_url}}" mode="aspectFill" class="data-v-1c5f368e"></image><view class="weight data-v-1c5f368e"><view class="data-v-1c5f368e">{{ite.name}}</view><view class="size12 c999 data-v-1c5f368e">{{ite.weight}}<text class="data-v-1c5f368e">|</text>{{ite.val+"kcal"}}</view></view></view></uni-swipe-action-item></block></uni-swipe-action></view></block><block wx:else><view class="nolist data-v-1c5f368e"><image src="/static/none.png" class="data-v-1c5f368e"></image><view class="data-v-1c5f368e">暂无食物</view></view></block></view></view><view data-event-opts="{{[['tap',[['handleAddFood']]]]}}" class="add data-v-1c5f368e" bindtap="__e"><text class="data-v-1c5f368e">+</text>添加食物</view></view></view><uni-drawer vue-id="6f881c38-4" mode="right" width="300" data-ref="showRight" class="data-v-1c5f368e vue-ref" bind:__l="__l" vue-slots="{{['default']}}"><scroll-view style="height:100%;" scroll-y="true" class="data-v-1c5f368e"><view class="foodDetail data-v-1c5f368e"><view class="foodInfo data-v-1c5f368e"><image src="{{activeFoodDetail.pic_url}}" mode="aspectFill" class="data-v-1c5f368e"></image><view class="info data-v-1c5f368e"><view class="name data-v-1c5f368e">{{activeFoodDetail.name}}</view><view class="kcal data-v-1c5f368e">{{activeFoodDetail.val+"千卡"}}</view></view></view><view class="foodContent data-v-1c5f368e"><view class="title data-v-1c5f368e">热量和营养</view><view class="progress data-v-1c5f368e"><view class="chart-wrap _div data-v-1c5f368e"><qiun-data-charts vue-id="{{('6f881c38-5')+','+('6f881c38-4')}}" type="ring" opts="{{opts2}}" chartData="{{chartData2}}" cHeight="{{280}}" cWidth="{{280}}" class="data-v-1c5f368e" bind:__l="__l"></qiun-data-charts></view><block wx:if="{{activeFoodDetail.nutrients_four}}"><view class="info data-v-1c5f368e"><block wx:for="{{$root.l1}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view class="info-item data-v-1c5f368e"><view class="color data-v-1c5f368e" style="{{'background-color:'+(''+item.color)+';'}}"></view><view class="data-v-1c5f368e">{{item.name+""+item.proportion+"%"}}</view></view></block></view></block></view><view class="tips data-v-1c5f368e"><text class="data-v-1c5f368e">营养素</text><text class="data-v-1c5f368e">{{activeFoodDetail.weight+"含量"}}</text></view><view class="foodDetailList data-v-1c5f368e"><block wx:for="{{activeFoodDetail.nutrients_list}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view class="foodDetailItem data-v-1c5f368e"><view class="name data-v-1c5f368e">{{item.name_ch}}</view><view class="value data-v-1c5f368e">{{item.value+item.unit+''}}</view></view></block></view></view></view></scroll-view></uni-drawer></view>
<view class="content data-v-1c5f368e"><view class="content_box data-v-1c5f368e"><view class="box data-v-1c5f368e"><view class="top data-v-1c5f368e"><image src="{{bgimage}}" mode="aspectFill" class="data-v-1c5f368e"></image><view class="name data-v-1c5f368e">{{info.name}}</view><view class="time data-v-1c5f368e">{{time}}</view></view><view class="everyDay data-v-1c5f368e"><view class="title data-v-1c5f368e"><view class="data-v-1c5f368e"><text class="quan data-v-1c5f368e"></text>成分统计</view></view><view class="progress data-v-1c5f368e"><view class="chart-wrap _div data-v-1c5f368e"><qiun-data-charts vue-id="6f881c38-1" type="ring" opts="{{opts}}" canvasId="foodCharts" chartData="{{chartData}}" cHeight="{{280}}" cWidth="{{280}}" canvas2d="{{true}}" class="data-v-1c5f368e" bind:__l="__l"></qiun-data-charts></view><block wx:if="{{info.nutrients_four}}"><view class="info data-v-1c5f368e"><block wx:for="{{$root.l0}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view class="info-item data-v-1c5f368e"><view class="data-v-1c5f368e"><view class="color data-v-1c5f368e" style="{{'background-color:'+(''+item.color)+';'}}"></view><view class="data-v-1c5f368e">{{item.name}}</view></view><view class="data-v-1c5f368e"><view class="data-v-1c5f368e">{{item.value+item.unit}}<text class="data-v-1c5f368e">|</text>{{item.proportion+"%"}}</view></view></view></block></view></block></view></view><view class="foodtools data-v-1c5f368e"><view class="type data-v-1c5f368e"><view class="title data-v-1c5f368e"><view class="data-v-1c5f368e"><text class="quan data-v-1c5f368e"></text>食物类型</view></view><block wx:if="{{$root.g0}}"><view class="list data-v-1c5f368e"><uni-swipe-action vue-id="6f881c38-2" class="data-v-1c5f368e" bind:__l="__l" vue-slots="{{['default']}}"><block wx:for="{{info.list}}" wx:for-item="ite" wx:for-index="ind" wx:key="ind"><uni-swipe-action-item vue-id="{{('6f881c38-3-'+ind)+','+('6f881c38-2')}}" right-options="{{actionOptions}}" data-event-opts="{{[['^click',[['delAcitionItem',['$0'],[[['info.list','',ind]]]]]]]}}" bind:click="__e" class="data-v-1c5f368e" bind:__l="__l" vue-slots="{{['default']}}"><view data-event-opts="{{[['tap',[['showFoodDetail',['$0'],[[['info.list','',ind]]]]]]]}}" class="item data-v-1c5f368e" bindtap="__e"><image src="{{ite.pic_url}}" mode="aspectFill" class="data-v-1c5f368e"></image><view class="weight data-v-1c5f368e"><view class="data-v-1c5f368e">{{ite.name}}</view><view class="size12 c999 data-v-1c5f368e">{{ite.weight}}<text class="data-v-1c5f368e">|</text>{{ite.val+"kcal"}}</view></view></view></uni-swipe-action-item></block></uni-swipe-action></view></block><block wx:else><view class="nolist data-v-1c5f368e"><image src="/static/none.png" class="data-v-1c5f368e"></image><view class="data-v-1c5f368e">暂无食物</view></view></block></view></view><view data-event-opts="{{[['tap',[['handleAddFood']]]]}}" class="add data-v-1c5f368e" bindtap="__e"><text class="data-v-1c5f368e">+</text>添加食物</view></view></view><uni-drawer vue-id="6f881c38-4" mode="right" width="300" data-ref="showRight" class="data-v-1c5f368e vue-ref" bind:__l="__l" vue-slots="{{['default']}}"><scroll-view style="height:100%;" scroll-y="true" class="data-v-1c5f368e"><view class="foodDetail data-v-1c5f368e"><view class="foodInfo data-v-1c5f368e"><image src="{{activeFoodDetail.pic_url}}" mode="aspectFill" class="data-v-1c5f368e"></image><view class="info data-v-1c5f368e"><view class="name data-v-1c5f368e">{{activeFoodDetail.name}}</view><view class="kcal data-v-1c5f368e">{{activeFoodDetail.val+"千卡"}}</view></view></view><view class="foodContent data-v-1c5f368e"><view class="title data-v-1c5f368e">热量和营养</view><view class="progress data-v-1c5f368e"><view class="chart-wrap _div data-v-1c5f368e"><qiun-data-charts vue-id="{{('6f881c38-5')+','+('6f881c38-4')}}" type="ring" opts="{{opts2}}" chartData="{{chartData2}}" cHeight="{{280}}" cWidth="{{280}}" class="data-v-1c5f368e" bind:__l="__l"></qiun-data-charts></view><block wx:if="{{activeFoodDetail.nutrients_four}}"><view class="info data-v-1c5f368e"><block wx:for="{{$root.l1}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view class="info-item data-v-1c5f368e"><view class="color data-v-1c5f368e" style="{{'background-color:'+(''+item.color)+';'}}"></view><view class="data-v-1c5f368e">{{item.name+""+item.proportion+"%"}}</view></view></block></view></block></view><view class="tips data-v-1c5f368e"><text class="data-v-1c5f368e">营养素</text><text class="data-v-1c5f368e">{{activeFoodDetail.weight+"含量"}}</text></view><view class="foodDetailList data-v-1c5f368e"><block wx:for="{{activeFoodDetail.nutrients_list}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view class="foodDetailItem data-v-1c5f368e"><view class="name data-v-1c5f368e">{{item.name_ch}}</view><view class="value data-v-1c5f368e">{{item.value+item.unit+''}}</view></view></block></view></view></view></scroll-view></uni-drawer></view>

View File

@ -182,6 +182,6 @@
width: 100%;
text-align: center;
font-weight: bold;
margin-top: 10px;
margin: 30rpx 0;
}

View File

@ -371,7 +371,7 @@ var _default = {
},
//实时重量
realTimeWeight: function realTimeWeight(weight, unit) {
console.log("实时重量", weight, unit);
// console.log("实时重量", weight, unit)
this.activeType = Object.assign({}, this.activeType, {
weight: this.convertToGrams(weight, unit)
});
@ -386,9 +386,9 @@ var _default = {
},
convertToGrams: function convertToGrams(value, fromUnit) {
var conversionFactors = {
'lb': 453.59237,
'lb': 453.59,
// 1磅 = 453.59237克
'oz': 28.349523125,
'oz': 28.35,
// 1盎司 = 28.349523125克
'kg': 1000,
// 1公斤 = 1000克
@ -406,6 +406,8 @@ var _default = {
that.isShop = false;
that.IsWeight = true;
that.activeType = ite;
that.weightKcal = ite.kcal;
console.log("111111", ite, that.bleValue);
if (that.bleValue.serviceId != "") {
that.realTimeWeight(that.bleValue.countWeight, that.bleValue.unit);
} else {
@ -415,7 +417,6 @@ var _default = {
});
that.realTimeWeight(100, "g");
// that.activeType.weight = 100
// that.weightKcal = that.activeType.kcal
// let chart_data = []
// that.opts.color = []
// for (let i = 1; i < ite.nutrients_four.length; ++i) {
@ -442,6 +443,7 @@ var _default = {
that.activeType.weight = weight;
that.activeType.meals_type = that.foodName;
list.push(that.activeType);
console.log("list", list);
that.$model.getAddIntakeFood({
aud_id: that.user.aud_id,
food_list: list,

File diff suppressed because one or more lines are too long

View File

@ -604,13 +604,14 @@
width: 100%;
height: 45px;
display: flex;
padding: 5px 0;
position: relative;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid #f7f7f7;
}
.wrapper .box2 .list .item .item-left.data-v-d4f38c70 {
width: 80%;
width: calc(100% - 40px);
display: flex;
align-items: center;
}
@ -621,10 +622,14 @@
border: 1px solid #f7f7f7;
}
.wrapper .box2 .list .item .item-left .name.data-v-d4f38c70 {
width: calc(100% - 100rpx);
display: flex;
flex-direction: column;
margin-left: 10px;
height: 40px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
justify-content: space-between;
}
.wrapper .box2 .list .item .item-left .name text.data-v-d4f38c70 {

View File

@ -279,6 +279,7 @@ var _default = {
}).then(function (res) {
if (res.code == 0) {
that.$tools.msg("设置成功");
that.$store.dispatch("getUserInfo");
setTimeout(function () {
uni.switchTab({
url: '/pages/count/count'

View File

@ -128,7 +128,7 @@ var render = function () {
var g0 = _vm.search_list.length
var g1 = !g0 ? _vm.history_food.length : null
var g2 = !g0 && g1 ? _vm.history_food.length : null
var g3 = !g0 && g1 && !_vm.showAll ? _vm.history_food.slice(0, 10) : null
var g3 = !g0 && g1 && !_vm.showAll ? _vm.history_food.slice(0, 8) : null
var g4 = _vm.search_list.length
var l0 = g4
? _vm.__map(_vm.search_list, function (ite, ind) {
@ -140,10 +140,8 @@ var render = function () {
}
})
: null
var g6 = _vm.ActiveList.length
var g7 = g6 ? _vm.ActiveList.length : null
var g8 = g6 && g7 ? _vm.ActiveList.length : null
var g9 = _vm.isShop ? _vm.ActiveList.length : null
var g6 = _vm.ActiveList.length || 0
var g7 = _vm.isShop ? _vm.ActiveList.length : null
if (!_vm._isMounted) {
_vm.e0 = function ($event) {
_vm.showAll = !_vm.showAll
@ -156,12 +154,9 @@ var render = function () {
return _vm.handleSearchHistory(item.keyword)
}
_vm.e2 = function ($event) {
_vm.showAutoSearchDlg = false
}
_vm.e3 = function ($event) {
_vm.isShop = !_vm.isShop
}
_vm.e4 = function ($event) {
_vm.e3 = function ($event) {
_vm.isShop = false
}
}
@ -177,8 +172,6 @@ var render = function () {
l0: l0,
g6: g6,
g7: g7,
g8: g8,
g9: g9,
},
}
)
@ -295,19 +288,13 @@ var _default = {
}
}
},
onShowSearchType: function onShowSearchType(type) {
var that = this;
console.log("autoSearchType", type, that.autoSearchContent);
this.autoSearchType = type;
if (type == 1) {
that.showAutoSearchDlg = true;
} else if (type == 2) {
that.selectPhoto();
}
},
// 搜索
handleSerach: function handleSerach() {
var that = this;
if (that.search_value == "") {
that.$tools.msg("输入关键字后搜索");
return;
}
that.search_list = [];
that.$model.getFoodSearch({
page: that.page,
@ -328,15 +315,6 @@ var _default = {
this.search_value = "";
this.search_list = [];
},
handleVoiceSearch: function handleVoiceSearch() {
var that = this;
if (that.autoSearchContent != '') {
that.search_value = that.autoSearchContent;
that.showAutoSearchDlg = false;
that.autoSearchContent = '';
that.handleSerach();
}
},
// 历史搜索
handleSearchHistory: function handleSearchHistory(text) {
var that = this;
@ -345,15 +323,6 @@ var _default = {
that.autoSearchContent = '';
that.handleSerach();
},
// 重试
retrySearch: function retrySearch() {
var that = this;
that.autoSearchContent = '';
if (that.autoSearchType == 2) {
that.showAutoSearchDlg = false;
that.selectPhoto();
}
},
// 开始说话
onVoiceTouchStart: function onVoiceTouchStart() {
var that = this;
@ -369,44 +338,6 @@ var _default = {
that.mic_touch = false;
that.voiceManager.stop();
},
selectPhoto: function selectPhoto() {
var that = this;
uni.chooseMedia({
count: 1,
mediaType: ['image'],
sourceType: ['album', 'camera'],
sizeType: ['compressed'],
camera: 'back',
success: function success(res) {
var tempFilePath = res.tempFiles[0].tempFilePath;
uni.getFileSystemManager().readFile({
filePath: tempFilePath,
encoding: 'base64',
success: function success(res) {
var base64 = 'data:image/jpeg;base64,' + res.data;
uni.showLoading({
title: '图片识别中...',
mask: true
});
that.$model.getPhotoSearch({
img_str: base64
}).then(function (res) {
uni.hideLoading();
if (res.code != 0) return;
that.autoSearchContent = res.data.name;
that.showAutoSearchDlg = true;
});
},
fail: function fail(err) {
console.error('读取文件失败:', err);
}
});
},
fail: function fail(err) {
console.error('拍照失败:', err);
}
});
},
// 购物车提交
handlesubbtn: function handlesubbtn() {
var that = this;

File diff suppressed because one or more lines are too long

View File

@ -144,7 +144,7 @@
.popular-container.data-v-c58b4fba {
width: 100%;
margin-top: 30rpx;
margin-bottom: 80px;
margin-bottom: 120px;
}
.popular-container .popular-food-item.data-v-c58b4fba {
display: flex;
@ -181,7 +181,7 @@
display: flex;
padding: 0 20rpx;
flex-wrap: wrap;
margin: 75px 20rpx 90px;
margin: 75px 20rpx 120px;
width: calc(100% - 80rpx);
justify-content: space-between;
background: #fff;
@ -275,7 +275,7 @@
}
.activeList.data-v-c58b4fba {
z-index: 12;
bottom: 100rpx;
bottom: 200rpx;
}
.activeList .box2.data-v-c58b4fba {
height: 500rpx;
@ -283,7 +283,7 @@
position: absolute;
width: 100%;
bottom: 70px;
padding-bottom: 90px;
padding-bottom: 120px;
border-radius: 20rpx 20rpx 0 0;
}
.activeList .list.data-v-c58b4fba {
@ -304,21 +304,28 @@
bottom: 0;
left: 0;
right: 0;
height: 55px;
height: 90px;
z-index: 99;
flex-wrap: wrap;
background-color: #fff;
overflow: hidden;
box-shadow: 0px 1px 5px 2px #dfe2e1fc;
}
.groupbtn .subbtn.data-v-c58b4fba {
color: #fff;
width: 40%;
width: 60%;
text-align: center;
border-radius: 20rpx;
height: 35px;
line-height: 35px;
background-color: #f0ae43;
}
.groupbtn .jilu.data-v-c58b4fba {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
.groupbtn .che.data-v-c58b4fba {
width: 120rpx;
height: 120rpx;
@ -350,6 +357,16 @@
margin: auto;
background-color: #f0ae43;
}
.mic-icon.data-v-c58b4fba {
color: #fff;
width: 100%;
padding: 8px 0;
background: #3CB383;
display: flex;
align-items: center;
justify-content: center;
border-radius: 20rpx;
}
.button-container.data-v-c58b4fba {
position: absolute;
top: 20rpx;

View File

@ -199,13 +199,16 @@ var _default = {
isLast: false,
cookIndex: null,
showSaveFood: false,
saveFoodTypes: ['早餐', '午餐', '晚餐', '早加餐', '午加餐', '晚加餐'],
saveFoodTypes: ['早餐', '午餐', '晚餐', '加餐'],
selectSaveType: 0
};
},
computed: _objectSpread(_objectSpread({}, (0, _vuex.mapState)(["user", "configInfo"])), {}, {
menu: function menu() {
return this.configInfo.cookbook_label;
},
endDate: function endDate() {
return this.$tools.getDate("start");
}
}),
components: {
@ -264,7 +267,7 @@ var _default = {
that.info.tags[0].list[ind].newkcal = kcal;
that.listInd = that.listInd + 1;
that.activeType = that.info.tags[0].list[ind + 1];
that.weightKcal = that.activeType.kcal;
that.weightKcal = Number(Number(that.activeType.kcal) / 100).toFixed(2);
that.info.tags[0].list[that.listInd].newweight = "";
that.info.tags[0].list[that.listInd].newunit = "";
that.info.tags[0].list[that.listInd].newkcal = "";
@ -294,7 +297,7 @@ var _default = {
that.activeType = ite;
that.iSWeightSub = true;
that.isWeightType = false;
that.weightKcal = that.activeType.kcal;
that.weightKcal = Number(Number(that.activeType.kcal) / 100).toFixed(2);
that.info.tags[0].list[ind].newweight = "";
that.info.tags[0].list[ind].newunit = "";
that.info.tags[0].list[ind].newkcal = "";
@ -310,7 +313,7 @@ var _default = {
this.isLast = false;
this.isWeightType = false;
this.activeType = this.info.tags[0].list[0];
this.weightKcal = this.activeType.kcal;
this.weightKcal = Number(Number(this.activeType.kcal) / 100).toFixed(2);
this.listInd = 0;
if (this.info.tags[0].list.length == 1) {
this.isLast = true;
@ -323,18 +326,22 @@ var _default = {
for (var i = 0; i < that.info.tags[0].list.length; ++i) {
if (that.info.tags[0].list[i].newweight) {
newFoodList.push({
meals_type: that.saveFoodTypes[that.selectSaveType],
id: that.info.tags[0].list[i].id,
weight: that.info.tags[0].list[i].newweight
weight: that.info.tags[0].list[i].newweight,
unit: that.info.tags[0].list[i].newunit == 'g' ? '克' : '盎司'
});
}
}
console.log("newFoodList", that.info.tags[0].list, newFoodList);
if (newFoodList.length > 0) {
that.$model.getAddIntakeFood({
aud_id: that.user.aud_id,
meals_type: that.saveFoodTypes[that.selectSaveType],
food_list: newFoodList
food_list: newFoodList,
time: that.$tools.getDate("start")
}).then(function (res) {
if (res.code != 0) return;
that.$store.dispatch("getUserInfo");
uni.showToast({
title: '保存成功',
icon: 'success'

File diff suppressed because one or more lines are too long

View File

@ -320,9 +320,10 @@
flex-wrap: wrap;
justify-content: space-between;
margin-top: 30rpx;
width: 100%;
}
.saveFood .saveFoodInner .types .type-item.data-v-4a383a52 {
width: 30%;
width: 22%;
height: 50rpx;
line-height: 50rpx;
text-align: center;

View File

@ -1 +1 @@
<view class="content data-v-61fb252d"><view class="content_box data-v-61fb252d"><view class="set data-v-61fb252d"><view class="date data-v-61fb252d">{{foodInfo.date}}</view></view><view class="box data-v-61fb252d"><view class="kcal2 data-v-61fb252d"><view class="top data-v-61fb252d"><view class="left data-v-61fb252d"><view class="center data-v-61fb252d">可以吃<text class="data-v-61fb252d">{{foodInfo.remaining_kcal}}</text><view class="unit data-v-61fb252d">Kcal</view></view></view><view class="right data-v-61fb252d"><view class="item border-bottom data-v-61fb252d"><text class="name data-v-61fb252d">已摄入</text><text class="bold data-v-61fb252d">{{''+foodInfo.today_intake.kcal+'千卡'}}</text></view><view class="item data-v-61fb252d"><text class="name data-v-61fb252d">碳水</text><text class="bold data-v-61fb252d">{{''+foodInfo.today_intake.carbohydrate+"/"+foodInfo.suggestion.carbohydrate+''}}</text></view><view class="item data-v-61fb252d"><text class="name data-v-61fb252d">脂肪</text><text class="bold data-v-61fb252d">{{''+foodInfo.today_intake.fat+"/"+foodInfo.suggestion.fat+''}}</text></view><view class="item data-v-61fb252d"><text class="name data-v-61fb252d">蛋白</text><text class="bold data-v-61fb252d">{{''+foodInfo.today_intake.protein+"/"+foodInfo.suggestion.protein+''}}</text></view></view></view></view><view class="tabbar-box data-v-61fb252d"><block wx:if="{{$root.g0}}"><view class="list data-v-61fb252d"><block wx:for="{{foodInfo.list}}" wx:for-item="ite" wx:for-index="ind" wx:key="ind"><view class="listbox data-v-61fb252d"><view class="left data-v-61fb252d"><view class="title data-v-61fb252d">{{ite.name}}</view><view class="kcalval data-v-61fb252d"><text class="data-v-61fb252d">{{ite.val}}</text>{{ite.unit+''}}</view></view><view class="right data-v-61fb252d"><block wx:for="{{ite.list}}" wx:for-item="it" wx:for-index="id"><view data-event-opts="{{[['tap',[['showFoodDetail',['$0'],[[['foodInfo.list','',ind],['list','',id]]]]]]]}}" class="item data-v-61fb252d" bindtap="__e"><image src="{{it.pic_url}}" mode="aspectFill" class="data-v-61fb252d"></image><text class="data-v-61fb252d">{{it.name}}</text><text class="data-v-61fb252d">{{it.weight}}</text><text class="data-v-61fb252d">{{it.val+"千卡"}}</text></view></block></view></view></block></view></block></view></view></view><uni-drawer vue-id="452bfd0e-1" mode="right" width="300" data-ref="showRight" class="data-v-61fb252d vue-ref" bind:__l="__l" vue-slots="{{['default']}}"><scroll-view style="height:100%;" scroll-y="true" class="data-v-61fb252d"><view class="foodDetail data-v-61fb252d"><view class="foodInfo data-v-61fb252d"><image src="{{activeFoodDetail.pic_url}}" mode="aspectFill" class="data-v-61fb252d"></image><view class="info data-v-61fb252d"><view class="name data-v-61fb252d">{{activeFoodDetail.name}}</view><view class="kcal data-v-61fb252d">{{activeFoodDetail.val+"千卡"}}</view></view></view><view class="foodContent data-v-61fb252d"><view class="title data-v-61fb252d">热量和营养</view><view class="progress data-v-61fb252d"><view class="chart-wrap _div data-v-61fb252d"><qiun-data-charts vue-id="{{('452bfd0e-2')+','+('452bfd0e-1')}}" type="ring" opts="{{opts}}" canvas2d="{{true}}" canvasId="foodCharts" chartData="{{chartData2}}" cHeight="{{250}}" cWidth="{{250}}" class="data-v-61fb252d" bind:__l="__l"></qiun-data-charts><view class="uchart-kcal data-v-61fb252d">{{activeFoodDetail.val}}</view></view><block wx:if="{{activeFoodDetail.nutrients_four}}"><view class="info data-v-61fb252d"><block wx:for="{{$root.l0}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view class="info-item data-v-61fb252d"><view class="color data-v-61fb252d" style="{{'background-color:'+(''+item.color)+';'}}"></view><view class="data-v-61fb252d">{{item.name+""+item.proportion+"%"}}</view></view></block></view></block></view><view class="tips data-v-61fb252d"><text class="data-v-61fb252d">营养素</text><text class="data-v-61fb252d">{{activeFoodDetail.weight+"含量"}}</text></view><view class="foodDetailList data-v-61fb252d"><block wx:for="{{activeFoodDetail.nutrients_list}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view class="foodDetailItem data-v-61fb252d"><view class="name data-v-61fb252d">{{item.name_ch}}</view><view class="value data-v-61fb252d">{{item.value+item.unit+''}}</view></view></block></view></view></view></scroll-view></uni-drawer></view>
<view class="content data-v-61fb252d"><view class="content_box data-v-61fb252d"><view class="set data-v-61fb252d"><view class="date data-v-61fb252d">{{foodInfo.date}}</view></view><view class="box data-v-61fb252d"><view class="kcal2 data-v-61fb252d"><view class="top data-v-61fb252d"><view class="left data-v-61fb252d"><view class="center data-v-61fb252d">可以吃<text class="data-v-61fb252d">{{foodInfo.remaining_kcal}}</text><view class="unit data-v-61fb252d">Kcal</view></view></view><view class="right data-v-61fb252d"><view class="item border-bottom data-v-61fb252d"><text class="name data-v-61fb252d">已摄入</text><text class="bold data-v-61fb252d">{{''+foodInfo.today_intake.kcal+'千卡'}}</text></view><view class="item data-v-61fb252d"><text class="name data-v-61fb252d">碳水</text><text class="bold data-v-61fb252d">{{''+foodInfo.today_intake.carbohydrate+"/"+foodInfo.suggestion.carbohydrate+''}}</text></view><view class="item data-v-61fb252d"><text class="name data-v-61fb252d">脂肪</text><text class="bold data-v-61fb252d">{{''+foodInfo.today_intake.fat+"/"+foodInfo.suggestion.fat+''}}</text></view><view class="item data-v-61fb252d"><text class="name data-v-61fb252d">蛋白</text><text class="bold data-v-61fb252d">{{''+foodInfo.today_intake.protein+"/"+foodInfo.suggestion.protein+''}}</text></view></view></view></view><view class="tabbar-box data-v-61fb252d"><block wx:if="{{$root.g0}}"><view class="list data-v-61fb252d"><block wx:for="{{foodInfo.list}}" wx:for-item="ite" wx:for-index="ind" wx:key="ind"><view class="listbox data-v-61fb252d"><view class="left data-v-61fb252d"><view class="title data-v-61fb252d">{{ite.name}}</view><view class="kcalval data-v-61fb252d"><text class="data-v-61fb252d">{{ite.val}}</text>{{ite.unit+''}}</view></view><view class="right data-v-61fb252d"><block wx:for="{{ite.list}}" wx:for-item="it" wx:for-index="id"><view data-event-opts="{{[['tap',[['showFoodDetail',['$0'],[[['foodInfo.list','',ind],['list','',id]]]]]]]}}" class="item data-v-61fb252d" bindtap="__e"><image src="{{it.pic_url}}" mode="aspectFill" class="data-v-61fb252d"></image><text class="data-v-61fb252d">{{it.name}}</text><text class="data-v-61fb252d">{{it.weight}}</text><text class="data-v-61fb252d">{{it.val+"千卡"}}</text></view></block></view></view></block></view></block></view></view></view><uni-drawer vue-id="452bfd0e-1" mode="right" width="300" data-ref="showRight" class="data-v-61fb252d vue-ref" bind:__l="__l" vue-slots="{{['default']}}"><scroll-view style="height:100%;" scroll-y="true" class="data-v-61fb252d"><view class="foodDetail data-v-61fb252d"><view class="foodInfo data-v-61fb252d"><image src="{{activeFoodDetail.pic_url}}" mode="aspectFill" class="data-v-61fb252d"></image><view class="info data-v-61fb252d"><view class="name data-v-61fb252d">{{activeFoodDetail.name}}</view><view class="kcal data-v-61fb252d">{{activeFoodDetail.val+"千卡"}}</view></view></view><view class="foodContent data-v-61fb252d"><view class="title data-v-61fb252d">热量和营养</view><view class="progress data-v-61fb252d"><view class="chart-wrap _div data-v-61fb252d"><qiun-data-charts vue-id="{{('452bfd0e-2')+','+('452bfd0e-1')}}" type="ring" opts="{{opts}}" canvas2d="{{true}}" canvasId="recordetailCharts" chartData="{{chartData2}}" cHeight="{{250}}" cWidth="{{250}}" class="data-v-61fb252d" bind:__l="__l"></qiun-data-charts><view class="uchart-kcal data-v-61fb252d">{{activeFoodDetail.val}}</view></view><block wx:if="{{activeFoodDetail.nutrients_four}}"><view class="info data-v-61fb252d"><block wx:for="{{$root.l0}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view class="info-item data-v-61fb252d"><view class="color data-v-61fb252d" style="{{'background-color:'+(''+item.color)+';'}}"></view><view class="data-v-61fb252d">{{item.name+""+item.proportion+"%"}}</view></view></block></view></block></view><view class="tips data-v-61fb252d"><text class="data-v-61fb252d">营养素</text><text class="data-v-61fb252d">{{activeFoodDetail.weight+"含量"}}</text></view><view class="foodDetailList data-v-61fb252d"><block wx:for="{{activeFoodDetail.nutrients_list}}" wx:for-item="item" wx:for-index="index" wx:key="index"><view class="foodDetailItem data-v-61fb252d"><view class="name data-v-61fb252d">{{item.name_ch}}</view><view class="value data-v-61fb252d">{{item.value+item.unit+''}}</view></view></block></view></view></view></scroll-view></uni-drawer></view>

View File

@ -222,7 +222,7 @@ var _default = {
}]
},
isBle: true,
// countWeight: 0,
handTrue: false,
chartData2: {},
activeFoodDetail: {},
actionOptions: [{
@ -241,7 +241,11 @@ var _default = {
computed: _objectSpread(_objectSpread({}, (0, _vuex.mapState)(["user", "countFoodInfo"])), {}, {
foodInfo: function foodInfo() {
var that = this;
that.chartData.series[0].data = that.countFoodInfo.nutrients_four[0].proportion / 100;
that.handTrue = false;
this.$nextTick(function () {
that.handTrue = true;
that.chartData.series[0].data = Number(that.countFoodInfo.nutrients_four[0].proportion) / 100;
});
return that.countFoodInfo;
},
endDate: function endDate() {
@ -252,6 +256,16 @@ var _default = {
var that = this;
that.token = uni.getStorageSync('token');
},
onPullDownRefresh: function onPullDownRefresh() {
var that = this;
that.$store.dispatch("getCountFoodInfo", {
aud_id: that.user.aud_id,
time: that.tools.getDate("start")
});
setTimeout(function () {
uni.stopPullDownRefresh();
}, 500);
},
methods: {
// 详情
showFoodDetail: function showFoodDetail(item) {
@ -330,13 +344,14 @@ var _default = {
aud_id: that.user.aud_id,
eat_log_id: item.id
}).then(function (res) {
that.$store.dispatch("getCountFoodInfo", {
aud_id: that.user.aud_id,
time: that.foodInfo.date
});
// 删除最新一天食物
if (that.foodInfo.date == that.user.food_count.date) {
that.$store.dispatch("getUserInfo");
} else {
that.$store.dispatch("getCountFoodInfo", {
aud_id: that.user.aud_id,
time: that.foodInfo.date
});
}
});
}

File diff suppressed because one or more lines are too long

View File

@ -179,14 +179,15 @@ var _default = {
data: function data() {
return {
token: "",
foodInfo: {
date: "",
list: [],
details: {},
remaining_kcal: 0,
nutrients_four: [],
trace_elements_all_day: []
},
handTrue: false,
// foodInfo: {
// date: "",
// list: [],
// details: {},
// remaining_kcal: 0,
// nutrients_four: [],
// trace_elements_all_day: []
// },
unwatch: null,
chartData: {
series: [{
@ -205,6 +206,16 @@ var _default = {
},
kcalVal: function kcalVal() {
return this.configInfo.kcal_data;
},
foodInfo: function foodInfo() {
var _this = this;
var that = this;
this.handTrue = false;
this.$nextTick(function () {
_this.handTrue = true;
that.chartData.series[0].data = _this.user.aud_id != "" ? Number(_this.user.food_count.nutrients_four[0].proportion) / 100 : 0;
});
return this.user.aud_id != "" ? this.user.food_count : this.configInfo.default_count_foot;
}
}),
onLoad: function onLoad() {
@ -219,33 +230,35 @@ var _default = {
that.$store.commit("changeBluetooth", res.available);
});
},
watch: {
user: {
handler: function handler(newVal, oldVal) {
var that = this;
that.foodInfo = that.user.aud_id != "" ? that.user.food_count : that.configInfo.default_count_foot;
that.chartData.series[0].data = newVal.aud_id != "" ? newVal.food_count.nutrients_four[0].proportion / 100 : 0;
},
immediate: true,
deep: true
}
},
onPullDownRefresh: function onPullDownRefresh() {
var that = this;
that.index = 0;
that.footlist = [];
that.chartData.series[0].data = 0;
that.$store.dispatch("getHomeConfig");
setTimeout(function () {
uni.stopPullDownRefresh();
}, 500);
},
onShow: function onShow() {
var that = this;
that.handTrue = false;
this.$nextTick(function () {
that.handTrue = true;
that.chartData.series[0].data = that.user.aud_id != "" ? Number(that.user.food_count.nutrients_four[0].proportion) / 100 : 0;
});
this.startWatching();
},
onHide: function onHide() {
this.stopWatching();
},
methods: {
handleInfo: function handleInfo() {
var that = this;
this.$nextTick(function () {
that.chartData.series[0].data = that.user.aud_id == "" ? 0 : Number(that.user.food_count.nutrients_four[0].proportion) / 100;
});
},
startWatching: function startWatching() {
this.unwatch = this.$watch('bleValue', function (newVal, oldVal) {
// 这里可以执行你的业务逻辑

File diff suppressed because one or more lines are too long