最新版计食器小程序

This commit is contained in:
qcl_123 2025-12-04 15:23:17 +08:00
commit 6c6e82e095
79 changed files with 1555 additions and 1952 deletions

View File

@ -38,6 +38,9 @@ page {
.c999{ .c999{
color: #999 !important; color: #999 !important;
} }
.red{
color: red !important;
}
.bold { .bold {
font-weight: bold; font-weight: bold;
} }
@ -919,3 +922,46 @@ page {
} }
} }
} }
.voice-wave {
display: flex;
align-items: center;
gap: 4px;
height: 40px;
}
.wave-bar {
width: 6px;
background: #3498db;
border-radius: 3px;
animation: wave 1.2s ease-in-out infinite;
}
.wave-bar:nth-child(2) {
animation-delay: -1.1s;
}
.wave-bar:nth-child(3) {
animation-delay: -1.0s;
}
.wave-bar:nth-child(4) {
animation-delay: -0.9s;
}
.wave-bar:nth-child(5) {
animation-delay: -0.8s;
}
@keyframes wave {
0%,
100% {
height: 8px;
}
50% {
height: 30px;
}
}

View File

@ -1,27 +1,45 @@
<template> <template>
<view class="weightPages"> <view class="weightPages">
<view class="table" v-if="isConnection == 0">{{msgText}}</view> <view class="table">
<view class="table" v-if="isConnection == 1" @click="openBluetoothAdapter">连接失败点击重新连接</view> <view class="text">
<view class="image" v-if="isConnection != 3"> <image src="/static/zhong.png"></image>
<image src="../static/cheng.png"></image> <text @click="openBluetoothAdapter">{{bleTipsText}}</text>
</view>
</view>
<view class="name">{{name}}</view>
<!-- 蓝牙称重 -->
<view class="weight-wrap">
<view class="weight" @click="inputDialogToggle">
<text class="val">{{weight == '' ? '0.0':weight}}</text>
<text class="unit">{{unit}}</text>
</view> </view>
<view v-if="isConnection == 3">
<view class="weight"> <view class="weight">
<view>重量<text>{{weight}}</text>{{dw=='g'?'克':'盎司'}}</view> <text class="val">{{kcal?kcal:0}}</text>
<view>热量<text>{{kcal}}</text>千卡</view> <text class="unit">kcal</text>
</view> </view>
<view class="tips">
重新测量可更新当前数据
</view> </view>
<view class="groupbtn" v-if="weightType!=2"> <view class="groupbtn">
<view class="btn" @click="handleDetailSub">完成</view> <view class="btn danwei">
<view class="btn" @click="handleDetailNext" v-if="!stopblue">下一位</view> <view class="lan border-bottom">
<view class="right">
<picker mode="selector" :range="unitList" range-key="name" @change="changleUnits"
:value="unitListIndex">
<view class="uni-input">
单位
</view> </view>
<view class="btn" @click="handlesub" v-if="weightType==2">确认添加</view> </picker>
</view> </view>
<view class="tips" v-if="isConnection == 1"> </view>
<uni-icons type="info-filled" color="#dd524d" size="20"></uni-icons> </view>
请确定设备是开机状态手机蓝牙权限已打开 <view class="btn" @click="handleDetailSub" :style="{'width':!stopblue?'20%':'45%'}">保存</view>
<view class="btn" @click="handleDetailNext" v-if="!stopblue">下一味</view>
<view class="btn qingling" @click="handleqingling">清零</view>
</view>
<view>
<uni-popup ref="popup" type="dialog">
<uni-popup-dialog mode="input" title="重量" placeholder="请输入食物重量" @close="close"
@confirm="confirm"></uni-popup-dialog>
</uni-popup>
</view> </view>
</view> </view>
</template> </template>
@ -30,20 +48,27 @@
import { import {
mapState mapState
} from "vuex"; } from "vuex";
let searchTimer = null
export default { export default {
data() { data() {
return { return {
dw: "g",
kcal: "", kcal: "",
weight: "", // weight: "",
weightALL: "", weightALL: "",
msgText: "蓝牙连接中", bleTipsText: "",
unit: '', unit: 'g',
weight0: 0, weight0: 0,
devicesList: [],
stopblue: false, stopblue: false,
isConnection: 0, // devicesList: [],
unitList: [{
name: "克",
id: '00',
unit: "g"
}, {
name: "盎司",
id: "08",
unit: "oz"
}],
unitListIndex: 0,
units: ['kg', '斤', 'st:lb', 'lb', 'g', 'ml', 'Waterml', units: ['kg', '斤', 'st:lb', 'lb', 'g', 'ml', 'Waterml',
'milkml', 'oz', 'floz', 'lboz' 'milkml', 'oz', 'floz', 'lboz'
] ]
@ -54,53 +79,35 @@
type: Number, type: Number,
default: 0 //gkcal default: 0 //gkcal
}, },
weightType: {
type: Number,
default: -1 //0,1,2
},
isLast: { isLast: {
type: Boolean, type: Boolean,
default: false default: false
},
name: {
type: String,
default: ''
} }
}, },
computed: { computed: {
...mapState(["user", "isBluetoothTyle", "bleValue"]), ...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)
return this.bleValue.countWeight
},
isConnection() {
this.bleTipsText = this.bleValue.bleTipsText
return this.bleValue.isConnectStatus
},
}, },
mounted() { mounted() {
let that = this let that = this
if (that.bleValue.serviceId != "") {
that.closeBLEConnection()
that.closeBluetoothAdapter()
that.openBluetoothAdapter()
} else {
that.openBluetoothAdapter()
}
that.onBLEConnectionStateChange()
uni.onBluetoothAdapterStateChange(function(res) { uni.onBluetoothAdapterStateChange(function(res) {
that.$store.commit("changeBluetooth", res.available); that.$store.commit("changeBluetooth", res.available);
}) })
}, },
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()
},
watch: { watch: {
// weightType: function() {
// let that = this
// that.openBluetoothAdapter()
// },
isBluetoothTyle: function() { isBluetoothTyle: function() {
let that = this let that = this
if (!that.isBluetoothTyle) { if (!that.isBluetoothTyle) {
@ -110,314 +117,79 @@
isLast: function() { isLast: function() {
let that = this let that = this
that.stopblue = that.isLast that.stopblue = that.isLast
console.log("最后", this.isLast)
} }
}, },
methods: { methods: {
// //
openBluetoothAdapter() { openBluetoothAdapter() {
let that = this let that = this
that.weight = "" if (that.isConnection == 0) return
that.kcal = "" that.kcal = ""
that.msgText = '蓝牙连接中' that.$store.commit('changeBluetoothValue', {
uni.openBluetoothAdapter({ deviceId: "",
success: e => { serviceId: "",
that.isConnection = 0 notify: '',
that.startBluetoothDeviceDiscovery() write: '',
searchTimer = setTimeout(() => { unit: "g",
uni.stopBluetoothDevicesDiscovery() countWeight: "",
if (!that.devicesList.length) { bleTipsText: "蓝牙搜索中",
clearTimeout(searchTimer); isConnectStatus: 0,
that.isConnection = 1 })
} that.$ble.openBluetoothAdapter()
}, 30000); // 30
}, },
fail: e => { changleUnits(e) {
that.isConnection = 1
console.log('openBluetoothAdapter', e)
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")
}
});
},
//
startBluetoothDeviceDiscovery() {
let that = this let that = this
uni.startBluetoothDevicesDiscovery({ let name = that.unitList[e.detail.value].name
allowDuplicatesKey: true, console.log("单位切换", name, that.unit)
services: [ if (that.unit != name) {
// "F0A0", that.handletoggleUnit(name == '盎司' ? 0x08 : 0x04)
// "A5FE"
],
success: res => {
that.isConnection = 0
that.onBluetoothDeviceFound();
},
fail: res => {
that.isConnection = 1
console.log('startBluetoothDeviceDiscovery', res)
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")
} }
}); that.unitListIndex = [e.detail.value]
that.$store.commit('changeBluetoothValue', {
unit: that.unitList[e.detail.value].unit
})
}, },
// handletoggleUnit(unit) {
onBLEConnectionStateChange() {
let that = this let that = this
uni.onBLEConnectionStateChange(function(res) { let checksum = 0;
console.log("监听蓝牙连接状态", res.connected) const bytes = [0xC5, 0x03, 0x05, 0x11]
if (!res.connected) { bytes[4] = unit
that.isConnection = 1 for (let i = 0; i < bytes.length; i++) {
that.closeBLEConnection() checksum ^= bytes[i];
that.closeBluetoothAdapter()
} }
that.$store.commit("changeConnected", res.connected); bytes[5] = checksum
}) that.sendData(new Uint8Array(bytes).buffer)
}, },
/** handleqingling() {
* 停止搜索蓝牙设备
*/
stopBluetoothDevicesDiscovery() {
uni.stopBluetoothDevicesDiscovery({
success: e => {
console.log("停止搜索蓝牙设备", e)
},
});
},
/**
* 发现外围设备
*/
onBluetoothDeviceFound() {
var that = this;
that.isConnection = 0
uni.onBluetoothDeviceFound(res => {
res.devices.forEach(device => {
device.advertisData = device.advertisData ? device.advertisData : ''
device.advertisServiceUUIDs = device.advertisServiceUUIDs ? device
.advertisServiceUUIDs : ""
let value = that.$tools.ab2hex(device.advertisData, "")
let id = value.substring(0, 4)
if (!device.name && !device.localName) {
return
}
if (device.name.indexOf("EL") !== -1 && device.advertisServiceUUIDs != '') {
that.isConnection = 3
clearTimeout(searchTimer);
let value = that.$tools.ab2hex(device.advertisData)
let parseDataRes = plugin.parseBroadcastData(device.advertisData)
let analyzeData = plugin.analyzeBroadcastScaleData(parseDataRes)
let analyzeDataText = analyzeData.text
let data = analyzeData.data
if (parseDataRes.status == 1) {
let data0 = parseDataRes.payload
let data = parseInt(data0[3]).toString(16)
console.log('data' + data)
let data1 = parseInt(data0[4]).toString(16)
let data2 = parseInt((data + data1), 16) //
//
let unit0 = parseInt(data0[5]).toString(16) //
let unit = unit0.length > 1 ? unit0.substring(1, 2) : unit0 //
let num = parseInt(unit0.substring(0, 1), 16).toString(8)
let dot = num.toString().substring(0, 1) //
let zfz = 0 //
if (num.toString().length > 1) {
dot = num.toString().substring(1, 2)
zfz = num.toString().substring(0, 1)
}
if (unit == '0') {
that.dw = 'g'
}
if (unit == "7") {
that.dw = "ml"
}
if (unit == "3") {
that.dw = "oz"
}
if (unit == "2") {
that.dw = "lb'oz"
}
if (dot == "1") {
data2 = data2 / 10
}
if (dot == "2") {
data2 = data2 / 100
}
if (zfz == "0") {
data2 = data2
}
if (zfz == "1") {
data2 = "-" + data2
}
that.weight = data2
let 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 && device
.localName.indexOf(
'Chipsea-BLE') != -1) || id == 'a5fe') {
clearTimeout(searchTimer);
that.stopBluetoothDevicesDiscovery()
that.Bluetoothfilter(device.deviceId)
}
})
});
},
//
Bluetoothfilter(deviceId) {
let that = this let that = this
const foundDevices = that.devicesList let str = "C503071100D0"
const idx = that.$ble.inArray(foundDevices, "deviceId", deviceId) let buf = new Uint8Array(str.match(/[\da-f]{2}/gi).map(function(h) {
if (idx === -1) { return parseInt(h, 16)
that.devicesList.push(deviceId); }))
that.connectDevice(deviceId) that.sendData(buf.buffer)
}
}, },
// sendData(buffer) {
async connectDevice(device_id) {
let that = this;
uni.createBLEConnection({
deviceId: device_id,
success: res => {
setTimeout(function() {
that.getBLEDeviceServices(device_id)
}, 200)
},
fail: res => {
console.log("设备连接失败,请重新连接", res);
}
});
},
/**
* 获取设备的UUID
*/
getBLEDeviceServices(device_id) {
let serviceList = [];
let that = this;
uni.getBLEDeviceServices({
deviceId: device_id,
success: res => {
console.log("获取设备的UUID成功", res)
serviceList = res.services;
for (let i = 0; i < serviceList.length; i++) {
let service = serviceList[i];
if (service.uuid.indexOf("FFF0") != -1) {
that.getBLEDeviceCharacteristics(device_id, service.uuid);
break;
}
}
},
fail: res => {
console.log('获取设备的UUID失败:', res)
}
});
},
/**
* 获取指定服务的特征值
*/
getBLEDeviceCharacteristics(deviceId, serviceId) {
let characteristicsList = [];
let that = this;
uni.getBLEDeviceCharacteristics({
deviceId: deviceId,
serviceId: serviceId,
success: res => {
console.log("服务的特征值成功", res)
let write, notify
for (let i = 0; i < res.characteristics.length; i++) {
let item = res.characteristics[i];
if (item.uuid.indexOf('0000FFF2') != -1) {
write = item.uuid
} else if (item.uuid.indexOf('0000FFF1') != -1) {
notify = item.uuid
}
}
that.notifyBLECharacteristicValueChange(deviceId, serviceId, notify)
},
fail: res => {
console.log('获取特征值失败:', JSON.stringify(res))
}
})
},
notifyBLECharacteristicValueChange(deviceId, serviceId, notify) {
let that = this let that = this
uni.notifyBLECharacteristicValueChange({ uni.writeBLECharacteristicValue({
deviceId: deviceId, deviceId: that.bleValue.deviceId,
serviceId: serviceId, serviceId: that.bleValue.serviceId,
characteristicId: notify, characteristicId: that.bleValue.write,
state: true, value: buffer,
success: () => { success: res => {
that.isConnection = 3 console.log('下发指令成功', res.errMsg)
that.$emit('connect_success')
that.msgText = "测量中,请将食物放到秤上"
uni.onBLECharacteristicValueChange(function(res) {
const value = res.value
const dataView = new DataView(value)
const header = dataView.getUint8(0)
// MCU
if (header === 0xC7) {
const cmd = dataView.getUint8(2)
switch (cmd) {
case 0x02:
that.parseWeightData(dataView)
break
case 0x03:
break
}
}
})
}, },
fail: res => { fail: res => {
console.log('获取特征值失败:', JSON.stringify(res)) console.log("下发指令失败", res);
}
})
}, },
parseWeightData(dataView) { })
const statusByte = dataView.getUint8(4)
const isNegative = !!(statusByte & 0x80) //
const statusType = statusByte & 0x0F //
// 24 ()
const weightValue =
(dataView.getUint8(5) << 16) |
(dataView.getUint8(6) << 8) |
dataView.getUint8(7)
//
const unitByte = dataView.getUint8(8)
const precision = (unitByte & 0xF0) >> 4 // 4
const unitIndex = unitByte & 0x0F // 4
//
let 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)
let kcal = (Number(this.weightKcal) * finalWeight).toFixed(2)
this.kcal = this.convertToGrams(kcal, this.dw).toFixed(2)
// console.log('' + finalWeight)
// console.log('' + this.unit)
//
// if (statusType === 0x02) {
// this.$emit('handleBle', finalWeight,this.unit,0)
// }
}, },
// //
handlesub() { handlesub() {
let that = this let that = this
console.log("weight", that.weight) console.log("测量保存", that.weight, that.unit, that.kcal)
if (Number(that.weight) > 0) { if (Number(that.weight) > 0) {
that.$emit("handleBle", that.weight, that.dw, that.kcal) that.$emit("handleBle", that.weight, that.unit, that.kcal)
that.stopBluetoothDevicesDiscovery() //
that.closeBLEConnection()
that.closeBluetoothAdapter()
} else { } else {
that.$tools.msg("数据异常,请清零后重新测量!") that.$tools.msg("数据异常,请清零后重新测量!")
} }
@ -440,24 +212,8 @@
// //
handleDetailSub() { handleDetailSub() {
let that = this let that = this
if (that.weightType == 1) { // if (Number(that.weight) > 0) {
// that.weight0 = Number(that.weight) - Number(that.weightALL) that.$emit("handleDetailSub", that.weight, that.unit, that.kcal)
that.weight0 = Number((Number(that.weight) - Number(that.weightALL)).toFixed(2))
if (that.weight0 > 0) {
that.weightALL = that.weight
} else {
that.$tools.msg("数据异常,请清零后重新测量!")
}
} else {
that.weight0 = that.weight
}
if (Number(that.weight0) > 0) {
that.$emit("handleDetailSub", that.weight0, that.dw, that.kcal)
// that.stopBluetoothDevicesDiscovery() //
// that.closeBLEConnection()
// that.closeBluetoothAdapter()
that.weight = 0
that.weight0 = 0
} else { } else {
that.$tools.msg("数据异常,请重新测量!") that.$tools.msg("数据异常,请重新测量!")
} }
@ -465,110 +221,83 @@
// //
handleDetailNext() { handleDetailNext() {
let that = this let that = this
if (that.weightType == 1) { if (Number(that.weight) > 0) {
console.log('weight' + that.weight) that.$emit("handleDetailNext", that.weight, that.unit, that.kcal)
console.log('weight0' + that.weight0)
console.log('weightALL' + that.weightALL)
// that.weight0 = Number(that.weight) - Number(that.weightALL)
that.weight0 = Number((Number(that.weight) - Number(that.weightALL)).toFixed(2))
if (that.weight0 > 0) {
that.weightALL = that.weight
} else {
that.$tools.msg("数据异常,请清零后重新测量!")
}
} else {
that.weight0 = that.weight
}
if (Number(that.weight0) > 0) {
that.$emit("handleDetailNext", that.weight0, that.dw, that.kcal)
that.weight = 0
that.weight0 = 0
} else { } else {
that.$tools.msg("数据异常,请清零后重新测量!") that.$tools.msg("数据异常,请清零后重新测量!")
} }
}, },
unitConversion(unit) {
handlechongzhi(weight) { if (unit == 'kcal') {
let that = this return '千卡'
console.log('当前总重:' + that.weightALL) } else if (unit == 'g') {
console.log('重置重量:' + weight) return '克'
if (that.weightType == 1) { } else if (unit == 'lb') {
that.weightALL = Number((Number(that.weightALL) - Number(weight)).toFixed(2)) return '磅'
console.log('剩余重量:' + that.weightALL) } else if (unit == 'oz') {
return '盎司'
} }
return unit
}, },
handleBack() { handleBack() {
let that = this let that = this
that.isConnection = 1 that.$store.commit("changeBluetoothValue", {
that.stopBluetoothDevicesDiscovery() // bleTipsText: "连接失败,点击重新连接",
that.closeBLEConnection() isConnectStatus: 1
that.closeBluetoothAdapter()
},
/**
* 断开蓝牙模块
*/
closeBluetoothAdapter() {
let that = this;
uni.closeBluetoothAdapter({
success: res => {
console.log('蓝牙模块关闭成功');
}
}) })
that.$ble.stopBluetoothDevicesDiscovery() //
that.$ble.closeBLEConnection(that.bleValue.deviceId)
that.$ble.closeBluetoothAdapter()
}, },
/** confirm(value) {
* 断开蓝牙连接 console.log("手动输入", value)
*/ this.$store.commit("changeBluetoothValue", {
closeBLEConnection() { countWeight: value,
var that = this; unit: this.unitList[this.unitListIndex].unit
uni.closeBLEConnection({ })
deviceId: that.deviceId, this.$refs.popup.close()
success: res => { },
console.log('断开蓝牙连接成功'); close() {
} this.$refs.popup.close()
}); },
inputDialogToggle() {
this.$refs.popup.open()
}, },
// isNutritionScale(advertisData) {
// const buffer = this.base64ToArrayBuffer(advertisData)
// const dataView = new DataView(buffer)
// //
// if (dataView.getUint16(0) !== 0xA5FE) return false
// // (:0x0001)
// const typeId = dataView.getUint16(2)
// if (typeId !== 0x0001) return false
// // ID (:0x0001)
// const vendorId = dataView.getUint16(4)
// return vendorId === 0x0001
// },
// base64ToArrayBuffer(base64) {
// const str = atob(base64)
// const buffer = new ArrayBuffer(str.length)
// const view = new Uint8Array(buffer)
// for (let i = 0; i < str.length; i++) {
// view[i] = str.charCodeAt(i)
// }
// return buffer
// }
}, },
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.weightPages { .table {
width: 100%;
font-size: 14px;
align-items: center;
padding: 5px 0;
border-radius: 5px;
display: flex; display: flex;
flex-wrap: wrap; justify-content: space-between;
flex-direction: column;
.text {
color: #8284f0;
display: flex;
image {
width: 22px;
height: 22px;
margin-right: 5px;
}
}
}
.weightPages {
position: absolute; position: absolute;
justify-content: space-around; left: 15px;
left: 0; right: 15px;
right: 0; bottom: 30rpx;
bottom: 40rpx; top: 15px;
top: 120rpx; display: flex;
margin-top: 40rpx; flex-direction: column;
justify-content: space-between;
.weight { .weight {
background: #fff; background: #fff;
@ -597,47 +326,80 @@
} }
} }
.tips { .tips {
font-size: 24rpx; font-size: 24rpx;
text-align: center; text-align: center;
} }
.btn {
color: #fff;
width: 80%;
margin-left: 10%
}
.groupbtn { .groupbtn {
margin-top: 0;
display: flex;
align-items: center;
justify-content: space-between;
.btn { .btn {
color: #000 !important; width: 20%;
color: $maincolor;
text-align: center;
height: 40px;
line-height: 40px;
border-radius: 10px;
border: 1px solid $maincolor;
background: #fff;
margin: 0;
view {
border: none !important;
width: auto !important;
height: 40px !important;
line-height: 40px !important;
}
} }
} }
.table { .weight-wrap {
display: flex;
justify-content: space-around;
align-items: center;
color: #666;
font-size: 16px;
text-align: center;
height: 60px;
border-radius: 10px;
.weight {
display: flex;
justify-content: center;
align-items: center;
width: 48%;
padding: 30rpx 0;
border-radius: 20rpx;
background-color: #F8F8F8;
.val {
font-size: 54rpx;
color: #F0AE43;
margin: 0 !important;
}
.unit {
padding: 10rpx;
margin-left: 20rpx;
font-size: 28rpx;
color: #fff;
border-radius: 8rpx;
background-color: #F0AE43;
}
}
}
.name {
width: 100%; width: 100%;
text-align: center;
font-size: 16px; font-size: 16px;
font-weight: bold; font-weight: bold;
text-align: center;
margin: 30rpx 0;
}
.image {
width: 112rpx;
height: 112rpx;
margin: auto;
image {
width: 100%;
height: 100%;
}
}
.tips {
margin-bottom: 30rpx;
margin-left: 30rpx;
display: flex;
color: #999;
} }
} }
</style> </style>

View File

@ -14,7 +14,7 @@
<!-- 蓝牙称重 --> <!-- 蓝牙称重 -->
<view class="weight" @click="inputDialogToggle"> <view class="weight" @click="inputDialogToggle">
<text class="val">{{weight == '' ? '0.0':weight}}</text> <text class="val">{{weight == '' ? '0.0':weight}}</text>
<text class="unit">{{unit}}</text> <text class="unit">{{unitConversion(unit)}}</text>
</view> </view>
</view> </view>
<!-- --> <!-- -->
@ -31,8 +31,8 @@
</view> </view>
</view> </view>
</view> </view>
<view class="btn addbtn size14" @click="handlesub" v-if="weightType==2&&btnType==2">保存</view> <view class="btn addbtn size14" @click="handlesub" v-if="btnType==2">保存</view>
<view class="btn addbtn" @click="handleAddFood" v-if="weightType==2&&btnType==1">+</view> <view class="btn addbtn" @click="handleAddFood" v-if="btnType==1">+</view>
<view class="btn qingling" @click="handleqingling">清零</view> <view class="btn qingling" @click="handleqingling">清零</view>
</view> </view>
<!-- --> <!-- -->
@ -56,6 +56,7 @@
return { return {
kcal: 0, kcal: 0,
unit: '', unit: '',
// weight: "",
bleTipsText: "", bleTipsText: "",
inputDialog: false, inputDialog: false,
unitList: [{ unitList: [{
@ -78,10 +79,6 @@
type: Number, type: Number,
default: 0 //100gkcal default: 0 //100gkcal
}, },
weightType: {
type: Number,
default: -1 //0,1,2
},
btnType: { btnType: {
type: Number, type: Number,
default: 1 //12 default: 1 //12
@ -91,7 +88,7 @@
...mapState(["bleValue", "isBluetoothTyle", "countFoodInfo"]), ...mapState(["bleValue", "isBluetoothTyle", "countFoodInfo"]),
weight() { weight() {
this.kcal = (Number(this.weightKcal) / 100 * this.bleValue.countWeight).toFixed(2) this.kcal = (Number(this.weightKcal) / 100 * this.bleValue.countWeight).toFixed(2)
this.unit = this.unitConversion(this.bleValue.unit) this.unit = this.bleValue.unit
return this.bleValue.countWeight return this.bleValue.countWeight
}, },
isConnection() { isConnection() {
@ -140,6 +137,7 @@
}) })
that.$ble.openBluetoothAdapter() that.$ble.openBluetoothAdapter()
}, },
changleUnits(e) { changleUnits(e) {
let that = this let that = this
let name = that.unitList[e.detail.value].name let name = that.unitList[e.detail.value].name
@ -240,30 +238,6 @@
close() { close() {
this.$refs.popup.close() this.$refs.popup.close()
}, },
// isNutritionScale(advertisData) {
// const buffer = this.base64ToArrayBuffer(advertisData)
// const dataView = new DataView(buffer)
// //
// if (dataView.getUint16(0) !== 0xA5FE) return false
// // (:0x0001)
// const typeId = dataView.getUint16(2)
// if (typeId !== 0x0001) return false
// // ID (:0x0001)
// const vendorId = dataView.getUint16(4)
// return vendorId === 0x0001
// },
// base64ToArrayBuffer(base64) {
// const str = atob(base64)
// const buffer = new ArrayBuffer(str.length)
// const view = new Uint8Array(buffer)
// for (let i = 0; i < str.length; i++) {
// view[i] = str.charCodeAt(i)
// }
// return buffer
// }
}, },
} }
</script> </script>
@ -314,7 +288,7 @@
.weight { .weight {
.val { .val {
font-size: 40rpx; font-size: 54rpx;
color: #F0AE43; color: #F0AE43;
margin: 0 !important; margin: 0 !important;
} }
@ -328,20 +302,6 @@
background-color: #F0AE43; background-color: #F0AE43;
} }
} }
.kcal {
font-size: 32rpx;
.val {
font-size: 40rpx;
color: #F0AE43;
margin: 0 !important;
}
.unit {
margin-left: 20rpx;
}
}
} }
.tips { .tips {

View File

@ -14,7 +14,7 @@
<view class="serach-box"> <view class="serach-box">
<view class="searchInput"> <view class="searchInput">
<input placeholder="请输入..." class="city-serach-input" v-model="search_value" /> <input placeholder="请输入..." class="city-serach-input" v-model="search_value" />
<icon v-if="search_value" class="iconfont icon-error" @click="handlecolse"></icon> <icon v-if="search_value" class="iconfont icon-error" @click="handlecolse" size="30"></icon>
</view> </view>
<view class="searchBtn"> <view class="searchBtn">
<view @click="handleSerach">搜索</view> <view @click="handleSerach">搜索</view>
@ -52,6 +52,24 @@
</view> </view>
</view> </view>
</view> </view>
<!-- 底部购物车 -->
<view class="groupbtn">
<view @click="handleisShop" class="left">
<view class="che">
<text>{{ActiveList.filter(ite => ite.meals_type == foodName).length||0}}</text>
<icon class="t-icon t-icon-canpan"></icon>
</view>
<view class="type">
{{foodName}}
<image src="/static/arrow-down.png"></image>
</view>
</view>
<view class="mic-icon" @touchstart="onVoiceTouchStart" @touchend="onVoiceTouchEnd"
@touchcancel="cancelRecording">
<uni-icons type="mic-filled" size="20" color="#fff"></uni-icons>
语音搜索
</view>
</view>
<!-- 搜索列表 --> <!-- 搜索列表 -->
<view class="search_list" v-if="search_list.length"> <view class="search_list" v-if="search_list.length">
<view class="search_list_item" v-for="(ite,ind) in search_list" @click="handleDetail(ite)"> <view class="search_list_item" v-for="(ite,ind) in search_list" @click="handleDetail(ite)">
@ -63,19 +81,62 @@
</view> </view>
<view class="endtext" v-if="!lastPage || page >= lastPage"> 到底了看看别的吧 </view> <view class="endtext" v-if="!lastPage || page >= lastPage"> 到底了看看别的吧 </view>
</view> </view>
<!-- 购物车列表 --> <!-- 购物车弹框 -->
<view class="wrapper activeList" v-if="isShop"> <view class="wrapper activeList" v-if="isShop">
<view class="bg" @click='isShop=false'> <view class="bg" @click='isShop=false'>
<view class="box2" @click.stop> <view class="box2" @click.stop>
<!-- -->
<icon class="iconfont icon-error" @click="isShop=false"></icon>
<view class="jishiqi">
<view class="left">
<view class="chart-wrap">
<qiun-data-charts type="arcbar" :chartData="chartData" :cHeight="280" :cWidth="280"
:canvas2d="true" canvasId="searchCharts" />
<view class="center">
摄入
<text>{{foodInfo[0].today_intake}}</text>
<view class="unit">Kcal</view>
</view>
</view>
<view class="mubiao">
目标<text>{{foodInfo[0].suggestion}}</text>kcal
</view>
</view>
<view class="right">
<view class="item" v-for="(ite,ind) in foodInfo.slice(1)">
<view class="left-icon">
<image :src="ite.icon"></image>
<view class="val" :style="{color:ite.color}">{{ite.proportion_fp||0}}%</view>
</view>
<view class="right-info">
<view class="right-info-top">
<text class="name">{{ite.name}}</text>
<text class="">
{{ite.today_intake||0}}/{{ite.suggestion||0}}g
</text>
</view>
<view class="right-info-bottom">
<view class="val" :style="{ width: ite.proportion + '%',background:ite.color}">
</view>
</view>
</view>
</view>
</view>
</view>
<!-- -->
<view class="box_list">
<view class="left"> <view class="left">
<view :class="[item.name == foodName?'active':'']" v-for="(item,index) in foodItem" <view :class="[item.name == foodName?'active':'']" v-for="(item,index) in foodItem"
@click="handleToggle(item.name)"> @click="handleToggle(item.name)">
{{item.name}} {{item.name}}
</view> </view>
</view> </view>
<view class="list" v-if="ActiveList.length"> <view class="box_list_item" v-if="ActiveList.length">
<view class="length">{{ActiveList.filter(ite => ite.meals_type == foodName).length}}条记录</view> <view class="length"><text
<view class="item" v-for="(ite,ind) in ActiveList" :key="ind" v-if="ite.meals_type==foodName"> class="red">{{ActiveList.filter(ite => ite.meals_type == foodName).length}}</text>条记录
</view>
<view class="item" v-for="(ite,ind) in ActiveList" :key="ind"
v-if="ite.meals_type==foodName">
<view class="item-left"> <view class="item-left">
<image :src="ite.pic_url"></image> <image :src="ite.pic_url"></image>
<view class="name"> <view class="name">
@ -94,11 +155,12 @@
</view> </view>
</view> </view>
</view> </view>
<!-- 测量区 --> </view>
<!-- 测量弹框 -->
<view class="wrapper" v-if="IsWeight"> <view class="wrapper" v-if="IsWeight">
<view class="bg" @click='IsWeight=false'> <view class="bg" @click='IsWeight=false'>
<view class="box" @click.stop> <view class="box" @click.stop>
<icon class="iconfont icon-error" @click="IsWeight=false" size="30"></icon> <icon class="iconfont icon-error" @click="IsWeight=false"></icon>
<scroll-view style="height: 100%;margin-top: 20rpx;" scroll-y="true"> <scroll-view style="height: 100%;margin-top: 20rpx;" scroll-y="true">
<view class="box-info"> <view class="box-info">
<view class="foodItem"> <view class="foodItem">
@ -124,7 +186,7 @@
</view> </view>
<!-- 蓝牙称重 --> <!-- 蓝牙称重 -->
<view class="blue-tooth" v-if="isBle"> <view class="blue-tooth" v-if="isBle">
<blue-tooth @handleBle="handleBle" :weightType="'2'" :weightKcal="weightKcal" <blue-tooth @handleBle="handleBle" :weightKcal="weightKcal"
@realTimeWeight="realTimeWeight" :btnType="'2'"></blue-tooth> @realTimeWeight="realTimeWeight" :btnType="'2'"></blue-tooth>
</view> </view>
</view> </view>
@ -150,23 +212,20 @@
</view> </view>
</view> </view>
</view> </view>
<!-- 底部购物车 --> <!-- 语音弹框 -->
<view class="groupbtn"> <view class="wrapper" v-if="showAutoSearchDlg">
<view @click="isShop =! isShop" class="left"> <view class="auto-search-dialog">
<view class="che"> <view class="auto-search-inner">
<text>{{ActiveList.filter(ite => ite.meals_type == foodName).length||0}}</text> <view class="voice-wave">
<icon class="t-icon t-icon-canpan"></icon> <view class="wave-bar"></view>
</view> <view class="wave-bar"></view>
<view class="type"> <view class="wave-bar"></view>
{{foodName}} <view class="wave-bar"></view>
<image src="/static/arrow-down.png"></image> <view class="wave-bar"></view>
<view class="wave-bar"></view>
</view> </view>
</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>
<!-- <view class="subbtn" @click="handlesubbtn"> 完成</view> -->
</view> </view>
</view> </view>
</template> </template>
@ -182,13 +241,13 @@
export default { export default {
data() { data() {
return { return {
opts: { chartData: {
background: "transparent", series: [{
title: { data: 0,
name: "", color: "#3CB383"
}]
}, },
}, foodInfo: [],
chartData: {},
time: "", time: "",
page: 1, page: 1,
foodName: "", foodName: "",
@ -202,10 +261,8 @@
search_value: '', search_value: '',
ActiveList: [], ActiveList: [],
activeType: {}, activeType: {},
mic_touch: false,
voiceManager: null, voiceManager: null,
autoSearchContent: "", showAutoSearchDlg: false
showAutoSearchDlg: false,
}; };
}, },
computed: { computed: {
@ -213,12 +270,12 @@
popular_food() { popular_food() {
return this.configInfo.search_guess.food_data return this.configInfo.search_guess.food_data
}, },
history_food() {
return this.configInfo.search_history.food
},
foodItem() { foodItem() {
return this.configInfo.meal_list return this.configInfo.meal_list
}, },
history_food() {
return this.configInfo.search_history.food
},
}, },
components: { components: {
search, search,
@ -263,24 +320,37 @@
this.handleSerach() this.handleSerach()
}, },
methods: { methods: {
//
onVoiceTouchStart() { onVoiceTouchStart() {
let that = this let that = this
that.mic_touch = true that.showAutoSearchDlg = true
that.isShop = false
that.voiceManager.start({ that.voiceManager.start({
duration: 60000, duration: 60000,
lang: "zh_CN" lang: "zh_CN"
}) })
}, },
//
onVoiceTouchEnd() { onVoiceTouchEnd() {
let that = this let that = this
that.mic_touch = false that.showAutoSearchDlg = false
that.voiceManager.stop() that.voiceManager.stop()
}, },
//
cancelRecording() {
// #ifdef MP-WEIXIN
if (this.voiceManager) {
this.voiceManager.stop()
this.showAutoSearchDlg = false
}
// #endif
},
// //
handleToggle(name) { handleToggle(name) {
this.search_value = "" this.search_value = ""
this.search_list = [] this.search_list = []
this.foodName = name this.foodName = name
this.handleAddEveryMealFood()
}, },
// //
realTimeWeight(weight, unit) { realTimeWeight(weight, unit) {
@ -317,9 +387,9 @@
that.isBle = true that.isBle = true
that.isShop = false that.isShop = false
that.IsWeight = true that.IsWeight = true
that.showAutoSearchDlg = false
that.activeType = ite that.activeType = ite
that.weightKcal = ite.kcal that.weightKcal = ite.kcal
console.log("111111", ite, that.bleValue)
if (that.bleValue.serviceId != "") { if (that.bleValue.serviceId != "") {
that.realTimeWeight(that.bleValue.countWeight, that.bleValue.unit) that.realTimeWeight(that.bleValue.countWeight, that.bleValue.unit)
} else { } else {
@ -328,22 +398,6 @@
unit: "g" unit: "g"
}) })
that.realTimeWeight(100, "g") that.realTimeWeight(100, "g")
// that.activeType.weight = 100
// let chart_data = []
// that.opts.color = []
// for (let i = 1; i < ite.nutrients_four.length; ++i) {
// that.opts.color.push(ite.nutrients_four[i].color)
// chart_data.push({
// name: ite.nutrients_four[i].name,
// value: Number(ite.nutrients_four[i].proportion),
// })
// }
// that.opts.title.name = ite.kcal
// that.chartData = JSON.parse(JSON.stringify({
// series: [{
// data: chart_data
// }]
// }));
} }
}, },
// //
@ -355,7 +409,6 @@
that.activeType.weight = weight that.activeType.weight = weight
that.activeType.meals_type = that.foodName that.activeType.meals_type = that.foodName
list.push(that.activeType) list.push(that.activeType)
console.log("list", list)
that.$model.getAddIntakeFood({ that.$model.getAddIntakeFood({
aud_id: that.user.aud_id, aud_id: that.user.aud_id,
food_list: list, food_list: list,
@ -371,12 +424,6 @@
}) })
} }
that.activeType.food_id = res.data.id that.activeType.food_id = res.data.id
if (that.activeType.weight <= 0) {
that.$tools.msg("请输入重量")
return
}
that.isBle = false
that.IsWeight = false
if (that.ActiveList.indexOf(that.activeType) == -1) { if (that.ActiveList.indexOf(that.activeType) == -1) {
that.ActiveList.push(that.activeType); that.ActiveList.push(that.activeType);
} else { } else {
@ -384,16 +431,49 @@
that.ActiveList[index].weight = that.activeType.weight; that.ActiveList[index].weight = that.activeType.weight;
that.ActiveList[index].unit = that.activeType.unit; that.ActiveList[index].unit = that.activeType.unit;
} }
setTimeout(() => {
that.handleAddEveryMealFood()
}, 100)
}) })
}, },
handleAddEveryMealFood() {
let that = this
let list = []
console.log("that.ActiveList", that.ActiveList)
that.ActiveList.forEach(ite => {
if (ite.meals_type == that.foodName) {
list.push(ite.food_id)
}
})
console.log("MealFood", list)
that.$model.getAddEveryMealFood({
log_id: list,
}).then(res => {
if (res.code != 0) return
that.isBle = false
that.IsWeight = false
that.isShop = true
that.foodInfo = res.data.nutrients_four
that.chartData.series[0].data = Number(res.data.nutrients_four[0].proportion) / 100
})
},
handleisShop() {
let that = this
if (!that.ActiveList.length) {
that.foodInfo = that.configInfo.default_count_foot.nutrients_four
that.chartData.series[0].data = Number(that.configInfo.default_count_foot.nutrients_four[0]
.proportion) / 100
}
that.isShop = true
},
// //
handleSerach() { handleSerach() {
let that = this let that = this
that.search_list = []
if (that.search_value == "") { if (that.search_value == "") {
that.$tools.msg("输入关键字后搜索") that.$tools.msg("输入关键字后搜索")
return return
} }
that.search_list = []
that.$model.getFoodSearch({ that.$model.getFoodSearch({
page: that.page, page: that.page,
search_data: that.search_value search_data: that.search_value
@ -417,24 +497,8 @@
handleSearchHistory(text) { handleSearchHistory(text) {
let that = this let that = this
that.search_value = text that.search_value = text
that.showAutoSearchDlg = false
that.handleSerach() that.handleSerach()
}, },
//
onVoiceTouchStart() {
let that = this
that.mic_touch = true
that.voiceManager.start({
duration: 60000,
lang: "zh_CN"
})
},
//
onVoiceTouchEnd() {
let that = this
that.mic_touch = false
that.voiceManager.stop()
},
// //
changeClickType(e) { changeClickType(e) {
this.search_value = "" this.search_value = ""
@ -461,6 +525,7 @@
time: that.time time: that.time
}) })
} }
that.handleAddEveryMealFood()
}) })
} }
} }
@ -706,7 +771,7 @@
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
height: 100%; bottom: 75px;
background-color: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.5);
z-index: 999; z-index: 999;
@ -716,53 +781,11 @@
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
position: relative; position: relative;
width: 70%; width: 50%;
height: 350rpx; padding: 60rpx 0;
padding: 80rpx 0;
background-color: #fff; background-color: #fff;
border-radius: 20rpx; border-radius: 20rpx;
box-shadow: 0 0 20rpx #ccc; box-shadow: 0 0 20rpx #ccc;
.close {
position: absolute;
left: 0;
right: 0;
bottom: -140rpx;
width: 90rpx;
margin: 0 auto;
}
}
text {
font-size: 32rpx;
width: 80%;
}
.mic-icon {
display: flex;
justify-content: center;
align-items: center;
width: 150rpx;
height: 150rpx;
border-radius: 50%;
border: 8rpx solid #777777;
}
.btn-wrap {
display: flex;
justify-content: space-around;
width: 90%;
.retry,
.confirm {
width: 190rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
font-size: 28rpx;
border: 2rpx solid #777;
border-radius: 15rpx;
}
} }
} }
@ -1091,32 +1114,66 @@
.icon-error { .icon-error {
position: absolute; position: absolute;
right: 20rpx; right: 20rpx;
top: -34rpx; top: -40rpx;
background: #fff; background: #fff;
font-size: 60rpx; font-size: 80rpx;
width: 60rpx; width: 80rpx;
height: 60rpx; height: 80rpx;
border-radius: 50%; border-radius: 50%;
} }
.box2 { .box2 {
left: 0; left: 0;
right: 0; right: 0;
height: 55%; top: 80rpx;
bottom: 0; bottom: 0;
background-color: #fff;
overflow: scroll;
position: absolute; position: absolute;
padding: 20rpx; padding: 20rpx;
padding-bottom: 90px;
background-color: #dfdfdf;
.jishiqi {
width: calc(100% - 20px);
overflow: hidden;
background: #fff;
padding: 10px;
border-radius: 10px;
height: 340rpx;
.chart-wrap {
margin-top: -15px;
}
.center {
height: 270rpx;
top: 80rpx;
}
.mubiao {
margin-top: 10px
}
}
.box_list {
position: absolute;
left: 10px;
right: 10px;
bottom: 90px;
background: #fff;
border-radius: 10px;
margin-top: 15px;
overflow: hidden;
top: 420rpx;
.left { .left {
width: 80px; width: 80px;
background: #dfdfdf; background: #fff;
position: absolute; position: absolute;
left: 0; left: 0px;
top: 0; top: 0px;
bottom: 75px; bottom: 0px;
display: flex; display: flex;
border-radius: 10px;
flex-direction: column; flex-direction: column;
view { view {
@ -1127,25 +1184,32 @@
} }
.active { .active {
background-color: #fff; border-radius: 10px;
background-color: #EDFFF4;
color: #3CB383;
} }
} }
.list { .box_list_item {
margin-bottom: 90px; position: absolute;
width: calc(100% - 80px); top: 10px;
margin-left: 80px; left: 90px;
right: 0;
bottom: 0;
overflow: scroll;
padding-bottom: 15px;
.length { .length {
width: 100%; width: 100%;
height: 30px; height: 35px;
line-height: 30px; line-height: 35px;
margin-top: -5px; margin-top: -5px;
font-weight: bold;
} }
.item { .item {
width: 100%; width: 100%;
height: 45px; height: 50px;
display: flex; display: flex;
padding: 5px 0; padding: 5px 0;
position: relative; position: relative;
@ -1195,7 +1259,7 @@
color: red !important; color: red !important;
font-size: 18px !important; font-size: 18px !important;
} }
}
} }
} }
} }

View File

@ -64,9 +64,10 @@
<text>{{ActiveList.length||0}}</text> <text>{{ActiveList.length||0}}</text>
<icon class="t-icon t-icon-canpan"></icon> <icon class="t-icon t-icon-canpan"></icon>
</view> </view>
<view class="subbtn" @click="handlesubbtn"> 确定</view> <!-- <view class="subbtn" @click="handlesubbtn"> 确定</view> -->
</view> </view>
<view class="mic-icon" @touchstart="onVoiceTouchStart" @touchend="onVoiceTouchEnd"> <view class="mic-icon" @touchstart="onVoiceTouchStart" @touchend="onVoiceTouchEnd"
@touchcancel="cancelRecording">
<uni-icons type="mic-filled" size="20" :color="mic_touch ? '#777777' : '#fff'"></uni-icons> <uni-icons type="mic-filled" size="20" :color="mic_touch ? '#777777' : '#fff'"></uni-icons>
语音搜索 语音搜索
</view> </view>
@ -91,6 +92,22 @@
</view> </view>
</view> </view>
</view> </view>
<!-- -->
<!-- 语音弹框 -->
<view class="wrapper" v-if="showAutoSearchDlg">
<view class="auto-search-dialog">
<view class="auto-search-inner">
<view class="voice-wave">
<view class="wave-bar"></view>
<view class="wave-bar"></view>
<view class="wave-bar"></view>
<view class="wave-bar"></view>
<view class="wave-bar"></view>
<view class="wave-bar"></view>
</view>
</view>
</view>
</view>
</view> </view>
</template> </template>
@ -158,6 +175,8 @@
handleDetail(ite, ind) { handleDetail(ite, ind) {
let that = this let that = this
let list = [] let list = []
let pages = getCurrentPages()
let prevPage = pages[pages.length - 2]
if (ind == 1) { if (ind == 1) {
list.push(ite) list.push(ite)
that.ActiveList = that.$tools.mergeAndDeduplicate(that.ActiveList, list, 'name') that.ActiveList = that.$tools.mergeAndDeduplicate(that.ActiveList, list, 'name')
@ -168,15 +187,16 @@
} }
} }
} }
prevPage.$vm.getAddFood(that.ActiveList)
}, },
// //
handleSerach() { handleSerach() {
let that = this let that = this
that.search_list = []
if (that.search_value == "") { if (that.search_value == "") {
that.$tools.msg("输入关键字后搜索") that.$tools.msg("输入关键字后搜索")
return return
} }
that.search_list = []
that.$model.getFoodSearch({ that.$model.getFoodSearch({
page: that.page, page: that.page,
search_data: that.search_value search_data: that.search_value
@ -207,7 +227,7 @@
// //
onVoiceTouchStart() { onVoiceTouchStart() {
let that = this let that = this
that.mic_touch = true that.showAutoSearchDlg = true
that.voiceManager.start({ that.voiceManager.start({
duration: 60000, duration: 60000,
lang: "zh_CN" lang: "zh_CN"
@ -216,9 +236,18 @@
// //
onVoiceTouchEnd() { onVoiceTouchEnd() {
let that = this let that = this
that.mic_touch = false that.showAutoSearchDlg = false
that.voiceManager.stop() that.voiceManager.stop()
}, },
//
cancelRecording() {
// #ifdef MP-WEIXIN
if (this.voiceManager) {
this.voiceManager.stop()
this.showAutoSearchDlg = false
}
// #endif
},
// //
handlesubbtn() { handlesubbtn() {
let that = this let that = this
@ -232,6 +261,9 @@
// //
handledelactive(ite) { handledelactive(ite) {
let that = this let that = this
let pages = getCurrentPages()
let prevPage = pages[pages.length - 2]
prevPage.$vm.handledel(ite.id, "食材")
that.ActiveList.splice(that.ActiveList.indexOf(ite), 1); that.ActiveList.splice(that.ActiveList.indexOf(ite), 1);
}, },
} }
@ -463,7 +495,7 @@
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
height: 100%; bottom: 75px;
background-color: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.5);
z-index: 999; z-index: 999;
@ -473,55 +505,14 @@
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
position: relative; position: relative;
width: 70%; width: 50%;
height: 350rpx; padding: 60rpx 0;
padding: 80rpx 0;
background-color: #fff; background-color: #fff;
border-radius: 20rpx; border-radius: 20rpx;
box-shadow: 0 0 20rpx #ccc; box-shadow: 0 0 20rpx #ccc;
.close {
position: absolute;
left: 0;
right: 0;
bottom: -140rpx;
width: 90rpx;
margin: 0 auto;
} }
} }
text {
font-size: 32rpx;
width: 80%;
}
.mic-icon {
display: flex;
justify-content: center;
align-items: center;
width: 150rpx;
height: 150rpx;
border-radius: 50%;
border: 8rpx solid #777777;
}
.btn-wrap {
display: flex;
justify-content: space-around;
width: 90%;
.retry,
.confirm {
width: 190rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
font-size: 28rpx;
border: 2rpx solid #777;
border-radius: 15rpx;
}
}
}
.activeList { .activeList {
z-index: 12; z-index: 12;
@ -556,14 +547,14 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
padding: 0 20rpx 40rpx; padding: 0 20rpx;
position: fixed; position: fixed;
bottom: 0; bottom: 0rpx;
left: 0; left: 0;
right: 0; right: 0;
height: 90px; height: 60px;
z-index: 99; padding-bottom: 15px;
flex-wrap: wrap; z-index: 15;
background-color: #fff; background-color: #fff;
overflow: hidden; overflow: hidden;
box-shadow: 0px 1px 5px 2px #dfe2e1fc; box-shadow: 0px 1px 5px 2px #dfe2e1fc;
@ -579,7 +570,7 @@
} }
.jilu { .jilu {
width: 100%; width: 110px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
@ -623,9 +614,9 @@
.mic-icon { .mic-icon {
color: #fff; color: #fff;
width: 100%; width: calc(100% - 120px);
padding: 8px 0; padding: 8px 0;
background: $maincolor; background: #3CB383;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;

View File

@ -72,10 +72,6 @@
<icon class="t-icon" :class="[info.collect_status=='yes'?'t-icon-icon3':'t-icon-icon_collect']"></icon> <icon class="t-icon" :class="[info.collect_status=='yes'?'t-icon-icon3':'t-icon-icon_collect']"></icon>
<text>收藏</text> <text>收藏</text>
</view> </view>
<!-- <view class="item" @click="handleshare()">
<icon class="iconfont icon-a-fenxiang2"></icon>
<text>分享</text>
</view> -->
<view class="item" v-if="type=='我的菜谱'" @click="handleEdit()"> <view class="item" v-if="type=='我的菜谱'" @click="handleEdit()">
<icon class="iconfont icon-bianji"></icon> <icon class="iconfont icon-bianji"></icon>
<text>编辑</text> <text>编辑</text>
@ -86,27 +82,31 @@
</view> </view>
</view> </view>
<!--蓝牙连接区 --> <!--蓝牙连接区 -->
<view class="wrapper" v-show="isBle"> <view class="wrapper" v-if="isBle">
<view class="bg" @click="isBle = false"> <view class="bg" @click="isBle = false">
<view class="box weightBox" @click.stop> <view class="box weightBox">
<view class="table">
<text>备料</text>
<icon class="iconfont icon-error" @click='isBle = false'></icon> <icon class="iconfont icon-error" @click='isBle = false'></icon>
</view> <view class="foodlist" @click.stop>
<view class="foodlist">
<view class="text"> <view class="text">
<text>食材</text> <text style="width: 30%;">食材</text>
<text>建议</text> <text style="width: 18%;">建议</text>
<view class="kcal">
<text>重量</text> <text>重量</text>
<text>热量</text> <text>热量</text>
<text>重秤</text> <text>重秤</text>
</view> </view>
</view>
<view class="item" v-for="(ite,ind) in info.tags[0].list" :key="ind" <view class="item" v-for="(ite,ind) in info.tags[0].list" :key="ind"
v-if="info.tags&&info.tags[0].list.length"> v-if="info.tags&&info.tags[0].list.length"
:class="[activeType.id&&activeType.id ==ite.id&&!ite.newweight?'active2':'']">
<view class="name">{{ite.name}}</view> <view class="name">{{ite.name}}</view>
<view class="num"> <view class="num" style="width: 18%;">
{{ite.weight}}{{ite.unit}} {{ite.weight}}{{ite.unit}}
</view> </view>
<view class="kcal" v-if="activeType.id&&activeType.id ==ite.id&&!ite.newweight">
正在测量...
</view>
<view class="kcal" v-else>
<view class="num" v-if="ite.newweight"> <view class="num" v-if="ite.newweight">
{{ite.newweight}}{{ite.newunit=="oz"?'盎司':'克'}} {{ite.newweight}}{{ite.newunit=="oz"?'盎司':'克'}}
</view> </view>
@ -116,16 +116,13 @@
<view class="edit" @click="handlechongzhi(ite,ind)" v-if="ite.newweight"> <view class="edit" @click="handlechongzhi(ite,ind)" v-if="ite.newweight">
<icon class="iconfont icon-reset"></icon> <icon class="iconfont icon-reset"></icon>
</view> </view>
<view class="kcal" v-if="activeType.id&&activeType.id ==ite.id&&!ite.newweight">
正在测量...
</view> </view>
</view> </view>
</view> </view>
<view class="title" :style="{display: (!isWeightType&&iSWeightSub) ? '' : 'none'}"> <view class="blue-tooth" :style="{display: (!isWeightType&&iSWeightSub) ? '' : 'none'}" @click.stop>
<view class="name">{{activeType.name}}</view>
<blue-tooth ref="blueTooth" @handleDetailNext="handleDetailNext" <blue-tooth ref="blueTooth" @handleDetailNext="handleDetailNext"
@handleDetailSub="handleDetailSub" @connect_success="handleWeight" :weightType="weightType" @handleDetailSub="handleDetailSub" :weightKcal="weightKcal" :name="activeType.name"
:isLast="isLast" :weightKcal="weightKcal" /> :isLast="isLast" />
</view> </view>
</view> </view>
</view> </view>
@ -158,6 +155,7 @@
info: {}, info: {},
id: null, id: null,
index: 0, index: 0,
isLast: false,
weightKcal: null, weightKcal: null,
weightType: 0, weightType: 0,
activeType: {}, activeType: {},
@ -165,7 +163,6 @@
isWeightType: true, isWeightType: true,
iSWeightSub: true, iSWeightSub: true,
listInd: 0, listInd: 0,
isLast: false,
cookIndex: null, cookIndex: null,
showSaveFood: false, showSaveFood: false,
saveFoodTypes: [ saveFoodTypes: [
@ -178,7 +175,7 @@
} }
}, },
computed: { computed: {
...mapState(["user", "configInfo"]), ...mapState(["user", "configInfo", "bleValue"]),
menu() { menu() {
return this.configInfo.cookbook_label return this.configInfo.cookbook_label
}, },
@ -214,6 +211,9 @@
if (res.code != 0) return if (res.code != 0) return
that.info = res.data that.info = res.data
that.cookIndex = that.menu.findIndex(ite => ite.id == res.data.cook_label) that.cookIndex = that.menu.findIndex(ite => ite.id == res.data.cook_label)
if (that.bleValue.serviceId != '') {
that.handleWeight()
}
}) })
}, },
// //
@ -222,13 +222,16 @@
if (that.isBle) { if (that.isBle) {
return return
} }
that.listInd = 0
that.isBle = true that.isBle = true
that.isLast = false that.isLast = false
that.activeType = {}
that.iSWeightSub = true that.iSWeightSub = true
that.isWeightType = true that.isWeightType = false
that.handleWeightType(0) // that.activeType = that.info.tags[0].list[0]
that.weightKcal = Number(Number(that.activeType.kcal) / 100).toFixed(2)
if (that.info.tags[0].list.length == 1) {
that.isLast = true
}
}, },
// //
handleDetailNext(weight, dw, kcal) { handleDetailNext(weight, dw, kcal) {
@ -247,6 +250,7 @@
that.isLast = true that.isLast = true
console.log('已经测量完成') console.log('已经测量完成')
} }
console.log("下一位", that.activeType)
}, },
// //
handleDetailSub(weight, dw, kcal) { handleDetailSub(weight, dw, kcal) {
@ -265,29 +269,14 @@
that.listInd = ind that.listInd = ind
that.isLast = false that.isLast = false
that.activeType = ite that.activeType = ite
that.iSWeightSub = true that.weightKcal = Number(Number(ite.kcal) / 100).toFixed(2)
that.isWeightType = false
that.weightKcal = Number(Number(that.activeType.kcal) / 100).toFixed(2)
that.info.tags[0].list[ind].newweight = "" that.info.tags[0].list[ind].newweight = ""
that.info.tags[0].list[ind].newunit = "" that.info.tags[0].list[ind].newunit = ""
that.info.tags[0].list[ind].newkcal = "" that.info.tags[0].list[ind].newkcal = ""
if (that.listInd == that.info.tags[0].list.length - 1 || that.listInd == that.info.tags[0].list.length) { if (that.listInd == that.info.tags[0].list.length - 1 || that.listInd == that.info.tags[0].list.length) {
that.isLast = true that.isLast = true
} }
this.$refs.blueTooth.handlechongzhi(weight) console.log("重置", ite)
console.log("重置", ind, that.info.tags[0].list.length)
},
//
handleWeightType(ind) {
this.weightType = ind
this.isLast = false
this.isWeightType = false
this.activeType = this.info.tags[0].list[0]
this.weightKcal = Number(Number(this.activeType.kcal) / 100).toFixed(2)
this.listInd = 0
if (this.info.tags[0].list.length == 1) {
this.isLast = true
}
}, },
// //
confirmSaveFood() { confirmSaveFood() {
@ -299,7 +288,7 @@
meals_type: that.saveFoodTypes[that.selectSaveType], meals_type: that.saveFoodTypes[that.selectSaveType],
id: that.info.tags[0].list[i].id, 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' ? '克' : '盎司' unit: that.info.tags[0].list[i].newunit == '' ? '克' : '盎司'
}) })
} }
} }
@ -316,6 +305,9 @@
title: '保存成功', title: '保存成功',
icon: 'success' icon: 'success'
}) })
uni.switchTab({
url: "/pages/count/count"
})
}) })
} }
that.showSaveFood = false that.showSaveFood = false
@ -568,116 +560,71 @@
// //
.weightBox { .weightBox {
top: 64rpx; top: 40px;
height: auto; background: #dfdfdf;
border-radius: 0;
.table { .icon-error {
width: 100%;
display: flex;
justify-content: center;
font-size: 18px;
font-weight: bold;
border-bottom: 1px solid #fff;
icon {
font-size: 100rpx;
margin-top: -60rpx;
background: #fff;
border-radius: 50%;
width: 100rpx;
height: 100rpx;
position: absolute; position: absolute;
right: 16px; right: 20rpx;
} top: -40rpx;
background: #fff;
font-size: 80rpx;
width: 80rpx;
height: 80rpx;
border-radius: 50%;
} }
.foodlist { .foodlist {
border-radius: 0; border-radius: 0;
height: 40%; height: 40%;
overflow: scroll; overflow: scroll;
padding: 10px;
border-radius: 10px;
margin-top: 30rpx; margin-top: 30rpx;
font-size: 14px;
.text { .text {
width: 100%; width: 100%;
font-weight: bold; font-weight: bold;
font-size: 14px;
display: flex; display: flex;
height: 80rpx; height: 80rpx;
line-height: 80rpx; line-height: 80rpx;
justify-content: space-between;
text {
width: 18%;
text-align: center;
}
:nth-child(1) {
width: 28%;
text-align: left;
}
:nth-child(5) {
width: 15%;
// text-align: right !important;
}
} }
.item { .item {
display: flex; display: flex;
// justify-content: space-between;
align-items: center; align-items: center;
height: 80rpx; height: 80rpx;
line-height: 80rpx; line-height: 80rpx;
font-size: 16px; font-size: 28rpx;
justify-content: space-between;
view {
width: 18%;
text-align: center;
font-size: 24rpx;
}
:nth-child(5) {
width: 15%;
text-align: right !important;
display: flex;
justify-content: center;
}
}
.kcal {
width: 60% !important;
text-align: center !important;
} }
.name { .name {
width: auto; width: calc(30% - 10px);
float: left;
font-size: 24rpx;
font-weight: 500;
width: 28% !important;
text-align: left !important; text-align: left !important;
white-space: nowrap; white-space: nowrap;
overflow-x: auto; overflow-x: auto;
} font-weight: inherit;
font-size: 28rpx;
margin-right: 10px;
} }
.title { .kcal {
width: 100%; width: 52% !important;
padding: 0; display: flex;
margin-top: 20rpx; justify-content: space-between;
overflow: hidden;
position: absolute;
bottom: 20rpx;
top: 50%;
left: 0;
right: 0;
/deep/.weightPages {
top: 30rpx;
display: block;
} }
}
.blue-tooth {
background: #fff;
border-radius: 10px;
margin-top: 15px;
position: relative;
height: 50%;
} }
.groupbtn { .groupbtn {
@ -760,6 +707,12 @@
} }
} }
.active2 {
color: #8284f0;
font-weight: bold;
background: #ecedff;
}
.title2 { .title2 {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -15,7 +15,7 @@
<text class="overflow">{{it.create_user_nickname}}</text> <text class="overflow">{{it.create_user_nickname}}</text>
</view> </view>
<view class="zan" @click="handleZan(it)"> <view class="zan" @click="handleZan(it)">
<icon class="iconfont" :class="[it.is_me_like_it=='yes'?'icon-icon3':'icon-icon_collect']"> <icon class="t-icon" :class="[it.is_me_like_it=='yes'?'t-icon-icon3':'t-icon-icon_collect']">
</icon> </icon>
<text>{{it.likes_num}}</text> <text>{{it.likes_num}}</text>
</view> </view>

View File

@ -10,7 +10,7 @@
<view v-else class="content_box"> <view v-else class="content_box">
<!-- 称重 --> <!-- 称重 -->
<view class="blue-tooth"> <view class="blue-tooth">
<blue-tooth :weightType="'2'" :btnType="'1'"></blue-tooth> <blue-tooth :btnType="'1'"></blue-tooth>
</view> </view>
<!-- 每日摄入 --> <!-- 每日摄入 -->
<view class="box" v-if="user.aud_id!=''"> <view class="box" v-if="user.aud_id!=''">

View File

@ -44,7 +44,10 @@
<view class="jishiqi"> <view class="jishiqi">
<view class="top"> <view class="top">
<view class="date">{{foodInfo.date}}</view> <view class="date">{{foodInfo.date}}</view>
<view class="detail" @click="navTo('/pageTwo/count/everyDay?page=home')">查看详情</view> <view class="detail" @click="navTo('/pageTwo/count/everyDay?page=home')">
<image src="/static/fenxi.png"></image>
营养分析
</view>
</view> </view>
<view class="left"> <view class="left">
<view class="chart-wrap"> <view class="chart-wrap">
@ -167,7 +170,8 @@
this.handTrue = false this.handTrue = false
this.$nextTick(() => { this.$nextTick(() => {
this.handTrue = true this.handTrue = true
that.chartData.series[0].data = this.user.aud_id != "" ? Number(this.user.food_count.nutrients_four[0].proportion) / 100 : 0 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 return this.user.aud_id != "" ? this.user.food_count : this.configInfo.default_count_foot
} }
@ -197,7 +201,8 @@
that.handTrue = false that.handTrue = false
this.$nextTick(() => { this.$nextTick(() => {
that.handTrue = true that.handTrue = true
that.chartData.series[0].data = that.user.aud_id != ""?Number(that.user.food_count.nutrients_four[0].proportion) / 100:0 that.chartData.series[0].data = that.user.aud_id != "" ? Number(that.user.food_count
.nutrients_four[0].proportion) / 100 : 0
}) })
this.startWatching() this.startWatching()
}, },
@ -405,11 +410,28 @@
} }
.detail { .detail {
color: #fff; color: #3CB383;
width: auto; width: auto;
padding: 5px 20px; padding: 3px 10px;
background: $yellowcolor; background: #fff;
border-radius: 10px; border-radius: 8px;
border: 1px solid #3CB383;
display: flex;
align-items: center;
image {
width: 44rpx;
height: 44rpx;
margin-right: 5px;
}
}
.left {
margin-top: -10px;
}
.right {
margin-top: 0;
} }
} }

View File

@ -13,7 +13,7 @@
<text class="overflow">{{it.create_user_nickname}}</text> <text class="overflow">{{it.create_user_nickname}}</text>
</view> </view>
<view class="zan"> <view class="zan">
<icon class="iconfont" :class="[it.is_me_like_it=='yes'?'icon-icon3':'icon-icon_collect']"> <icon class="t-icon" :class="[it.is_me_like_it=='yes'?'t-icon-icon3':'t-icon-icon_collect']">
</icon> </icon>
<text>{{it.likes_num}}</text> <text>{{it.likes_num}}</text>
</view> </view>

View File

@ -38,29 +38,29 @@
</view> </view>
</view> </view>
</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="handleSearchHistory(autoSearchContent)">确定</view>
</view>
<uni-icons class="close" type="close" color="#ffffff" size="45"
@click="showAutoSearchDlg=false"></uni-icons>
</view>
</view> -->
<!-- 语音 --> <!-- 语音 -->
<view class="footBtn"> <view class="footBtn">
<view class="mic-icon" @touchstart="onVoiceTouchStart" @touchend="onVoiceTouchEnd"> <view class="mic-icon" @touchstart="onVoiceTouchStart" @touchend="onVoiceTouchEnd"
<uni-icons type="mic-filled" size="20" :color="mic_touch ? '#777777' : '#fff'"></uni-icons> @touchcancel="cancelRecording">
<uni-icons type="mic-filled" size="20" color="#fff"></uni-icons>
语音搜索 语音搜索
</view> </view>
</view> </view>
<!-- 语音弹框 -->
<view class="wrapper" v-if="showAutoSearchDlg">
<view class="auto-search-dialog">
<view class="auto-search-inner">
<view class="voice-wave">
<view class="wave-bar"></view>
<view class="wave-bar"></view>
<view class="wave-bar"></view>
<view class="wave-bar"></view>
<view class="wave-bar"></view>
<view class="wave-bar"></view>
</view>
</view>
</view>
</view>
</view> </view>
</template> </template>
@ -76,7 +76,7 @@
Page: 1, Page: 1,
showAll: false, showAll: false,
search_value: '', search_value: '',
mic_touch: false, showAutoSearchDlg: false,
voiceManager: null, voiceManager: null,
}; };
}, },
@ -110,7 +110,7 @@
}, },
onVoiceTouchStart() { onVoiceTouchStart() {
let that = this let that = this
that.mic_touch = true that.showAutoSearchDlg = true
that.voiceManager.start({ that.voiceManager.start({
duration: 60000, duration: 60000,
lang: "zh_CN" lang: "zh_CN"
@ -118,12 +118,22 @@
}, },
onVoiceTouchEnd() { onVoiceTouchEnd() {
let that = this let that = this
that.mic_touch = false that.showAutoSearchDlg = false
that.voiceManager.stop() that.voiceManager.stop()
}, },
//
cancelRecording() {
// #ifdef MP-WEIXIN
if (this.voiceManager) {
this.voiceManager.stop()
this.showAutoSearchDlg = false
}
// #endif
},
handlecolse() { handlecolse() {
console.log("取消搜索") console.log("取消搜索")
this.search_value = "" this.search_value = ""
this.search_list = []
}, },
// //
handleSearchHistory(text) { handleSearchHistory(text) {
@ -302,7 +312,7 @@
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
height: 100%; bottom: 60px;
background-color: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.5);
z-index: 999; z-index: 999;
@ -312,53 +322,11 @@
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
position: relative; position: relative;
width: 70%; width: 50%;
height: 350rpx; padding: 60rpx 0;
padding: 80rpx 0;
background-color: #fff; background-color: #fff;
border-radius: 20rpx; border-radius: 20rpx;
box-shadow: 0 0 20rpx #ccc; box-shadow: 0 0 20rpx #ccc;
.close {
position: absolute;
left: 0;
right: 0;
bottom: -140rpx;
width: 90rpx;
margin: 0 auto;
}
}
text {
font-size: 32rpx;
width: 80%;
}
.mic-icon {
display: flex;
justify-content: center;
align-items: center;
width: 150rpx;
height: 150rpx;
border-radius: 50%;
border: 8rpx solid #777777;
}
.btn-wrap {
display: flex;
justify-content: space-around;
width: 90%;
.retry,
.confirm {
width: 190rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
font-size: 28rpx;
border: 2rpx solid #777;
border-radius: 15rpx;
}
} }
} }

View File

@ -133,7 +133,6 @@ function getBLEDeviceCharacteristics(deviceId, serviceId) {
notify = item.uuid notify = item.uuid
} }
} }
getBLECharacteristicValueChange(deviceId, serviceId, notify, write) getBLECharacteristicValueChange(deviceId, serviceId, notify, write)
}, },
fail: res => { fail: res => {
@ -160,6 +159,9 @@ function getBLECharacteristicValueChange(deviceId, serviceId, notify,write) {
bleTipsText: "测量中,请将食物放到秤上", bleTipsText: "测量中,请将食物放到秤上",
isConnectStatus: 0 isConnectStatus: 0
}) })
const units = ['kg', '斤', 'st:lb', 'lb', 'g', 'ml', 'Waterml',
'milkml', 'oz', 'floz', 'lboz'
]
uni.onBLECharacteristicValueChange(function(res) { uni.onBLECharacteristicValueChange(function(res) {
const value = res.value const value = res.value
const dataView = new DataView(value) const dataView = new DataView(value)
@ -170,9 +172,6 @@ function getBLECharacteristicValueChange(deviceId, serviceId, notify,write) {
switch (cmd) { switch (cmd) {
case 0x02: case 0x02:
let units = ['kg', '斤', 'st:lb', 'lb', 'g', 'ml', 'Waterml',
'milkml', 'oz', 'floz', 'lboz'
]
const statusByte = dataView.getUint8(4) const statusByte = dataView.getUint8(4)
const isNegative = !!(statusByte & 0x80) // 最高位表示正负 const isNegative = !!(statusByte & 0x80) // 最高位表示正负
const statusType = statusByte & 0x0F // 状态类型 const statusType = statusByte & 0x0F // 状态类型
@ -300,6 +299,7 @@ export default {
getBLEDeviceCharacteristics, getBLEDeviceCharacteristics,
closeBluetoothAdapter, closeBluetoothAdapter,
closeBLEConnection, closeBLEConnection,
getBLECharacteristicValueChange,
onBLEConnectionStateChange, onBLEConnectionStateChange,
stopBluetoothDevicesDiscovery stopBluetoothDevicesDiscovery
} }

View File

@ -161,6 +161,11 @@ export default {
return res return res
}) })
}, },
getAddEveryMealFood(param) { // 当次食材添加的卡路里摄入记录
return http.post("/kitchenscale2/current_food_statistics", param).then(res => {
return res
})
},
getCountfootCon(param) { // 每日记食器板块详细内容 getCountfootCon(param) { // 每日记食器板块详细内容
return http.post("/kitchenscale2/get_countfoot_content", param).then(res => { return http.post("/kitchenscale2/get_countfoot_content", param).then(res => {
return res return res

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

@ -503,6 +503,9 @@ page {
.c999 { .c999 {
color: #999 !important; color: #999 !important;
} }
.red {
color: red !important;
}
.bold { .bold {
font-weight: bold; font-weight: bold;
} }
@ -1269,6 +1272,53 @@ page {
height: 16rpx; height: 16rpx;
border-radius: 5px; border-radius: 5px;
} }
.voice-wave {
display: flex;
align-items: center;
gap: 4px;
height: 40px;
}
.wave-bar {
width: 6px;
background: #3498db;
border-radius: 3px;
-webkit-animation: wave 1.2s ease-in-out infinite;
animation: wave 1.2s ease-in-out infinite;
}
.wave-bar:nth-child(2) {
-webkit-animation-delay: -1.1s;
animation-delay: -1.1s;
}
.wave-bar:nth-child(3) {
-webkit-animation-delay: -1.0s;
animation-delay: -1.0s;
}
.wave-bar:nth-child(4) {
-webkit-animation-delay: -0.9s;
animation-delay: -0.9s;
}
.wave-bar:nth-child(5) {
-webkit-animation-delay: -0.8s;
animation-delay: -0.8s;
}
@-webkit-keyframes wave {
0%,
100% {
height: 8px;
}
50% {
height: 30px;
}
}
@keyframes wave {
0%,
100% {
height: 8px;
}
50% {
height: 30px;
}
}
/*每个页面公共css */ /*每个页面公共css */
.content { .content {
display: flex; display: flex;

View File

@ -28446,6 +28446,12 @@ var _default = (_getonlogin$getSendCo = {
return res; return res;
}); });
}, },
getAddEveryMealFood: function getAddEveryMealFood(param) {
// 当次食材添加的卡路里摄入记录
return _https.default.post("/kitchenscale2/current_food_statistics", param).then(function (res) {
return res;
});
},
getCountfootCon: function getCountfootCon(param) { getCountfootCon: function getCountfootCon(param) {
// 每日记食器板块详细内容 // 每日记食器板块详细内容
return _https.default.post("/kitchenscale2/get_countfoot_content", param).then(function (res) { return _https.default.post("/kitchenscale2/get_countfoot_content", param).then(function (res) {
@ -29252,6 +29258,7 @@ function getBLECharacteristicValueChange(deviceId, serviceId, notify, write) {
bleTipsText: "测量中,请将食物放到秤上", bleTipsText: "测量中,请将食物放到秤上",
isConnectStatus: 0 isConnectStatus: 0
}); });
var units = ['kg', '斤', 'st:lb', 'lb', 'g', 'ml', 'Waterml', 'milkml', 'oz', 'floz', 'lboz'];
uni.onBLECharacteristicValueChange(function (res) { uni.onBLECharacteristicValueChange(function (res) {
var value = res.value; var value = res.value;
var dataView = new DataView(value); var dataView = new DataView(value);
@ -29261,7 +29268,6 @@ function getBLECharacteristicValueChange(deviceId, serviceId, notify, write) {
var cmd = dataView.getUint8(2); var cmd = dataView.getUint8(2);
switch (cmd) { switch (cmd) {
case 0x02: case 0x02:
var units = ['kg', '斤', 'st:lb', 'lb', 'g', 'ml', 'Waterml', 'milkml', 'oz', 'floz', 'lboz'];
var statusByte = dataView.getUint8(4); var statusByte = dataView.getUint8(4);
var isNegative = !!(statusByte & 0x80); // 最高位表示正负 var isNegative = !!(statusByte & 0x80); // 最高位表示正负
var statusType = statusByte & 0x0F; // 状态类型 var statusType = statusByte & 0x0F; // 状态类型
@ -29380,6 +29386,7 @@ var _default = {
getBLEDeviceCharacteristics: getBLEDeviceCharacteristics, getBLEDeviceCharacteristics: getBLEDeviceCharacteristics,
closeBluetoothAdapter: closeBluetoothAdapter, closeBluetoothAdapter: closeBluetoothAdapter,
closeBLEConnection: closeBLEConnection, closeBLEConnection: closeBLEConnection,
getBLECharacteristicValueChange: getBLECharacteristicValueChange,
onBLEConnectionStateChange: onBLEConnectionStateChange, onBLEConnectionStateChange: onBLEConnectionStateChange,
stopBluetoothDevicesDiscovery: stopBluetoothDevicesDiscovery stopBluetoothDevicesDiscovery: stopBluetoothDevicesDiscovery
}; };

View File

@ -79,8 +79,11 @@ __webpack_require__.r(__webpack_exports__);
var components var components
try { try {
components = { components = {
uniIcons: function () { uniPopup: function () {
return Promise.all(/*! import() | uni_modules/uni-icons/components/uni-icons/uni-icons */[__webpack_require__.e("common/vendor"), __webpack_require__.e("uni_modules/uni-icons/components/uni-icons/uni-icons")]).then(__webpack_require__.bind(null, /*! @/uni_modules/uni-icons/components/uni-icons/uni-icons.vue */ 293)) return __webpack_require__.e(/*! import() | uni_modules/uni-popup/components/uni-popup/uni-popup */ "uni_modules/uni-popup/components/uni-popup/uni-popup").then(__webpack_require__.bind(null, /*! @/uni_modules/uni-popup/components/uni-popup/uni-popup.vue */ 354))
},
uniPopupDialog: function () {
return Promise.all(/*! import() | uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog */[__webpack_require__.e("common/vendor"), __webpack_require__.e("uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog")]).then(__webpack_require__.bind(null, /*! @/uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue */ 361))
}, },
} }
} catch (e) { } catch (e) {
@ -144,27 +147,31 @@ Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.default = void 0; exports.default = void 0;
var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ 270));
var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ 273));
var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ 11)); var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ 11));
var _vuex = __webpack_require__(/*! vuex */ 30); 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 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; } 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 searchTimer = null;
var _default = { var _default = {
data: function data() { data: function data() {
return { return {
dw: "g",
kcal: "", kcal: "",
weight: "", // weight: "",
weightALL: "", weightALL: "",
msgText: "蓝牙连接中", bleTipsText: "",
unit: '', unit: 'g',
weight0: 0, weight0: 0,
devicesList: [],
stopblue: false, stopblue: false,
isConnection: 0, 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'] units: ['kg', '斤', 'st:lb', 'lb', 'g', 'ml', 'Waterml', 'milkml', 'oz', 'floz', 'lboz']
}; };
}, },
@ -174,52 +181,34 @@ var _default = {
default: 0 //当前测量食物每g含的kcal default: 0 //当前测量食物每g含的kcal
}, },
weightType: {
type: Number,
default: -1 //0分类测量,1累计测量,2购物车测量
},
isLast: { isLast: {
type: Boolean, type: Boolean,
default: false default: false
},
name: {
type: String,
default: ''
} }
}, },
computed: _objectSpread({}, (0, _vuex.mapState)(["user", "isBluetoothTyle", "bleValue"])), computed: _objectSpread(_objectSpread({}, (0, _vuex.mapState)(["user", "isBluetoothTyle", "bleValue"])), {}, {
weight: function weight() {
var 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);
return this.bleValue.countWeight;
},
isConnection: function isConnection() {
this.bleTipsText = this.bleValue.bleTipsText;
return this.bleValue.isConnectStatus;
}
}),
mounted: function mounted() { mounted: function mounted() {
var that = this; var that = this;
if (that.bleValue.serviceId != "") {
that.closeBLEConnection();
that.closeBluetoothAdapter();
that.openBluetoothAdapter();
} else {
that.openBluetoothAdapter();
}
that.onBLEConnectionStateChange();
uni.onBluetoothAdapterStateChange(function (res) { uni.onBluetoothAdapterStateChange(function (res) {
that.$store.commit("changeBluetooth", res.available); 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();
},
watch: { watch: {
// weightType: function() {
// let that = this
// that.openBluetoothAdapter()
// },
isBluetoothTyle: function isBluetoothTyle() { isBluetoothTyle: function isBluetoothTyle() {
var that = this; var that = this;
if (!that.isBluetoothTyle) { if (!that.isBluetoothTyle) {
@ -229,318 +218,78 @@ var _default = {
isLast: function isLast() { isLast: function isLast() {
var that = this; var that = this;
that.stopblue = that.isLast; that.stopblue = that.isLast;
console.log("最后", this.isLast);
} }
}, },
methods: { methods: {
// 初始化蓝牙 // 初始化蓝牙
openBluetoothAdapter: function openBluetoothAdapter() { openBluetoothAdapter: function openBluetoothAdapter() {
var that = this; var that = this;
that.weight = ""; if (that.isConnection == 0) return;
that.kcal = ""; that.kcal = "";
that.msgText = '蓝牙连接中'; that.$store.commit('changeBluetoothValue', {
uni.openBluetoothAdapter({ deviceId: "",
success: function success(e) { serviceId: "",
that.isConnection = 0; notify: '',
that.startBluetoothDeviceDiscovery(); write: '',
searchTimer = setTimeout(function () { unit: "g",
uni.stopBluetoothDevicesDiscovery(); countWeight: "",
if (!that.devicesList.length) { bleTipsText: "蓝牙搜索中",
clearTimeout(searchTimer); isConnectStatus: 0
that.isConnection = 1; });
} that.$ble.openBluetoothAdapter();
}, 30000); // 30秒超时
}, },
changleUnits: function changleUnits(e) {
fail: function fail(e) { var that = this;
that.isConnection = 1; var name = that.unitList[e.detail.value].name;
console.log('openBluetoothAdapter', e); console.log("单位切换", name, that.unit);
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!"); if (that.unit != name) {
that.handletoggleUnit(name == '盎司' ? 0x08 : 0x04);
} }
that.unitListIndex = [e.detail.value];
that.$store.commit('changeBluetoothValue', {
unit: that.unitList[e.detail.value].unit
}); });
}, },
// 开始搜寻附近的蓝牙外围设备 handletoggleUnit: function handletoggleUnit(unit) {
startBluetoothDeviceDiscovery: function startBluetoothDeviceDiscovery() {
var that = this; var that = this;
uni.startBluetoothDevicesDiscovery({ var checksum = 0;
allowDuplicatesKey: true, var bytes = [0xC5, 0x03, 0x05, 0x11];
services: [ bytes[4] = unit;
// "F0A0", for (var i = 0; i < bytes.length; i++) {
// "A5FE" checksum ^= bytes[i];
], }
bytes[5] = checksum;
that.sendData(new Uint8Array(bytes).buffer);
},
handleqingling: function handleqingling() {
var that = this;
var str = "C503071100D0";
var buf = new Uint8Array(str.match(/[\da-f]{2}/gi).map(function (h) {
return parseInt(h, 16);
}));
that.sendData(buf.buffer);
},
sendData: function sendData(buffer) {
var that = this;
uni.writeBLECharacteristicValue({
deviceId: that.bleValue.deviceId,
serviceId: that.bleValue.serviceId,
characteristicId: that.bleValue.write,
value: buffer,
success: function success(res) { success: function success(res) {
that.isConnection = 0; console.log('下发指令成功', res.errMsg);
that.onBluetoothDeviceFound();
}, },
fail: function fail(res) { fail: function fail(res) {
that.isConnection = 1; console.log("下发指令失败", res);
console.log('startBluetoothDeviceDiscovery', res);
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!");
} }
}); });
}, },
// 监听蓝牙连接状态
onBLEConnectionStateChange: function onBLEConnectionStateChange() {
var that = this;
uni.onBLEConnectionStateChange(function (res) {
console.log("监听蓝牙连接状态", res.connected);
if (!res.connected) {
that.isConnection = 1;
that.closeBLEConnection();
that.closeBluetoothAdapter();
}
that.$store.commit("changeConnected", res.connected);
});
},
/**
* 停止搜索蓝牙设备
*/
stopBluetoothDevicesDiscovery: function stopBluetoothDevicesDiscovery() {
uni.stopBluetoothDevicesDiscovery({
success: function success(e) {
console.log("停止搜索蓝牙设备", e);
}
});
},
/**
* 发现外围设备
*/
onBluetoothDeviceFound: function onBluetoothDeviceFound() {
var that = this;
that.isConnection = 0;
uni.onBluetoothDeviceFound(function (res) {
res.devices.forEach(function (device) {
device.advertisData = device.advertisData ? device.advertisData : '';
device.advertisServiceUUIDs = device.advertisServiceUUIDs ? device.advertisServiceUUIDs : "";
var value = that.$tools.ab2hex(device.advertisData, "");
var id = value.substring(0, 4);
if (!device.name && !device.localName) {
return;
}
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);
var analyzeDataText = analyzeData.text;
var data = analyzeData.data;
if (parseDataRes.status == 1) {
var data0 = parseDataRes.payload;
var _data = parseInt(data0[3]).toString(16);
console.log('data' + _data);
var data1 = parseInt(data0[4]).toString(16);
var data2 = parseInt(_data + data1, 16); //重量
//
var unit0 = parseInt(data0[5]).toString(16); //单位小数点
var unit = unit0.length > 1 ? unit0.substring(1, 2) : unit0; //单位
var num = parseInt(unit0.substring(0, 1), 16).toString(8);
var dot = num.toString().substring(0, 1); //小数点
var zfz = 0; //正负值
if (num.toString().length > 1) {
dot = num.toString().substring(1, 2);
zfz = num.toString().substring(0, 1);
}
if (unit == '0') {
that.dw = 'g';
}
if (unit == "7") {
that.dw = "ml";
}
if (unit == "3") {
that.dw = "oz";
}
if (unit == "2") {
that.dw = "lb'oz";
}
if (dot == "1") {
data2 = data2 / 10;
}
if (dot == "2") {
data2 = data2 / 100;
}
if (zfz == "0") {
data2 = data2;
}
if (zfz == "1") {
data2 = "-" + data2;
}
that.weight = data2;
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 && device.localName.indexOf('Chipsea-BLE') != -1 || id == 'a5fe') {
clearTimeout(searchTimer);
that.stopBluetoothDevicesDiscovery();
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;
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
var that;
return _regenerator.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
that = _this;
uni.createBLEConnection({
deviceId: device_id,
success: function success(res) {
setTimeout(function () {
that.getBLEDeviceServices(device_id);
}, 200);
},
fail: function fail(res) {
console.log("设备连接失败,请重新连接", res);
}
});
case 2:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
},
/**
* 获取设备的UUID
*/
getBLEDeviceServices: function getBLEDeviceServices(device_id) {
var serviceList = [];
var that = this;
uni.getBLEDeviceServices({
deviceId: device_id,
success: function success(res) {
console.log("获取设备的UUID成功", res);
serviceList = res.services;
for (var i = 0; i < serviceList.length; i++) {
var service = serviceList[i];
if (service.uuid.indexOf("FFF0") != -1) {
that.getBLEDeviceCharacteristics(device_id, service.uuid);
break;
}
}
},
fail: function fail(res) {
console.log('获取设备的UUID失败:', res);
}
});
},
/**
* 获取指定服务的特征值
*/
getBLEDeviceCharacteristics: function getBLEDeviceCharacteristics(deviceId, serviceId) {
var characteristicsList = [];
var that = this;
uni.getBLEDeviceCharacteristics({
deviceId: deviceId,
serviceId: serviceId,
success: function success(res) {
console.log("服务的特征值成功", res);
var write, notify;
for (var i = 0; i < res.characteristics.length; i++) {
var item = res.characteristics[i];
if (item.uuid.indexOf('0000FFF2') != -1) {
write = item.uuid;
} else if (item.uuid.indexOf('0000FFF1') != -1) {
notify = item.uuid;
}
}
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));
}
});
},
parseWeightData: function parseWeightData(dataView) {
var statusByte = dataView.getUint8(4);
var isNegative = !!(statusByte & 0x80); // 最高位表示正负
var statusType = statusByte & 0x0F; // 状态类型
// 组合24位重量值 (大端序)
var weightValue = dataView.getUint8(5) << 16 | dataView.getUint8(6) << 8 | dataView.getUint8(7);
// 精度和单位
var unitByte = dataView.getUint8(8);
var precision = (unitByte & 0xF0) >> 4; // 高4位精度
var unitIndex = unitByte & 0x0F; // 低4位单位
// 计算实际重量
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)
var kcal = (Number(this.weightKcal) * finalWeight).toFixed(2);
this.kcal = this.convertToGrams(kcal, this.dw).toFixed(2);
// console.log('重量:' + finalWeight)
// console.log('单位:' + this.unit)
// 状态处理
// if (statusType === 0x02) {
// this.$emit('handleBle', finalWeight,this.unit,0)
// }
},
// 保存测量结果 // 保存测量结果
handlesub: function handlesub() { handlesub: function handlesub() {
var that = this; var that = this;
console.log("weight", that.weight); console.log("测量保存", that.weight, that.unit, that.kcal);
if (Number(that.weight) > 0) { if (Number(that.weight) > 0) {
that.$emit("handleBle", that.weight, that.dw, that.kcal); that.$emit("handleBle", that.weight, that.unit, that.kcal);
that.stopBluetoothDevicesDiscovery(); //取消蓝牙搜索
that.closeBLEConnection();
that.closeBluetoothAdapter();
} else { } else {
that.$tools.msg("数据异常,请清零后重新测量!"); that.$tools.msg("数据异常,请清零后重新测量!");
} }
@ -563,25 +312,8 @@ var _default = {
// 备料完成 // 备料完成
handleDetailSub: function handleDetailSub() { handleDetailSub: function handleDetailSub() {
var that = this; var that = this;
if (that.weightType == 1) { if (Number(that.weight) > 0) {
//累计测量 that.$emit("handleDetailSub", that.weight, that.unit, that.kcal);
// that.weight0 = Number(that.weight) - Number(that.weightALL)
that.weight0 = Number((Number(that.weight) - Number(that.weightALL)).toFixed(2));
if (that.weight0 > 0) {
that.weightALL = that.weight;
} else {
that.$tools.msg("数据异常,请清零后重新测量!");
}
} else {
that.weight0 = that.weight;
}
if (Number(that.weight0) > 0) {
that.$emit("handleDetailSub", that.weight0, that.dw, that.kcal);
// that.stopBluetoothDevicesDiscovery() //取消蓝牙搜索
// that.closeBLEConnection()
// that.closeBluetoothAdapter()
that.weight = 0;
that.weight0 = 0;
} else { } else {
that.$tools.msg("数据异常,请重新测量!"); that.$tools.msg("数据异常,请重新测量!");
} }
@ -589,87 +321,48 @@ var _default = {
//备料下一个 //备料下一个
handleDetailNext: function handleDetailNext() { handleDetailNext: function handleDetailNext() {
var that = this; var that = this;
if (that.weightType == 1) { if (Number(that.weight) > 0) {
console.log('weight' + that.weight); that.$emit("handleDetailNext", that.weight, that.unit, that.kcal);
console.log('weight0' + that.weight0);
console.log('weightALL' + that.weightALL);
// that.weight0 = Number(that.weight) - Number(that.weightALL)
that.weight0 = Number((Number(that.weight) - Number(that.weightALL)).toFixed(2));
if (that.weight0 > 0) {
that.weightALL = that.weight;
} else {
that.$tools.msg("数据异常,请清零后重新测量!");
}
} else {
that.weight0 = that.weight;
}
if (Number(that.weight0) > 0) {
that.$emit("handleDetailNext", that.weight0, that.dw, that.kcal);
that.weight = 0;
that.weight0 = 0;
} else { } else {
that.$tools.msg("数据异常,请清零后重新测量!"); that.$tools.msg("数据异常,请清零后重新测量!");
} }
}, },
handlechongzhi: function handlechongzhi(weight) { unitConversion: function unitConversion(unit) {
var that = this; if (unit == 'kcal') {
console.log('当前总重:' + that.weightALL); return '千卡';
console.log('重置重量:' + weight); } else if (unit == 'g') {
if (that.weightType == 1) { return '克';
that.weightALL = Number((Number(that.weightALL) - Number(weight)).toFixed(2)); } else if (unit == 'lb') {
console.log('剩余重量:' + that.weightALL); return '磅';
} else if (unit == 'oz') {
return '盎司';
} }
return unit;
}, },
handleBack: function handleBack() { handleBack: function handleBack() {
var that = this; var that = this;
that.isConnection = 1; that.$store.commit("changeBluetoothValue", {
that.stopBluetoothDevicesDiscovery(); //取消蓝牙搜索 bleTipsText: "连接失败,点击重新连接",
that.closeBLEConnection(); isConnectStatus: 1
that.closeBluetoothAdapter();
},
/**
* 断开蓝牙模块
*/
closeBluetoothAdapter: function closeBluetoothAdapter() {
var that = this;
uni.closeBluetoothAdapter({
success: function success(res) {
console.log('蓝牙模块关闭成功');
}
}); });
that.$ble.stopBluetoothDevicesDiscovery(); //取消蓝牙搜索
that.$ble.closeBLEConnection(that.bleValue.deviceId);
that.$ble.closeBluetoothAdapter();
}, },
/** confirm: function confirm(value) {
* 断开蓝牙连接 console.log("手动输入", value);
*/ this.$store.commit("changeBluetoothValue", {
closeBLEConnection: function closeBLEConnection() { countWeight: value,
var that = this; unit: this.unitList[this.unitListIndex].unit
uni.closeBLEConnection({
deviceId: that.deviceId,
success: function success(res) {
console.log('断开蓝牙连接成功');
}
}); });
} // isNutritionScale(advertisData) { this.$refs.popup.close();
// const buffer = this.base64ToArrayBuffer(advertisData) },
// const dataView = new DataView(buffer) close: function close() {
// // 检查厂商自定义数据头 this.$refs.popup.close();
// if (dataView.getUint16(0) !== 0xA5FE) return false },
// // 检查产品类型 (营养秤:0x0001) inputDialogToggle: function inputDialogToggle() {
// const typeId = dataView.getUint16(2) this.$refs.popup.open();
// if (typeId !== 0x0001) return false }
// // 检查厂商ID (通用方案:0x0001)
// const vendorId = dataView.getUint16(4)
// return vendorId === 0x0001
// },
// base64ToArrayBuffer(base64) {
// const str = atob(base64)
// const buffer = new ArrayBuffer(str.length)
// const view = new Uint8Array(buffer)
// for (let i = 0; i < str.length; i++) {
// view[i] = str.charCodeAt(i)
// }
// return buffer
// }
} }
}; };
exports.default = _default; exports.default = _default;

View File

@ -1,6 +1,7 @@
{ {
"usingComponents": { "usingComponents": {
"uni-icons": "/uni_modules/uni-icons/components/uni-icons/uni-icons" "uni-popup": "/uni_modules/uni-popup/components/uni-popup/uni-popup",
"uni-popup-dialog": "/uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog"
}, },
"component": true "component": true
} }

View File

@ -1 +1 @@
<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 class="weightPages data-v-53fa6103"><view class="table data-v-53fa6103"><view class="text data-v-53fa6103"><image src="/static/zhong.png" class="data-v-53fa6103"></image><text data-event-opts="{{[['tap',[['openBluetoothAdapter',['$event']]]]]}}" bindtap="__e" class="data-v-53fa6103">{{bleTipsText}}</text></view></view><view class="name data-v-53fa6103">{{name}}</view><view class="weight-wrap data-v-53fa6103"><view data-event-opts="{{[['tap',[['inputDialogToggle',['$event']]]]]}}" class="weight data-v-53fa6103" bindtap="__e"><text class="val data-v-53fa6103">{{weight==''?'0.0':weight}}</text><text class="unit data-v-53fa6103">{{unit}}</text></view><view class="weight data-v-53fa6103"><text class="val data-v-53fa6103">{{kcal?kcal:0}}</text><text class="unit data-v-53fa6103">kcal</text></view></view><view class="groupbtn data-v-53fa6103"><view class="btn danwei data-v-53fa6103"><view class="lan border-bottom data-v-53fa6103"><view class="right data-v-53fa6103"><picker mode="selector" range="{{unitList}}" range-key="name" value="{{unitListIndex}}" data-event-opts="{{[['change',[['changleUnits',['$event']]]]]}}" bindchange="__e" class="data-v-53fa6103"><view class="uni-input data-v-53fa6103">单位</view></picker></view></view></view><view data-event-opts="{{[['tap',[['handleDetailSub',['$event']]]]]}}" class="btn data-v-53fa6103" style="{{'width:'+(!stopblue?'20%':'45%')+';'}}" bindtap="__e">保存</view><block wx:if="{{!stopblue}}"><view data-event-opts="{{[['tap',[['handleDetailNext',['$event']]]]]}}" class="btn data-v-53fa6103" bindtap="__e">下一味</view></block><view data-event-opts="{{[['tap',[['handleqingling',['$event']]]]]}}" class="btn qingling data-v-53fa6103" bindtap="__e">清零</view></view><view class="data-v-53fa6103"><uni-popup vue-id="2b524063-1" type="dialog" data-ref="popup" class="data-v-53fa6103 vue-ref" bind:__l="__l" vue-slots="{{['default']}}"><uni-popup-dialog vue-id="{{('2b524063-2')+','+('2b524063-1')}}" mode="input" title="重量" placeholder="请输入食物重量" data-event-opts="{{[['^close',[['close']]],['^confirm',[['confirm']]]]}}" bind:close="__e" bind:confirm="__e" class="data-v-53fa6103" bind:__l="__l"></uni-popup-dialog></uni-popup></view></view>

View File

@ -24,17 +24,33 @@
/* 垂直间距 */ /* 垂直间距 */
/* 透明度 */ /* 透明度 */
/* 文章场景相关 */ /* 文章场景相关 */
.weightPages.data-v-53fa6103 { .table.data-v-53fa6103 {
width: 100%;
font-size: 14px;
align-items: center;
padding: 5px 0;
border-radius: 5px;
display: flex; display: flex;
flex-wrap: wrap; justify-content: space-between;
flex-direction: column; }
.table .text.data-v-53fa6103 {
color: #8284f0;
display: flex;
}
.table .text image.data-v-53fa6103 {
width: 22px;
height: 22px;
margin-right: 5px;
}
.weightPages.data-v-53fa6103 {
position: absolute; position: absolute;
justify-content: space-around; left: 15px;
left: 0; right: 15px;
right: 0; bottom: 30rpx;
bottom: 40rpx; top: 15px;
top: 120rpx; display: flex;
margin-top: 40rpx; flex-direction: column;
justify-content: space-between;
} }
.weightPages .weight.data-v-53fa6103 { .weightPages .weight.data-v-53fa6103 {
background: #fff; background: #fff;
@ -64,34 +80,65 @@
font-size: 24rpx; font-size: 24rpx;
text-align: center; text-align: center;
} }
.weightPages .btn.data-v-53fa6103 { .weightPages .groupbtn.data-v-53fa6103 {
color: #fff; margin-top: 0;
width: 80%; display: flex;
margin-left: 10%; align-items: center;
justify-content: space-between;
} }
.weightPages .groupbtn .btn.data-v-53fa6103 { .weightPages .groupbtn .btn.data-v-53fa6103 {
color: #000 !important; width: 20%;
color: #3CB383;
text-align: center;
height: 40px;
line-height: 40px;
border-radius: 10px;
border: 1px solid #3CB383;
background: #fff;
margin: 0;
} }
.weightPages .table.data-v-53fa6103 { .weightPages .groupbtn .btn view.data-v-53fa6103 {
border: none !important;
width: auto !important;
height: 40px !important;
line-height: 40px !important;
}
.weightPages .weight-wrap.data-v-53fa6103 {
display: flex;
justify-content: space-around;
align-items: center;
color: #666;
font-size: 16px;
text-align: center;
height: 60px;
border-radius: 10px;
}
.weightPages .weight-wrap .weight.data-v-53fa6103 {
display: flex;
justify-content: center;
align-items: center;
width: 48%;
padding: 30rpx 0;
border-radius: 20rpx;
background-color: #F8F8F8;
}
.weightPages .weight-wrap .weight .val.data-v-53fa6103 {
font-size: 54rpx;
color: #F0AE43;
margin: 0 !important;
}
.weightPages .weight-wrap .weight .unit.data-v-53fa6103 {
padding: 10rpx;
margin-left: 20rpx;
font-size: 28rpx;
color: #fff;
border-radius: 8rpx;
background-color: #F0AE43;
}
.weightPages .name.data-v-53fa6103 {
width: 100%; width: 100%;
text-align: center;
font-size: 16px; font-size: 16px;
font-weight: bold; font-weight: bold;
text-align: center;
margin: 30rpx 0;
}
.weightPages .image.data-v-53fa6103 {
width: 112rpx;
height: 112rpx;
margin: auto;
}
.weightPages .image image.data-v-53fa6103 {
width: 100%;
height: 100%;
}
.weightPages .tips.data-v-53fa6103 {
margin-bottom: 30rpx;
margin-left: 30rpx;
display: flex;
color: #999;
} }

View File

@ -107,6 +107,15 @@ var render = function () {
var _vm = this var _vm = this
var _h = _vm.$createElement var _h = _vm.$createElement
var _c = _vm._self._c || _h var _c = _vm._self._c || _h
var m0 = _vm.unitConversion(_vm.unit)
_vm.$mp.data = Object.assign(
{},
{
$root: {
m0: m0,
},
}
)
} }
var recyclableRender = false var recyclableRender = false
var staticRenderFns = [] var staticRenderFns = []
@ -158,6 +167,7 @@ var _default = {
return { return {
kcal: 0, kcal: 0,
unit: '', unit: '',
// weight: "",
bleTipsText: "", bleTipsText: "",
inputDialog: false, inputDialog: false,
unitList: [{ unitList: [{
@ -179,11 +189,6 @@ var _default = {
default: 0 //当前测量食物每100g含的kcal default: 0 //当前测量食物每100g含的kcal
}, },
weightType: {
type: Number,
default: -1 //0分类测量,1累计测量,2购物车测量
},
btnType: { btnType: {
type: Number, type: Number,
default: 1 //1添加食材2保存测量 default: 1 //1添加食材2保存测量
@ -193,7 +198,7 @@ var _default = {
computed: _objectSpread(_objectSpread({}, (0, _vuex.mapState)(["bleValue", "isBluetoothTyle", "countFoodInfo"])), {}, { computed: _objectSpread(_objectSpread({}, (0, _vuex.mapState)(["bleValue", "isBluetoothTyle", "countFoodInfo"])), {}, {
weight: function weight() { weight: function weight() {
this.kcal = (Number(this.weightKcal) / 100 * this.bleValue.countWeight).toFixed(2); this.kcal = (Number(this.weightKcal) / 100 * this.bleValue.countWeight).toFixed(2);
this.unit = this.unitConversion(this.bleValue.unit); this.unit = this.bleValue.unit;
return this.bleValue.countWeight; return this.bleValue.countWeight;
}, },
isConnection: function isConnection() { isConnection: function isConnection() {
@ -338,27 +343,7 @@ var _default = {
}, },
close: function close() { close: function close() {
this.$refs.popup.close(); this.$refs.popup.close();
} // isNutritionScale(advertisData) { }
// const buffer = this.base64ToArrayBuffer(advertisData)
// const dataView = new DataView(buffer)
// // 检查厂商自定义数据头
// if (dataView.getUint16(0) !== 0xA5FE) return false
// // 检查产品类型 (营养秤:0x0001)
// const typeId = dataView.getUint16(2)
// if (typeId !== 0x0001) return false
// // 检查厂商ID (通用方案:0x0001)
// const vendorId = dataView.getUint16(4)
// return vendorId === 0x0001
// },
// base64ToArrayBuffer(base64) {
// const str = atob(base64)
// const buffer = new ArrayBuffer(str.length)
// const view = new Uint8Array(buffer)
// for (let i = 0; i < str.length; i++) {
// view[i] = str.charCodeAt(i)
// }
// return buffer
// }
} }
}; };
exports.default = _default; exports.default = _default;

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==''?'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 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">{{$root.m0}}</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="{{btnType==2}}"><view data-event-opts="{{[['tap',[['handlesub',['$event']]]]]}}" class="btn addbtn size14 data-v-5fc22dca" bindtap="__e">保存</view></block><block wx:if="{{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

@ -65,7 +65,7 @@ image.data-v-5fc22dca {
background-color: #F8F8F8; background-color: #F8F8F8;
} }
.weightPages .weight-wrap .weight .val.data-v-5fc22dca { .weightPages .weight-wrap .weight .val.data-v-5fc22dca {
font-size: 40rpx; font-size: 54rpx;
color: #F0AE43; color: #F0AE43;
margin: 0 !important; margin: 0 !important;
} }
@ -77,17 +77,6 @@ image.data-v-5fc22dca {
border-radius: 8rpx; border-radius: 8rpx;
background-color: #F0AE43; background-color: #F0AE43;
} }
.weightPages .weight-wrap .kcal.data-v-5fc22dca {
font-size: 32rpx;
}
.weightPages .weight-wrap .kcal .val.data-v-5fc22dca {
font-size: 40rpx;
color: #F0AE43;
margin: 0 !important;
}
.weightPages .weight-wrap .kcal .unit.data-v-5fc22dca {
margin-left: 20rpx;
}
.weightPages .tips.data-v-5fc22dca { .weightPages .tips.data-v-5fc22dca {
font-size: 24rpx; font-size: 24rpx;
text-align: center; text-align: center;

View File

@ -129,41 +129,42 @@ var render = function () {
var g1 = !g0 ? _vm.history_food.length : null var g1 = !g0 ? _vm.history_food.length : null
var g2 = !g0 && g1 ? _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, 10) : null
var g4 = _vm.search_list.length var g4 =
var g5 = _vm.isShop ? _vm.ActiveList.length : null _vm.ActiveList.filter(function (ite) {
var g6 = return ite.meals_type == _vm.foodName
_vm.isShop && g5 }).length || 0
var g5 = _vm.search_list.length
var l0 = _vm.isShop ? _vm.foodInfo.slice(1) : null
var g6 = _vm.isShop ? _vm.ActiveList.length : null
var g7 =
_vm.isShop && g6
? _vm.ActiveList.filter(function (ite) { ? _vm.ActiveList.filter(function (ite) {
return ite.meals_type == _vm.foodName return ite.meals_type == _vm.foodName
}).length }).length
: null : null
var l0 = _vm.IsWeight var l1 = _vm.IsWeight
? _vm.__map(_vm.activeType.nutrients_four, function (item, index) { ? _vm.__map(_vm.activeType.nutrients_four, function (item, index) {
var $orig = _vm.__get_orig(item) var $orig = _vm.__get_orig(item)
var m0 = _vm.unitConversion(item.unit) var m0 = _vm.unitConversion(item.unit)
var g7 = Number((_vm.activeType.weight / 100) * item.value).toFixed(1) var g8 = Number((_vm.activeType.weight / 100) * item.value).toFixed(1)
return { return {
$orig: $orig, $orig: $orig,
m0: m0, m0: m0,
g7: g7, g8: g8,
} }
}) })
: null : null
var g8 = _vm.IsWeight ? Math.floor(_vm.activeType.weight) : null var g9 = _vm.IsWeight ? Math.floor(_vm.activeType.weight) : null
var l1 = _vm.IsWeight var l2 = _vm.IsWeight
? _vm.__map(_vm.activeType.nutrients_list, function (item, index) { ? _vm.__map(_vm.activeType.nutrients_list, function (item, index) {
var $orig = _vm.__get_orig(item) var $orig = _vm.__get_orig(item)
var g9 = Number((item.value * _vm.activeType.weight) / 100).toFixed(2) var g10 = Number((item.value * _vm.activeType.weight) / 100).toFixed(2)
return { return {
$orig: $orig, $orig: $orig,
g9: g9, g10: g10,
} }
}) })
: null : null
var g10 =
_vm.ActiveList.filter(function (ite) {
return ite.meals_type == _vm.foodName
}).length || 0
if (!_vm._isMounted) { if (!_vm._isMounted) {
_vm.e0 = function ($event) { _vm.e0 = function ($event) {
_vm.showAll = !_vm.showAll _vm.showAll = !_vm.showAll
@ -179,13 +180,13 @@ var render = function () {
_vm.isShop = false _vm.isShop = false
} }
_vm.e3 = function ($event) { _vm.e3 = function ($event) {
_vm.IsWeight = false _vm.isShop = false
} }
_vm.e4 = function ($event) { _vm.e4 = function ($event) {
_vm.IsWeight = false _vm.IsWeight = false
} }
_vm.e5 = function ($event) { _vm.e5 = function ($event) {
_vm.isShop = !_vm.isShop _vm.IsWeight = false
} }
} }
_vm.$mp.data = Object.assign( _vm.$mp.data = Object.assign(
@ -198,11 +199,12 @@ var render = function () {
g3: g3, g3: g3,
g4: g4, g4: g4,
g5: g5, g5: g5,
g6: g6,
l0: l0, l0: l0,
g8: g8, g6: g6,
g7: g7,
l1: l1, l1: l1,
g10: g10, g9: g9,
l2: l2,
}, },
} }
) )
@ -248,7 +250,6 @@ Object.defineProperty(exports, "__esModule", {
exports.default = void 0; exports.default = void 0;
var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ 11)); var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ 11));
var _vuex = __webpack_require__(/*! vuex */ 30); var _vuex = __webpack_require__(/*! vuex */ 30);
var _methods;
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 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; } 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 plugin = requirePlugin("WechatSI"); var plugin = requirePlugin("WechatSI");
@ -270,13 +271,13 @@ var qiunDataCharts = function qiunDataCharts() {
var _default = { var _default = {
data: function data() { data: function data() {
return { return {
opts: { chartData: {
background: "transparent", series: [{
title: { data: 0,
name: "" color: "#3CB383"
} }]
}, },
chartData: {}, foodInfo: [],
time: "", time: "",
page: 1, page: 1,
foodName: "", foodName: "",
@ -290,9 +291,7 @@ var _default = {
search_value: '', search_value: '',
ActiveList: [], ActiveList: [],
activeType: {}, activeType: {},
mic_touch: false,
voiceManager: null, voiceManager: null,
autoSearchContent: "",
showAutoSearchDlg: false showAutoSearchDlg: false
}; };
}, },
@ -300,11 +299,11 @@ var _default = {
popular_food: function popular_food() { popular_food: function popular_food() {
return this.configInfo.search_guess.food_data; return this.configInfo.search_guess.food_data;
}, },
history_food: function history_food() {
return this.configInfo.search_history.food;
},
foodItem: function foodItem() { foodItem: function foodItem() {
return this.configInfo.meal_list; return this.configInfo.meal_list;
},
history_food: function history_food() {
return this.configInfo.search_history.food;
} }
}), }),
components: { components: {
@ -349,25 +348,36 @@ var _default = {
this.page++; this.page++;
this.handleSerach(); this.handleSerach();
}, },
methods: (_methods = { methods: {
// 开始录音
onVoiceTouchStart: function onVoiceTouchStart() { onVoiceTouchStart: function onVoiceTouchStart() {
var that = this; var that = this;
that.mic_touch = true; that.showAutoSearchDlg = true;
that.isShop = false;
that.voiceManager.start({ that.voiceManager.start({
duration: 60000, duration: 60000,
lang: "zh_CN" lang: "zh_CN"
}); });
}, },
// 停止录音
onVoiceTouchEnd: function onVoiceTouchEnd() { onVoiceTouchEnd: function onVoiceTouchEnd() {
var that = this; var that = this;
that.mic_touch = false; that.showAutoSearchDlg = false;
that.voiceManager.stop(); that.voiceManager.stop();
}, },
// 取消录音
cancelRecording: function cancelRecording() {
if (this.voiceManager) {
this.voiceManager.stop();
this.showAutoSearchDlg = false;
}
},
// 购物车早午晚餐切换 // 购物车早午晚餐切换
handleToggle: function handleToggle(name) { handleToggle: function handleToggle(name) {
this.search_value = ""; this.search_value = "";
this.search_list = []; this.search_list = [];
this.foodName = name; this.foodName = name;
this.handleAddEveryMealFood();
}, },
//实时重量 //实时重量
realTimeWeight: function realTimeWeight(weight, unit) { realTimeWeight: function realTimeWeight(weight, unit) {
@ -405,9 +415,9 @@ var _default = {
that.isBle = true; that.isBle = true;
that.isShop = false; that.isShop = false;
that.IsWeight = true; that.IsWeight = true;
that.showAutoSearchDlg = false;
that.activeType = ite; that.activeType = ite;
that.weightKcal = ite.kcal; that.weightKcal = ite.kcal;
console.log("111111", ite, that.bleValue);
if (that.bleValue.serviceId != "") { if (that.bleValue.serviceId != "") {
that.realTimeWeight(that.bleValue.countWeight, that.bleValue.unit); that.realTimeWeight(that.bleValue.countWeight, that.bleValue.unit);
} else { } else {
@ -416,22 +426,6 @@ var _default = {
unit: "g" unit: "g"
}); });
that.realTimeWeight(100, "g"); that.realTimeWeight(100, "g");
// that.activeType.weight = 100
// let chart_data = []
// that.opts.color = []
// for (let i = 1; i < ite.nutrients_four.length; ++i) {
// that.opts.color.push(ite.nutrients_four[i].color)
// chart_data.push({
// name: ite.nutrients_four[i].name,
// value: Number(ite.nutrients_four[i].proportion),
// })
// }
// that.opts.title.name = ite.kcal
// that.chartData = JSON.parse(JSON.stringify({
// series: [{
// data: chart_data
// }]
// }));
} }
}, },
//测量返回 //测量返回
@ -443,7 +437,6 @@ var _default = {
that.activeType.weight = weight; that.activeType.weight = weight;
that.activeType.meals_type = that.foodName; that.activeType.meals_type = that.foodName;
list.push(that.activeType); list.push(that.activeType);
console.log("list", list);
that.$model.getAddIntakeFood({ that.$model.getAddIntakeFood({
aud_id: that.user.aud_id, aud_id: that.user.aud_id,
food_list: list, food_list: list,
@ -459,12 +452,6 @@ var _default = {
}); });
} }
that.activeType.food_id = res.data.id; that.activeType.food_id = res.data.id;
if (that.activeType.weight <= 0) {
that.$tools.msg("请输入重量");
return;
}
that.isBle = false;
that.IsWeight = false;
if (that.ActiveList.indexOf(that.activeType) == -1) { if (that.ActiveList.indexOf(that.activeType) == -1) {
that.ActiveList.push(that.activeType); that.ActiveList.push(that.activeType);
} else { } else {
@ -472,16 +459,48 @@ var _default = {
that.ActiveList[index].weight = that.activeType.weight; that.ActiveList[index].weight = that.activeType.weight;
that.ActiveList[index].unit = that.activeType.unit; that.ActiveList[index].unit = that.activeType.unit;
} }
setTimeout(function () {
that.handleAddEveryMealFood();
}, 100);
}); });
}, },
handleAddEveryMealFood: function handleAddEveryMealFood() {
var that = this;
var list = [];
console.log("that.ActiveList", that.ActiveList);
that.ActiveList.forEach(function (ite) {
if (ite.meals_type == that.foodName) {
list.push(ite.food_id);
}
});
console.log("MealFood", list);
that.$model.getAddEveryMealFood({
log_id: list
}).then(function (res) {
if (res.code != 0) return;
that.isBle = false;
that.IsWeight = false;
that.isShop = true;
that.foodInfo = res.data.nutrients_four;
that.chartData.series[0].data = Number(res.data.nutrients_four[0].proportion) / 100;
});
},
handleisShop: function handleisShop() {
var that = this;
if (!that.ActiveList.length) {
that.foodInfo = that.configInfo.default_count_foot.nutrients_four;
that.chartData.series[0].data = Number(that.configInfo.default_count_foot.nutrients_four[0].proportion) / 100;
}
that.isShop = true;
},
// 搜索 // 搜索
handleSerach: function handleSerach() { handleSerach: function handleSerach() {
var that = this; var that = this;
that.search_list = [];
if (that.search_value == "") { if (that.search_value == "") {
that.$tools.msg("输入关键字后搜索"); that.$tools.msg("输入关键字后搜索");
return; return;
} }
that.search_list = [];
that.$model.getFoodSearch({ that.$model.getFoodSearch({
page: that.page, page: that.page,
search_data: that.search_value search_data: that.search_value
@ -505,25 +524,16 @@ var _default = {
handleSearchHistory: function handleSearchHistory(text) { handleSearchHistory: function handleSearchHistory(text) {
var that = this; var that = this;
that.search_value = text; that.search_value = text;
that.showAutoSearchDlg = false;
that.handleSerach(); that.handleSerach();
} },
}, (0, _defineProperty2.default)(_methods, "onVoiceTouchStart", function onVoiceTouchStart() { // 早午晚餐筛选
var that = this; changeClickType: function changeClickType(e) {
that.mic_touch = true;
that.voiceManager.start({
duration: 60000,
lang: "zh_CN"
});
}), (0, _defineProperty2.default)(_methods, "onVoiceTouchEnd", function onVoiceTouchEnd() {
var that = this;
that.mic_touch = false;
that.voiceManager.stop();
}), (0, _defineProperty2.default)(_methods, "changeClickType", function changeClickType(e) {
this.search_value = ""; this.search_value = "";
this.search_list = []; this.search_list = [];
this.foodName = this.foodItem[e.target.value].name; this.foodName = this.foodItem[e.target.value].name;
}), (0, _defineProperty2.default)(_methods, "handledelactive", function handledelactive(ite) { },
//删除购物车食材
handledelactive: function handledelactive(ite) {
var _this = this; var _this = this;
var that = this; var that = this;
uni.showModal({ uni.showModal({
@ -543,11 +553,13 @@ var _default = {
time: that.time time: that.time
}); });
} }
that.handleAddEveryMealFood();
}); });
} }
} }
}); });
}), _methods) }
}
}; };
exports.default = _default; exports.default = _default;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"])) /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"]))

File diff suppressed because one or more lines are too long

View File

@ -226,7 +226,7 @@
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
height: 100%; bottom: 75px;
background-color: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.5);
z-index: 999; z-index: 999;
} }
@ -236,49 +236,12 @@
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
position: relative; position: relative;
width: 70%; width: 50%;
height: 350rpx; padding: 60rpx 0;
padding: 80rpx 0;
background-color: #fff; background-color: #fff;
border-radius: 20rpx; border-radius: 20rpx;
box-shadow: 0 0 20rpx #ccc; box-shadow: 0 0 20rpx #ccc;
} }
.auto-search-dialog .auto-search-inner .close.data-v-d4f38c70 {
position: absolute;
left: 0;
right: 0;
bottom: -140rpx;
width: 90rpx;
margin: 0 auto;
}
.auto-search-dialog text.data-v-d4f38c70 {
font-size: 32rpx;
width: 80%;
}
.auto-search-dialog .mic-icon.data-v-d4f38c70 {
display: flex;
justify-content: center;
align-items: center;
width: 150rpx;
height: 150rpx;
border-radius: 50%;
border: 8rpx solid #777777;
}
.auto-search-dialog .btn-wrap.data-v-d4f38c70 {
display: flex;
justify-content: space-around;
width: 90%;
}
.auto-search-dialog .btn-wrap .retry.data-v-d4f38c70,
.auto-search-dialog .btn-wrap .confirm.data-v-d4f38c70 {
width: 190rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
font-size: 28rpx;
border: 2rpx solid #777;
border-radius: 15rpx;
}
.footBtn.data-v-d4f38c70 { .footBtn.data-v-d4f38c70 {
position: fixed; position: fixed;
width: 100%; width: 100%;
@ -553,56 +516,93 @@
.wrapper .icon-error.data-v-d4f38c70 { .wrapper .icon-error.data-v-d4f38c70 {
position: absolute; position: absolute;
right: 20rpx; right: 20rpx;
top: -34rpx; top: -40rpx;
background: #fff; background: #fff;
font-size: 60rpx; font-size: 80rpx;
width: 60rpx; width: 80rpx;
height: 60rpx; height: 80rpx;
border-radius: 50%; border-radius: 50%;
} }
.wrapper .box2.data-v-d4f38c70 { .wrapper .box2.data-v-d4f38c70 {
left: 0; left: 0;
right: 0; right: 0;
height: 55%; top: 80rpx;
bottom: 0; bottom: 0;
background-color: #fff;
overflow: scroll;
position: absolute; position: absolute;
padding: 20rpx; padding: 20rpx;
padding-bottom: 90px;
background-color: #dfdfdf;
} }
.wrapper .box2 .left.data-v-d4f38c70 { .wrapper .box2 .jishiqi.data-v-d4f38c70 {
width: 80px; width: calc(100% - 20px);
background: #dfdfdf; overflow: hidden;
background: #fff;
padding: 10px;
border-radius: 10px;
height: 340rpx;
}
.wrapper .box2 .jishiqi .chart-wrap.data-v-d4f38c70 {
margin-top: -15px;
}
.wrapper .box2 .jishiqi .center.data-v-d4f38c70 {
height: 270rpx;
top: 80rpx;
}
.wrapper .box2 .jishiqi .mubiao.data-v-d4f38c70 {
margin-top: 10px;
}
.wrapper .box2 .box_list.data-v-d4f38c70 {
position: absolute; position: absolute;
left: 0; left: 10px;
top: 0; right: 10px;
bottom: 75px; bottom: 90px;
background: #fff;
border-radius: 10px;
margin-top: 15px;
overflow: hidden;
top: 420rpx;
}
.wrapper .box2 .box_list .left.data-v-d4f38c70 {
width: 80px;
background: #fff;
position: absolute;
left: 0px;
top: 0px;
bottom: 0px;
display: flex; display: flex;
border-radius: 10px;
flex-direction: column; flex-direction: column;
} }
.wrapper .box2 .left view.data-v-d4f38c70 { .wrapper .box2 .box_list .left view.data-v-d4f38c70 {
height: 25%; height: 25%;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.wrapper .box2 .left .active.data-v-d4f38c70 { .wrapper .box2 .box_list .left .active.data-v-d4f38c70 {
background-color: #fff; border-radius: 10px;
background-color: #EDFFF4;
color: #3CB383;
} }
.wrapper .box2 .list.data-v-d4f38c70 { .wrapper .box2 .box_list .box_list_item.data-v-d4f38c70 {
margin-bottom: 90px; position: absolute;
width: calc(100% - 80px); top: 10px;
margin-left: 80px; left: 90px;
right: 0;
bottom: 0;
overflow: scroll;
padding-bottom: 15px;
} }
.wrapper .box2 .list .length.data-v-d4f38c70 { .wrapper .box2 .box_list .box_list_item .length.data-v-d4f38c70 {
width: 100%; width: 100%;
height: 30px; height: 35px;
line-height: 30px; line-height: 35px;
margin-top: -5px; margin-top: -5px;
font-weight: bold;
} }
.wrapper .box2 .list .item.data-v-d4f38c70 { .wrapper .box2 .box_list .box_list_item .item.data-v-d4f38c70 {
width: 100%; width: 100%;
height: 45px; height: 50px;
display: flex; display: flex;
padding: 5px 0; padding: 5px 0;
position: relative; position: relative;
@ -610,18 +610,18 @@
justify-content: space-between; justify-content: space-between;
border-bottom: 1px solid #f7f7f7; border-bottom: 1px solid #f7f7f7;
} }
.wrapper .box2 .list .item .item-left.data-v-d4f38c70 { .wrapper .box2 .box_list .box_list_item .item .item-left.data-v-d4f38c70 {
width: calc(100% - 40px); width: calc(100% - 40px);
display: flex; display: flex;
align-items: center; align-items: center;
} }
.wrapper .box2 .list .item .item-left image.data-v-d4f38c70 { .wrapper .box2 .box_list .box_list_item .item .item-left image.data-v-d4f38c70 {
width: 90rpx; width: 90rpx;
height: 90rpx; height: 90rpx;
border-radius: 50%; border-radius: 50%;
border: 1px solid #f7f7f7; border: 1px solid #f7f7f7;
} }
.wrapper .box2 .list .item .item-left .name.data-v-d4f38c70 { .wrapper .box2 .box_list .box_list_item .item .item-left .name.data-v-d4f38c70 {
width: calc(100% - 100rpx); width: calc(100% - 100rpx);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -632,14 +632,14 @@
white-space: nowrap; white-space: nowrap;
justify-content: space-between; justify-content: space-between;
} }
.wrapper .box2 .list .item .item-left .name text.data-v-d4f38c70 { .wrapper .box2 .box_list .box_list_item .item .item-left .name text.data-v-d4f38c70 {
width: 100%; width: 100%;
} }
.wrapper .box2 .list .item .item-left .weight.data-v-d4f38c70 { .wrapper .box2 .box_list .box_list_item .item .item-left .weight.data-v-d4f38c70 {
font-size: 24rpx; font-size: 24rpx;
color: #999; color: #999;
} }
.wrapper .box2 .list .icon-ashbin.data-v-d4f38c70 { .wrapper .box2 .box_list .box_list_item .icon-ashbin.data-v-d4f38c70 {
position: absolute; position: absolute;
right: 10px; right: 10px;
top: 15px; top: 15px;

View File

@ -277,6 +277,8 @@ var _default = {
handleDetail: function handleDetail(ite, ind) { handleDetail: function handleDetail(ite, ind) {
var that = this; var that = this;
var list = []; var list = [];
var pages = getCurrentPages();
var prevPage = pages[pages.length - 2];
if (ind == 1) { if (ind == 1) {
list.push(ite); list.push(ite);
that.ActiveList = that.$tools.mergeAndDeduplicate(that.ActiveList, list, 'name'); that.ActiveList = that.$tools.mergeAndDeduplicate(that.ActiveList, list, 'name');
@ -287,15 +289,16 @@ var _default = {
} }
} }
} }
prevPage.$vm.getAddFood(that.ActiveList);
}, },
// 搜索 // 搜索
handleSerach: function handleSerach() { handleSerach: function handleSerach() {
var that = this; var that = this;
that.search_list = [];
if (that.search_value == "") { if (that.search_value == "") {
that.$tools.msg("输入关键字后搜索"); that.$tools.msg("输入关键字后搜索");
return; return;
} }
that.search_list = [];
that.$model.getFoodSearch({ that.$model.getFoodSearch({
page: that.page, page: that.page,
search_data: that.search_value search_data: that.search_value
@ -326,7 +329,7 @@ var _default = {
// 开始说话 // 开始说话
onVoiceTouchStart: function onVoiceTouchStart() { onVoiceTouchStart: function onVoiceTouchStart() {
var that = this; var that = this;
that.mic_touch = true; that.showAutoSearchDlg = true;
that.voiceManager.start({ that.voiceManager.start({
duration: 60000, duration: 60000,
lang: "zh_CN" lang: "zh_CN"
@ -335,9 +338,16 @@ var _default = {
// 语音结束 // 语音结束
onVoiceTouchEnd: function onVoiceTouchEnd() { onVoiceTouchEnd: function onVoiceTouchEnd() {
var that = this; var that = this;
that.mic_touch = false; that.showAutoSearchDlg = false;
that.voiceManager.stop(); that.voiceManager.stop();
}, },
// 取消录音
cancelRecording: function cancelRecording() {
if (this.voiceManager) {
this.voiceManager.stop();
this.showAutoSearchDlg = false;
}
},
// 购物车提交 // 购物车提交
handlesubbtn: function handlesubbtn() { handlesubbtn: function handlesubbtn() {
var that = this; var that = this;
@ -351,6 +361,9 @@ var _default = {
//删除购物车食材 //删除购物车食材
handledelactive: function handledelactive(ite) { handledelactive: function handledelactive(ite) {
var that = this; var that = this;
var pages = getCurrentPages();
var prevPage = pages[pages.length - 2];
prevPage.$vm.handledel(ite.id, "食材");
that.ActiveList.splice(that.ActiveList.indexOf(ite), 1); that.ActiveList.splice(that.ActiveList.indexOf(ite), 1);
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -220,7 +220,7 @@
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
height: 100%; bottom: 75px;
background-color: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.5);
z-index: 999; z-index: 999;
} }
@ -230,49 +230,12 @@
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
position: relative; position: relative;
width: 70%; width: 50%;
height: 350rpx; padding: 60rpx 0;
padding: 80rpx 0;
background-color: #fff; background-color: #fff;
border-radius: 20rpx; border-radius: 20rpx;
box-shadow: 0 0 20rpx #ccc; box-shadow: 0 0 20rpx #ccc;
} }
.auto-search-dialog .auto-search-inner .close.data-v-c58b4fba {
position: absolute;
left: 0;
right: 0;
bottom: -140rpx;
width: 90rpx;
margin: 0 auto;
}
.auto-search-dialog text.data-v-c58b4fba {
font-size: 32rpx;
width: 80%;
}
.auto-search-dialog .mic-icon.data-v-c58b4fba {
display: flex;
justify-content: center;
align-items: center;
width: 150rpx;
height: 150rpx;
border-radius: 50%;
border: 8rpx solid #777777;
}
.auto-search-dialog .btn-wrap.data-v-c58b4fba {
display: flex;
justify-content: space-around;
width: 90%;
}
.auto-search-dialog .btn-wrap .retry.data-v-c58b4fba,
.auto-search-dialog .btn-wrap .confirm.data-v-c58b4fba {
width: 190rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
font-size: 28rpx;
border: 2rpx solid #777;
border-radius: 15rpx;
}
.activeList.data-v-c58b4fba { .activeList.data-v-c58b4fba {
z-index: 12; z-index: 12;
bottom: 200rpx; bottom: 200rpx;
@ -299,14 +262,14 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
padding: 0 20rpx 40rpx; padding: 0 20rpx;
position: fixed; position: fixed;
bottom: 0; bottom: 0rpx;
left: 0; left: 0;
right: 0; right: 0;
height: 90px; height: 60px;
z-index: 99; padding-bottom: 15px;
flex-wrap: wrap; z-index: 15;
background-color: #fff; background-color: #fff;
overflow: hidden; overflow: hidden;
box-shadow: 0px 1px 5px 2px #dfe2e1fc; box-shadow: 0px 1px 5px 2px #dfe2e1fc;
@ -321,7 +284,7 @@
background-color: #f0ae43; background-color: #f0ae43;
} }
.groupbtn .jilu.data-v-c58b4fba { .groupbtn .jilu.data-v-c58b4fba {
width: 100%; width: 110px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
@ -359,7 +322,7 @@
} }
.mic-icon.data-v-c58b4fba { .mic-icon.data-v-c58b4fba {
color: #fff; color: #fff;
width: 100%; width: calc(100% - 120px);
padding: 8px 0; padding: 8px 0;
background: #3CB383; background: #3CB383;
display: flex; display: flex;

View File

@ -104,7 +104,16 @@ var render = function () {
var _c = _vm._self._c || _h var _c = _vm._self._c || _h
var g0 = _vm.info.tags && _vm.info.tags[_vm.index].list.length var g0 = _vm.info.tags && _vm.info.tags[_vm.index].list.length
var g1 = _vm.info.step_list && _vm.info.step_list.length var g1 = _vm.info.step_list && _vm.info.step_list.length
var l0 = _vm.isBle
? _vm.__map(_vm.info.tags[0].list, function (ite, ind) {
var $orig = _vm.__get_orig(ite)
var g2 = _vm.info.tags && _vm.info.tags[0].list.length var g2 = _vm.info.tags && _vm.info.tags[0].list.length
return {
$orig: $orig,
g2: g2,
}
})
: null
if (!_vm._isMounted) { if (!_vm._isMounted) {
_vm.e0 = function ($event) { _vm.e0 = function ($event) {
_vm.isBle = false _vm.isBle = false
@ -129,7 +138,7 @@ var render = function () {
$root: { $root: {
g0: g0, g0: g0,
g1: g1, g1: g1,
g2: g2, l0: l0,
}, },
} }
) )
@ -178,7 +187,7 @@ 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 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; } 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 blueTooth = function blueTooth() { var blueTooth = function blueTooth() {
Promise.all(/*! require.ensure | components/bluetooth */[__webpack_require__.e("common/vendor"), __webpack_require__.e("components/bluetooth")]).then((function () { __webpack_require__.e(/*! require.ensure | components/bluetooth */ "components/bluetooth").then((function () {
return resolve(__webpack_require__(/*! ../../components/bluetooth.vue */ 339)); return resolve(__webpack_require__(/*! ../../components/bluetooth.vue */ 339));
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe); }).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
}; };
@ -189,6 +198,7 @@ var _default = {
info: {}, info: {},
id: null, id: null,
index: 0, index: 0,
isLast: false,
weightKcal: null, weightKcal: null,
weightType: 0, weightType: 0,
activeType: {}, activeType: {},
@ -196,14 +206,13 @@ var _default = {
isWeightType: true, isWeightType: true,
iSWeightSub: true, iSWeightSub: true,
listInd: 0, listInd: 0,
isLast: false,
cookIndex: null, cookIndex: null,
showSaveFood: false, showSaveFood: false,
saveFoodTypes: ['早餐', '午餐', '晚餐', '加餐'], saveFoodTypes: ['早餐', '午餐', '晚餐', '加餐'],
selectSaveType: 0 selectSaveType: 0
}; };
}, },
computed: _objectSpread(_objectSpread({}, (0, _vuex.mapState)(["user", "configInfo"])), {}, { computed: _objectSpread(_objectSpread({}, (0, _vuex.mapState)(["user", "configInfo", "bleValue"])), {}, {
menu: function menu() { menu: function menu() {
return this.configInfo.cookbook_label; return this.configInfo.cookbook_label;
}, },
@ -241,6 +250,9 @@ var _default = {
that.cookIndex = that.menu.findIndex(function (ite) { that.cookIndex = that.menu.findIndex(function (ite) {
return ite.id == res.data.cook_label; return ite.id == res.data.cook_label;
}); });
if (that.bleValue.serviceId != '') {
that.handleWeight();
}
}); });
}, },
//连接测量 //连接测量
@ -249,12 +261,16 @@ var _default = {
if (that.isBle) { if (that.isBle) {
return; return;
} }
that.listInd = 0;
that.isBle = true; that.isBle = true;
that.isLast = false; that.isLast = false;
that.activeType = {};
that.iSWeightSub = true; that.iSWeightSub = true;
that.isWeightType = true; that.isWeightType = false;
that.handleWeightType(0); //默认分类测量,取消累计测量 that.activeType = that.info.tags[0].list[0];
that.weightKcal = Number(Number(that.activeType.kcal) / 100).toFixed(2);
if (that.info.tags[0].list.length == 1) {
that.isLast = true;
}
}, },
// 下一位 // 下一位
handleDetailNext: function handleDetailNext(weight, dw, kcal) { handleDetailNext: function handleDetailNext(weight, dw, kcal) {
@ -275,6 +291,7 @@ var _default = {
that.isLast = true; that.isLast = true;
console.log('已经测量完成'); console.log('已经测量完成');
} }
console.log("下一位", that.activeType);
}, },
// 结束测量 // 结束测量
handleDetailSub: function handleDetailSub(weight, dw, kcal) { handleDetailSub: function handleDetailSub(weight, dw, kcal) {
@ -295,29 +312,14 @@ var _default = {
that.listInd = ind; that.listInd = ind;
that.isLast = false; that.isLast = false;
that.activeType = ite; that.activeType = ite;
that.iSWeightSub = true; that.weightKcal = Number(Number(ite.kcal) / 100).toFixed(2);
that.isWeightType = false;
that.weightKcal = Number(Number(that.activeType.kcal) / 100).toFixed(2);
that.info.tags[0].list[ind].newweight = ""; that.info.tags[0].list[ind].newweight = "";
that.info.tags[0].list[ind].newunit = ""; that.info.tags[0].list[ind].newunit = "";
that.info.tags[0].list[ind].newkcal = ""; that.info.tags[0].list[ind].newkcal = "";
if (that.listInd == that.info.tags[0].list.length - 1 || that.listInd == that.info.tags[0].list.length) { if (that.listInd == that.info.tags[0].list.length - 1 || that.listInd == that.info.tags[0].list.length) {
that.isLast = true; that.isLast = true;
} }
this.$refs.blueTooth.handlechongzhi(weight); console.log("重置", ite);
console.log("重置", ind, that.info.tags[0].list.length);
},
//测量类型选择
handleWeightType: function handleWeightType(ind) {
this.weightType = ind;
this.isLast = false;
this.isWeightType = false;
this.activeType = this.info.tags[0].list[0];
this.weightKcal = Number(Number(this.activeType.kcal) / 100).toFixed(2);
this.listInd = 0;
if (this.info.tags[0].list.length == 1) {
this.isLast = true;
}
}, },
//保存测量结果到计时器 //保存测量结果到计时器
confirmSaveFood: function confirmSaveFood() { confirmSaveFood: function confirmSaveFood() {
@ -329,7 +331,7 @@ var _default = {
meals_type: that.saveFoodTypes[that.selectSaveType], meals_type: that.saveFoodTypes[that.selectSaveType],
id: that.info.tags[0].list[i].id, 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' ? '克' : '盎司' unit: that.info.tags[0].list[i].newunit == '' ? '克' : '盎司'
}); });
} }
} }
@ -346,6 +348,9 @@ var _default = {
title: '保存成功', title: '保存成功',
icon: 'success' icon: 'success'
}); });
uni.switchTab({
url: "/pages/count/count"
});
}); });
} }
that.showSaveFood = false; that.showSaveFood = false;

File diff suppressed because one or more lines are too long

View File

@ -188,99 +188,64 @@
width: 100%; width: 100%;
} }
.weightBox.data-v-4a383a52 { .weightBox.data-v-4a383a52 {
top: 64rpx; top: 40px;
height: auto; background: #dfdfdf;
border-radius: 0;
} }
.weightBox .table.data-v-4a383a52 { .weightBox .icon-error.data-v-4a383a52 {
width: 100%;
display: flex;
justify-content: center;
font-size: 18px;
font-weight: bold;
border-bottom: 1px solid #fff;
}
.weightBox .table icon.data-v-4a383a52 {
font-size: 100rpx;
margin-top: -60rpx;
background: #fff;
border-radius: 50%;
width: 100rpx;
height: 100rpx;
position: absolute; position: absolute;
right: 16px; right: 20rpx;
top: -40rpx;
background: #fff;
font-size: 80rpx;
width: 80rpx;
height: 80rpx;
border-radius: 50%;
} }
.weightBox .foodlist.data-v-4a383a52 { .weightBox .foodlist.data-v-4a383a52 {
border-radius: 0; border-radius: 0;
height: 40%; height: 40%;
overflow: scroll; overflow: scroll;
padding: 10px;
border-radius: 10px;
margin-top: 30rpx; margin-top: 30rpx;
font-size: 14px;
} }
.weightBox .foodlist .text.data-v-4a383a52 { .weightBox .foodlist .text.data-v-4a383a52 {
width: 100%; width: 100%;
font-weight: bold; font-weight: bold;
font-size: 14px;
display: flex; display: flex;
height: 80rpx; height: 80rpx;
line-height: 80rpx; line-height: 80rpx;
} justify-content: space-between;
.weightBox .foodlist .text text.data-v-4a383a52 {
width: 18%;
text-align: center;
}
.weightBox .foodlist .text.data-v-4a383a52 :nth-child(1) {
width: 28%;
text-align: left;
}
.weightBox .foodlist .text.data-v-4a383a52 :nth-child(5) {
width: 15%;
} }
.weightBox .foodlist .item.data-v-4a383a52 { .weightBox .foodlist .item.data-v-4a383a52 {
display: flex; display: flex;
align-items: center; align-items: center;
height: 80rpx; height: 80rpx;
line-height: 80rpx; line-height: 80rpx;
font-size: 16px; font-size: 28rpx;
} justify-content: space-between;
.weightBox .foodlist .item view.data-v-4a383a52 {
width: 18%;
text-align: center;
font-size: 24rpx;
}
.weightBox .foodlist .item.data-v-4a383a52 :nth-child(5) {
width: 15%;
text-align: right !important;
display: flex;
justify-content: center;
}
.weightBox .foodlist .kcal.data-v-4a383a52 {
width: 60% !important;
text-align: center !important;
} }
.weightBox .foodlist .name.data-v-4a383a52 { .weightBox .foodlist .name.data-v-4a383a52 {
width: auto; width: calc(30% - 10px);
float: left;
font-size: 24rpx;
font-weight: 500;
width: 28% !important;
text-align: left !important; text-align: left !important;
white-space: nowrap; white-space: nowrap;
overflow-x: auto; overflow-x: auto;
font-weight: inherit;
font-size: 28rpx;
margin-right: 10px;
} }
.weightBox .title.data-v-4a383a52 { .weightBox .foodlist .kcal.data-v-4a383a52 {
width: 100%; width: 52% !important;
padding: 0; display: flex;
margin-top: 20rpx; justify-content: space-between;
overflow: hidden;
position: absolute;
bottom: 20rpx;
top: 50%;
left: 0;
right: 0;
} }
.weightBox .title.data-v-4a383a52 .weightPages { .weightBox .blue-tooth.data-v-4a383a52 {
top: 30rpx; background: #fff;
display: block; border-radius: 10px;
margin-top: 15px;
position: relative;
height: 50%;
} }
.weightBox .groupbtn.data-v-4a383a52 { .weightBox .groupbtn.data-v-4a383a52 {
position: absolute; position: absolute;
@ -351,6 +316,11 @@
.saveFood .saveFoodInner .btn-wrap view.data-v-4a383a52:first-child { .saveFood .saveFoodInner .btn-wrap view.data-v-4a383a52:first-child {
border-right: 1px solid #f1f1f1; border-right: 1px solid #f1f1f1;
} }
.active2.data-v-4a383a52 {
color: #8284f0;
font-weight: bold;
background: #ecedff;
}
.title2.data-v-4a383a52 { .title2.data-v-4a383a52 {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -1 +1 @@
<view class="content data-v-3e1b5f72"><search bind:handleSearch="__e" vue-id="f55de058-1" data-event-opts="{{[['^handleSearch',[['handleSearch']]]]}}" class="data-v-3e1b5f72" bind:__l="__l"></search><block wx:if="{{$root.g0}}"><view class="footlist footbox data-v-3e1b5f72"><block wx:for="{{menuList}}" wx:for-item="it" wx:for-index="id" wx:key="*this"><view data-event-opts="{{[['tap',[['handleDetail',['$0'],[[['menuList','',id,'id']]]]]]]}}" class="list data-v-3e1b5f72" bindtap="__e"><view class="topimg data-v-3e1b5f72"><image class="img data-v-3e1b5f72" src="{{it.cover_url}}" mode="aspectFill"></image></view><view class="item data-v-3e1b5f72"><view class="title data-v-3e1b5f72">{{it.title}}</view><view class="name data-v-3e1b5f72"><image src="{{it.create_user_head_pic}}" class="data-v-3e1b5f72"></image><text class="overflow data-v-3e1b5f72">{{it.create_user_nickname}}</text></view><view data-event-opts="{{[['tap',[['handleZan',['$0'],[[['menuList','',id]]]]]]]}}" class="zan data-v-3e1b5f72" bindtap="__e"><icon class="{{['iconfont','data-v-3e1b5f72',it.is_me_like_it=='yes'?'icon-icon3':'icon-icon_collect']}}"></icon><text class="data-v-3e1b5f72">{{it.likes_num}}</text></view></view></view></block></view></block><block wx:if="{{$root.g1}}"><view class="endtext data-v-3e1b5f72">—— 到底了,看看别的吧 ——</view></block><block wx:if="{{!$root.g2}}"><view class="nolist data-v-3e1b5f72"><icon class="iconfont icon-wancan data-v-3e1b5f72"></icon><text class="data-v-3e1b5f72">还没有记录哦</text></view></block></view> <view class="content data-v-3e1b5f72"><search bind:handleSearch="__e" vue-id="f55de058-1" data-event-opts="{{[['^handleSearch',[['handleSearch']]]]}}" class="data-v-3e1b5f72" bind:__l="__l"></search><block wx:if="{{$root.g0}}"><view class="footlist footbox data-v-3e1b5f72"><block wx:for="{{menuList}}" wx:for-item="it" wx:for-index="id" wx:key="*this"><view data-event-opts="{{[['tap',[['handleDetail',['$0'],[[['menuList','',id,'id']]]]]]]}}" class="list data-v-3e1b5f72" bindtap="__e"><view class="topimg data-v-3e1b5f72"><image class="img data-v-3e1b5f72" src="{{it.cover_url}}" mode="aspectFill"></image></view><view class="item data-v-3e1b5f72"><view class="title data-v-3e1b5f72">{{it.title}}</view><view class="name data-v-3e1b5f72"><image src="{{it.create_user_head_pic}}" class="data-v-3e1b5f72"></image><text class="overflow data-v-3e1b5f72">{{it.create_user_nickname}}</text></view><view data-event-opts="{{[['tap',[['handleZan',['$0'],[[['menuList','',id]]]]]]]}}" class="zan data-v-3e1b5f72" bindtap="__e"><icon class="{{['t-icon','data-v-3e1b5f72',it.is_me_like_it=='yes'?'t-icon-icon3':'t-icon-icon_collect']}}"></icon><text class="data-v-3e1b5f72">{{it.likes_num}}</text></view></view></view></block></view></block><block wx:if="{{$root.g1}}"><view class="endtext data-v-3e1b5f72">—— 到底了,看看别的吧 ——</view></block><block wx:if="{{!$root.g2}}"><view class="nolist data-v-3e1b5f72"><icon class="iconfont icon-wancan data-v-3e1b5f72"></icon><text class="data-v-3e1b5f72">还没有记录哦</text></view></block></view>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -150,11 +150,25 @@
font-weight: bold; font-weight: bold;
} }
.jishiqi .detail.data-v-57280228 { .jishiqi .detail.data-v-57280228 {
color: #fff; color: #3CB383;
width: auto; width: auto;
padding: 5px 20px; padding: 3px 10px;
background: #F7931E; background: #fff;
border-radius: 10px; border-radius: 8px;
border: 1px solid #3CB383;
display: flex;
align-items: center;
}
.jishiqi .detail image.data-v-57280228 {
width: 44rpx;
height: 44rpx;
margin-right: 5px;
}
.jishiqi .left.data-v-57280228 {
margin-top: -10px;
}
.jishiqi .right.data-v-57280228 {
margin-top: 0;
} }
.box1 .header.data-v-57280228 { .box1 .header.data-v-57280228 {
width: 100rpx; width: 100rpx;

View File

@ -1 +1 @@
<view class="content data-v-35a5eb88"><search vue-id="7f16836c-1" name="{{search_value}}" class="data-v-35a5eb88" bind:__l="__l"></search><block wx:if="{{$root.g0}}"><view class="footbox footlist data-v-35a5eb88"><block wx:for="{{food_search_list}}" wx:for-item="it" wx:for-index="ind" wx:key="ind"><view data-event-opts="{{[['tap',[['handleDetail',['$0'],[[['food_search_list','',ind,'id']]]]]]]}}" class="list data-v-35a5eb88" bindtap="__e"><view class="topimg data-v-35a5eb88"><image class="img data-v-35a5eb88" src="{{it.cover}}" mode="aspectFill"></image></view><view class="item data-v-35a5eb88"><view class="title data-v-35a5eb88">{{it.title}}</view><view class="name data-v-35a5eb88"><image src="{{it.create_user_head_pic}}" class="data-v-35a5eb88"></image><text class="overflow data-v-35a5eb88">{{it.create_user_nickname}}</text></view><view class="zan data-v-35a5eb88"><icon class="{{['iconfont','data-v-35a5eb88',it.is_me_like_it=='yes'?'icon-icon3':'icon-icon_collect']}}"></icon><text class="data-v-35a5eb88">{{it.likes_num}}</text></view></view></view></block></view></block><block wx:if="{{!lastPage||Page>=lastPage}}"><view class="endtext data-v-35a5eb88">—— 到底了,看看别的吧 ——</view></block><block wx:if="{{!$root.g1}}"><view class="nolist data-v-35a5eb88"><icon class="iconfont icon-wancan data-v-35a5eb88"></icon><text class="data-v-35a5eb88">还没有记录哦</text></view></block></view> <view class="content data-v-35a5eb88"><search vue-id="7f16836c-1" name="{{search_value}}" class="data-v-35a5eb88" bind:__l="__l"></search><block wx:if="{{$root.g0}}"><view class="footbox footlist data-v-35a5eb88"><block wx:for="{{food_search_list}}" wx:for-item="it" wx:for-index="ind" wx:key="ind"><view data-event-opts="{{[['tap',[['handleDetail',['$0'],[[['food_search_list','',ind,'id']]]]]]]}}" class="list data-v-35a5eb88" bindtap="__e"><view class="topimg data-v-35a5eb88"><image class="img data-v-35a5eb88" src="{{it.cover}}" mode="aspectFill"></image></view><view class="item data-v-35a5eb88"><view class="title data-v-35a5eb88">{{it.title}}</view><view class="name data-v-35a5eb88"><image src="{{it.create_user_head_pic}}" class="data-v-35a5eb88"></image><text class="overflow data-v-35a5eb88">{{it.create_user_nickname}}</text></view><view class="zan data-v-35a5eb88"><icon class="{{['t-icon','data-v-35a5eb88',it.is_me_like_it=='yes'?'t-icon-icon3':'t-icon-icon_collect']}}"></icon><text class="data-v-35a5eb88">{{it.likes_num}}</text></view></view></view></block></view></block><block wx:if="{{!lastPage||Page>=lastPage}}"><view class="endtext data-v-35a5eb88">—— 到底了,看看别的吧 ——</view></block><block wx:if="{{!$root.g1}}"><view class="nolist data-v-35a5eb88"><icon class="iconfont icon-wancan data-v-35a5eb88"></icon><text class="data-v-35a5eb88">还没有记录哦</text></view></block></view>

View File

@ -202,7 +202,7 @@ var _default = {
Page: 1, Page: 1,
showAll: false, showAll: false,
search_value: '', search_value: '',
mic_touch: false, showAutoSearchDlg: false,
voiceManager: null voiceManager: null
}; };
}, },
@ -233,7 +233,7 @@ var _default = {
}, },
onVoiceTouchStart: function onVoiceTouchStart() { onVoiceTouchStart: function onVoiceTouchStart() {
var that = this; var that = this;
that.mic_touch = true; that.showAutoSearchDlg = true;
that.voiceManager.start({ that.voiceManager.start({
duration: 60000, duration: 60000,
lang: "zh_CN" lang: "zh_CN"
@ -241,12 +241,20 @@ var _default = {
}, },
onVoiceTouchEnd: function onVoiceTouchEnd() { onVoiceTouchEnd: function onVoiceTouchEnd() {
var that = this; var that = this;
that.mic_touch = false; that.showAutoSearchDlg = false;
that.voiceManager.stop(); that.voiceManager.stop();
}, },
// 取消录音
cancelRecording: function cancelRecording() {
if (this.voiceManager) {
this.voiceManager.stop();
this.showAutoSearchDlg = false;
}
},
handlecolse: function handlecolse() { handlecolse: function handlecolse() {
console.log("取消搜索"); console.log("取消搜索");
this.search_value = ""; this.search_value = "";
this.search_list = [];
}, },
// 历史搜索 // 历史搜索
handleSearchHistory: function handleSearchHistory(text) { handleSearchHistory: function handleSearchHistory(text) {

View File

@ -1 +1 @@
<view class="content data-v-4cedc0c6"><view class="search data-v-4cedc0c6"><input type="text" placeholder="输入关键字匹配食谱" data-event-opts="{{[['input',[['__set_model',['','search_value','$event',[]]]]]]}}" value="{{search_value}}" bindinput="__e" class="data-v-4cedc0c6"/><block wx:if="{{search_value}}"><icon data-event-opts="{{[['tap',[['handlecolse',['$event']]]]]}}" class="iconfont icon-error data-v-4cedc0c6" bindtap="__e"></icon></block><image src="/static/28.png" data-event-opts="{{[['tap',[['handleSearchHistory',['$0'],['search_value']]]]]}}" bindtap="__e" class="data-v-4cedc0c6"></image></view><view class="content-box data-v-4cedc0c6"><block wx:if="{{$root.g0}}"><view class="search-history data-v-4cedc0c6"><view class="title data-v-4cedc0c6"><view class="quan mr-5 data-v-4cedc0c6"></view>历史搜索</view><block wx:if="{{$root.g1>8}}"><view data-event-opts="{{[['tap',[['e0',['$event']]]]]}}" class="button-container data-v-4cedc0c6" bindtap="__e"><image src="{{showAll?'/static/arrow-up.png':'/static/arrow-down.png'}}" class="data-v-4cedc0c6"></image></view></block><view class="history-list data-v-4cedc0c6"><block wx:for="{{showAll?history_food:$root.g2}}" wx:for-item="item" wx:for-index="index"><view data-event-opts="{{[['tap',[['e1',['$event']]]]]}}" data-event-params="{{({item})}}" class="history-list-item data-v-4cedc0c6" bindtap="__e">{{''+item.keyword+''}}</view></block></view></view></block><view class="popular-container data-v-4cedc0c6"><view class="title data-v-4cedc0c6"><view class="quan mr-5 data-v-4cedc0c6"></view>猜你想搜</view><block wx:for="{{popular_food}}" wx:for-item="ite" wx:for-index="index" wx:key="index"><view class="popular-food-item data-v-4cedc0c6"><view class="food-title data-v-4cedc0c6">{{ite.title}}</view><view class="popular-food-inner data-v-4cedc0c6"><block wx:for="{{ite.list}}" wx:for-item="sub_item" wx:for-index="sub_index" wx:key="sub_index"><text data-event-opts="{{[['tap',[['handleSearchHistory',['$0'],[[['popular_food','',index],['list','',sub_index,'name']]]]]]]}}" class="popular-food-subitem data-v-4cedc0c6" bindtap="__e">{{sub_item.name+''}}</text></block></view></view></block></view></view><view class="footBtn data-v-4cedc0c6"><view data-event-opts="{{[['touchstart',[['onVoiceTouchStart',['$event']]]],['touchend',[['onVoiceTouchEnd',['$event']]]]]}}" class="mic-icon data-v-4cedc0c6" bindtouchstart="__e" bindtouchend="__e"><uni-icons vue-id="50cad900-1" type="mic-filled" size="20" color="{{mic_touch?'#777777':'#fff'}}" class="data-v-4cedc0c6" bind:__l="__l"></uni-icons>语音搜索</view></view></view> <view class="content data-v-4cedc0c6"><view class="search data-v-4cedc0c6"><input type="text" placeholder="输入关键字匹配食谱" data-event-opts="{{[['input',[['__set_model',['','search_value','$event',[]]]]]]}}" value="{{search_value}}" bindinput="__e" class="data-v-4cedc0c6"/><block wx:if="{{search_value}}"><icon data-event-opts="{{[['tap',[['handlecolse',['$event']]]]]}}" class="iconfont icon-error data-v-4cedc0c6" bindtap="__e"></icon></block><image src="/static/28.png" data-event-opts="{{[['tap',[['handleSearchHistory',['$0'],['search_value']]]]]}}" bindtap="__e" class="data-v-4cedc0c6"></image></view><view class="content-box data-v-4cedc0c6"><block wx:if="{{$root.g0}}"><view class="search-history data-v-4cedc0c6"><view class="title data-v-4cedc0c6"><view class="quan mr-5 data-v-4cedc0c6"></view>历史搜索</view><block wx:if="{{$root.g1>8}}"><view data-event-opts="{{[['tap',[['e0',['$event']]]]]}}" class="button-container data-v-4cedc0c6" bindtap="__e"><image src="{{showAll?'/static/arrow-up.png':'/static/arrow-down.png'}}" class="data-v-4cedc0c6"></image></view></block><view class="history-list data-v-4cedc0c6"><block wx:for="{{showAll?history_food:$root.g2}}" wx:for-item="item" wx:for-index="index"><view data-event-opts="{{[['tap',[['e1',['$event']]]]]}}" data-event-params="{{({item})}}" class="history-list-item data-v-4cedc0c6" bindtap="__e">{{''+item.keyword+''}}</view></block></view></view></block><view class="popular-container data-v-4cedc0c6"><view class="title data-v-4cedc0c6"><view class="quan mr-5 data-v-4cedc0c6"></view>猜你想搜</view><block wx:for="{{popular_food}}" wx:for-item="ite" wx:for-index="index" wx:key="index"><view class="popular-food-item data-v-4cedc0c6"><view class="food-title data-v-4cedc0c6">{{ite.title}}</view><view class="popular-food-inner data-v-4cedc0c6"><block wx:for="{{ite.list}}" wx:for-item="sub_item" wx:for-index="sub_index" wx:key="sub_index"><text data-event-opts="{{[['tap',[['handleSearchHistory',['$0'],[[['popular_food','',index],['list','',sub_index,'name']]]]]]]}}" class="popular-food-subitem data-v-4cedc0c6" bindtap="__e">{{sub_item.name+''}}</text></block></view></view></block></view></view><view class="footBtn data-v-4cedc0c6"><view data-event-opts="{{[['touchstart',[['onVoiceTouchStart',['$event']]]],['touchend',[['onVoiceTouchEnd',['$event']]]],['touchcancel',[['cancelRecording',['$event']]]]]}}" class="mic-icon data-v-4cedc0c6" bindtouchstart="__e" bindtouchend="__e" bindtouchcancel="__e"><uni-icons vue-id="50cad900-1" type="mic-filled" size="20" color="#fff" class="data-v-4cedc0c6" bind:__l="__l"></uni-icons>语音搜索</view></view><block wx:if="{{showAutoSearchDlg}}"><view class="wrapper data-v-4cedc0c6"><view class="auto-search-dialog data-v-4cedc0c6"><view class="auto-search-inner data-v-4cedc0c6"><view class="voice-wave data-v-4cedc0c6"><view class="wave-bar data-v-4cedc0c6"></view><view class="wave-bar data-v-4cedc0c6"></view><view class="wave-bar data-v-4cedc0c6"></view><view class="wave-bar data-v-4cedc0c6"></view><view class="wave-bar data-v-4cedc0c6"></view><view class="wave-bar data-v-4cedc0c6"></view></view></view></view></view></block></view>

View File

@ -166,7 +166,7 @@
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
height: 100%; bottom: 60px;
background-color: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.5);
z-index: 999; z-index: 999;
} }
@ -176,49 +176,12 @@
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
position: relative; position: relative;
width: 70%; width: 50%;
height: 350rpx; padding: 60rpx 0;
padding: 80rpx 0;
background-color: #fff; background-color: #fff;
border-radius: 20rpx; border-radius: 20rpx;
box-shadow: 0 0 20rpx #ccc; box-shadow: 0 0 20rpx #ccc;
} }
.content .auto-search-dialog .auto-search-inner .close.data-v-4cedc0c6 {
position: absolute;
left: 0;
right: 0;
bottom: -140rpx;
width: 90rpx;
margin: 0 auto;
}
.content .auto-search-dialog text.data-v-4cedc0c6 {
font-size: 32rpx;
width: 80%;
}
.content .auto-search-dialog .mic-icon.data-v-4cedc0c6 {
display: flex;
justify-content: center;
align-items: center;
width: 150rpx;
height: 150rpx;
border-radius: 50%;
border: 8rpx solid #777777;
}
.content .auto-search-dialog .btn-wrap.data-v-4cedc0c6 {
display: flex;
justify-content: space-around;
width: 90%;
}
.content .auto-search-dialog .btn-wrap .retry.data-v-4cedc0c6,
.content .auto-search-dialog .btn-wrap .confirm.data-v-4cedc0c6 {
width: 190rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
font-size: 28rpx;
border: 2rpx solid #777;
border-radius: 15rpx;
}
.content .footBtn.data-v-4cedc0c6 { .content .footBtn.data-v-4cedc0c6 {
position: fixed; position: fixed;
width: 100%; width: 100%;