最新版计食器小程序
This commit is contained in:
commit
6c6e82e095
|
|
@ -38,6 +38,9 @@ page {
|
|||
.c999{
|
||||
color: #999 !important;
|
||||
}
|
||||
.red{
|
||||
color: red !important;
|
||||
}
|
||||
.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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,27 +1,45 @@
|
|||
<template>
|
||||
<view class="weightPages">
|
||||
<view class="table" v-if="isConnection == 0">{{msgText}}</view>
|
||||
<view class="table" v-if="isConnection == 1" @click="openBluetoothAdapter">连接失败,点击重新连接</view>
|
||||
<view class="image" v-if="isConnection != 3">
|
||||
<image src="../static/cheng.png"></image>
|
||||
<view class="table">
|
||||
<view class="text">
|
||||
<image src="/static/zhong.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 v-if="isConnection == 3">
|
||||
<view class="weight">
|
||||
<view>重量<text>{{weight}}</text>{{dw=='g'?'克':'盎司'}}</view>
|
||||
<view>热量<text>{{kcal}}</text>千卡</view>
|
||||
<text class="val">{{kcal?kcal:0}}</text>
|
||||
<text class="unit">kcal</text>
|
||||
</view>
|
||||
<view class="tips">
|
||||
注:重新测量可更新当前数据
|
||||
</view>
|
||||
<view class="groupbtn" v-if="weightType!=2">
|
||||
<view class="btn" @click="handleDetailSub">完成</view>
|
||||
<view class="btn" @click="handleDetailNext" v-if="!stopblue">下一位</view>
|
||||
<view class="groupbtn">
|
||||
<view class="btn danwei">
|
||||
<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 class="btn" @click="handlesub" v-if="weightType==2">确认添加</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="tips" v-if="isConnection == 1">
|
||||
<uni-icons type="info-filled" color="#dd524d" size="20"></uni-icons>
|
||||
请确定设备是开机状态、手机蓝牙权限已打开!
|
||||
</view>
|
||||
</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>
|
||||
</template>
|
||||
|
|
@ -30,20 +48,27 @@
|
|||
import {
|
||||
mapState
|
||||
} from "vuex";
|
||||
let searchTimer = null
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
dw: "g",
|
||||
kcal: "",
|
||||
weight: "",
|
||||
// weight: "",
|
||||
weightALL: "",
|
||||
msgText: "蓝牙连接中",
|
||||
unit: '',
|
||||
bleTipsText: "",
|
||||
unit: 'g',
|
||||
weight0: 0,
|
||||
devicesList: [],
|
||||
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'
|
||||
]
|
||||
|
|
@ -54,53 +79,35 @@
|
|||
type: Number,
|
||||
default: 0 //当前测量食物每g含的kcal
|
||||
},
|
||||
weightType: {
|
||||
type: Number,
|
||||
default: -1 //0分类测量,1累计测量,2购物车测量
|
||||
},
|
||||
isLast: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(["user", "isBluetoothTyle", "bleValue"]),
|
||||
weight() {
|
||||
let kcal = (Number(this.weightKcal) * this.bleValue.countWeight).toFixed(2)
|
||||
this.unit = this.unitConversion(this.bleValue.unit)
|
||||
this.kcal = this.convertToGrams(kcal, this.bleValue.unit).toFixed(2)
|
||||
return this.bleValue.countWeight
|
||||
},
|
||||
isConnection() {
|
||||
this.bleTipsText = this.bleValue.bleTipsText
|
||||
return this.bleValue.isConnectStatus
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
let that = this
|
||||
if (that.bleValue.serviceId != "") {
|
||||
that.closeBLEConnection()
|
||||
that.closeBluetoothAdapter()
|
||||
that.openBluetoothAdapter()
|
||||
} else {
|
||||
that.openBluetoothAdapter()
|
||||
}
|
||||
that.onBLEConnectionStateChange()
|
||||
uni.onBluetoothAdapterStateChange(function(res) {
|
||||
that.$store.commit("changeBluetooth", res.available);
|
||||
})
|
||||
},
|
||||
destroyed() {
|
||||
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: {
|
||||
// weightType: function() {
|
||||
// let that = this
|
||||
// that.openBluetoothAdapter()
|
||||
// },
|
||||
isBluetoothTyle: function() {
|
||||
let that = this
|
||||
if (!that.isBluetoothTyle) {
|
||||
|
|
@ -110,314 +117,79 @@
|
|||
isLast: function() {
|
||||
let that = this
|
||||
that.stopblue = that.isLast
|
||||
console.log("最后", this.isLast)
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 初始化蓝牙
|
||||
openBluetoothAdapter() {
|
||||
let that = this
|
||||
that.weight = ""
|
||||
if (that.isConnection == 0) return
|
||||
that.kcal = ""
|
||||
that.msgText = '蓝牙连接中'
|
||||
uni.openBluetoothAdapter({
|
||||
success: e => {
|
||||
that.isConnection = 0
|
||||
that.startBluetoothDeviceDiscovery()
|
||||
searchTimer = setTimeout(() => {
|
||||
uni.stopBluetoothDevicesDiscovery()
|
||||
if (!that.devicesList.length) {
|
||||
clearTimeout(searchTimer);
|
||||
that.isConnection = 1
|
||||
}
|
||||
}, 30000); // 30秒超时
|
||||
that.$store.commit('changeBluetoothValue', {
|
||||
deviceId: "",
|
||||
serviceId: "",
|
||||
notify: '',
|
||||
write: '',
|
||||
unit: "g",
|
||||
countWeight: "",
|
||||
bleTipsText: "蓝牙搜索中",
|
||||
isConnectStatus: 0,
|
||||
})
|
||||
that.$ble.openBluetoothAdapter()
|
||||
},
|
||||
fail: e => {
|
||||
that.isConnection = 1
|
||||
console.log('openBluetoothAdapter', e)
|
||||
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")
|
||||
}
|
||||
});
|
||||
},
|
||||
// 开始搜寻附近的蓝牙外围设备
|
||||
startBluetoothDeviceDiscovery() {
|
||||
changleUnits(e) {
|
||||
let that = this
|
||||
uni.startBluetoothDevicesDiscovery({
|
||||
allowDuplicatesKey: true,
|
||||
services: [
|
||||
// "F0A0",
|
||||
// "A5FE"
|
||||
],
|
||||
success: res => {
|
||||
that.isConnection = 0
|
||||
that.onBluetoothDeviceFound();
|
||||
},
|
||||
fail: res => {
|
||||
that.isConnection = 1
|
||||
console.log('startBluetoothDeviceDiscovery', res)
|
||||
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")
|
||||
let name = that.unitList[e.detail.value].name
|
||||
console.log("单位切换", name, that.unit)
|
||||
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
|
||||
})
|
||||
|
||||
},
|
||||
// 监听蓝牙连接状态
|
||||
onBLEConnectionStateChange() {
|
||||
handletoggleUnit(unit) {
|
||||
let that = this
|
||||
uni.onBLEConnectionStateChange(function(res) {
|
||||
console.log("监听蓝牙连接状态", res.connected)
|
||||
if (!res.connected) {
|
||||
that.isConnection = 1
|
||||
that.closeBLEConnection()
|
||||
that.closeBluetoothAdapter()
|
||||
let checksum = 0;
|
||||
const bytes = [0xC5, 0x03, 0x05, 0x11]
|
||||
bytes[4] = unit
|
||||
for (let i = 0; i < bytes.length; i++) {
|
||||
checksum ^= bytes[i];
|
||||
}
|
||||
that.$store.commit("changeConnected", res.connected);
|
||||
})
|
||||
bytes[5] = checksum
|
||||
that.sendData(new Uint8Array(bytes).buffer)
|
||||
},
|
||||
/**
|
||||
* 停止搜索蓝牙设备
|
||||
*/
|
||||
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) {
|
||||
handleqingling() {
|
||||
let that = this
|
||||
const foundDevices = that.devicesList
|
||||
const idx = that.$ble.inArray(foundDevices, "deviceId", deviceId)
|
||||
if (idx === -1) {
|
||||
that.devicesList.push(deviceId);
|
||||
that.connectDevice(deviceId)
|
||||
}
|
||||
let str = "C503071100D0"
|
||||
let buf = new Uint8Array(str.match(/[\da-f]{2}/gi).map(function(h) {
|
||||
return parseInt(h, 16)
|
||||
}))
|
||||
that.sendData(buf.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) {
|
||||
sendData(buffer) {
|
||||
let that = this
|
||||
uni.notifyBLECharacteristicValueChange({
|
||||
deviceId: deviceId,
|
||||
serviceId: serviceId,
|
||||
characteristicId: notify,
|
||||
state: true,
|
||||
success: () => {
|
||||
that.isConnection = 3
|
||||
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
|
||||
}
|
||||
}
|
||||
})
|
||||
uni.writeBLECharacteristicValue({
|
||||
deviceId: that.bleValue.deviceId,
|
||||
serviceId: that.bleValue.serviceId,
|
||||
characteristicId: that.bleValue.write,
|
||||
value: buffer,
|
||||
success: res => {
|
||||
console.log('下发指令成功', res.errMsg)
|
||||
},
|
||||
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() {
|
||||
let that = this
|
||||
console.log("weight", that.weight)
|
||||
console.log("测量保存", that.weight, that.unit, that.kcal)
|
||||
if (Number(that.weight) > 0) {
|
||||
that.$emit("handleBle", that.weight, that.dw, that.kcal)
|
||||
that.stopBluetoothDevicesDiscovery() //取消蓝牙搜索
|
||||
that.closeBLEConnection()
|
||||
that.closeBluetoothAdapter()
|
||||
that.$emit("handleBle", that.weight, that.unit, that.kcal)
|
||||
} else {
|
||||
that.$tools.msg("数据异常,请清零后重新测量!")
|
||||
}
|
||||
|
|
@ -440,24 +212,8 @@
|
|||
// 备料完成
|
||||
handleDetailSub() {
|
||||
let that = this
|
||||
if (that.weightType == 1) { //累计测量
|
||||
// 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
|
||||
if (Number(that.weight) > 0) {
|
||||
that.$emit("handleDetailSub", that.weight, that.unit, that.kcal)
|
||||
} else {
|
||||
that.$tools.msg("数据异常,请重新测量!")
|
||||
}
|
||||
|
|
@ -465,110 +221,83 @@
|
|||
//备料下一个
|
||||
handleDetailNext() {
|
||||
let that = this
|
||||
if (that.weightType == 1) {
|
||||
console.log('weight:' + that.weight)
|
||||
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
|
||||
if (Number(that.weight) > 0) {
|
||||
that.$emit("handleDetailNext", that.weight, that.unit, that.kcal)
|
||||
} else {
|
||||
that.$tools.msg("数据异常,请清零后重新测量!")
|
||||
}
|
||||
},
|
||||
|
||||
handlechongzhi(weight) {
|
||||
let that = this
|
||||
console.log('当前总重:' + that.weightALL)
|
||||
console.log('重置重量:' + weight)
|
||||
if (that.weightType == 1) {
|
||||
that.weightALL = Number((Number(that.weightALL) - Number(weight)).toFixed(2))
|
||||
console.log('剩余重量:' + that.weightALL)
|
||||
unitConversion(unit) {
|
||||
if (unit == 'kcal') {
|
||||
return '千卡'
|
||||
} else if (unit == 'g') {
|
||||
return '克'
|
||||
} else if (unit == 'lb') {
|
||||
return '磅'
|
||||
} else if (unit == 'oz') {
|
||||
return '盎司'
|
||||
}
|
||||
return unit
|
||||
},
|
||||
|
||||
handleBack() {
|
||||
let that = this
|
||||
that.isConnection = 1
|
||||
that.stopBluetoothDevicesDiscovery() //取消蓝牙搜索
|
||||
that.closeBLEConnection()
|
||||
that.closeBluetoothAdapter()
|
||||
},
|
||||
/**
|
||||
* 断开蓝牙模块
|
||||
*/
|
||||
closeBluetoothAdapter() {
|
||||
let that = this;
|
||||
uni.closeBluetoothAdapter({
|
||||
success: res => {
|
||||
console.log('蓝牙模块关闭成功');
|
||||
}
|
||||
that.$store.commit("changeBluetoothValue", {
|
||||
bleTipsText: "连接失败,点击重新连接",
|
||||
isConnectStatus: 1
|
||||
})
|
||||
that.$ble.stopBluetoothDevicesDiscovery() //取消蓝牙搜索
|
||||
that.$ble.closeBLEConnection(that.bleValue.deviceId)
|
||||
that.$ble.closeBluetoothAdapter()
|
||||
},
|
||||
/**
|
||||
* 断开蓝牙连接
|
||||
*/
|
||||
closeBLEConnection() {
|
||||
var that = this;
|
||||
uni.closeBLEConnection({
|
||||
deviceId: that.deviceId,
|
||||
success: res => {
|
||||
console.log('断开蓝牙连接成功');
|
||||
}
|
||||
});
|
||||
confirm(value) {
|
||||
console.log("手动输入", value)
|
||||
this.$store.commit("changeBluetoothValue", {
|
||||
countWeight: value,
|
||||
unit: this.unitList[this.unitListIndex].unit
|
||||
})
|
||||
this.$refs.popup.close()
|
||||
},
|
||||
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>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.weightPages {
|
||||
.table {
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
align-items: center;
|
||||
padding: 5px 0;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
|
||||
.text {
|
||||
color: #8284f0;
|
||||
display: flex;
|
||||
|
||||
image {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.weightPages {
|
||||
position: absolute;
|
||||
justify-content: space-around;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 40rpx;
|
||||
top: 120rpx;
|
||||
margin-top: 40rpx;
|
||||
left: 15px;
|
||||
right: 15px;
|
||||
bottom: 30rpx;
|
||||
top: 15px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
|
||||
.weight {
|
||||
background: #fff;
|
||||
|
|
@ -597,47 +326,80 @@
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
.tips {
|
||||
font-size: 24rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.btn {
|
||||
color: #fff;
|
||||
width: 80%;
|
||||
margin-left: 10%
|
||||
}
|
||||
|
||||
.groupbtn {
|
||||
margin-top: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.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%;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
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>
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
<!-- 蓝牙称重 -->
|
||||
<view class="weight" @click="inputDialogToggle">
|
||||
<text class="val">{{weight == '' ? '0.0':weight}}</text>
|
||||
<text class="unit">{{unit}}</text>
|
||||
<text class="unit">{{unitConversion(unit)}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- -->
|
||||
|
|
@ -31,8 +31,8 @@
|
|||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="btn addbtn size14" @click="handlesub" v-if="weightType==2&&btnType==2">保存</view>
|
||||
<view class="btn addbtn" @click="handleAddFood" v-if="weightType==2&&btnType==1">+</view>
|
||||
<view class="btn addbtn size14" @click="handlesub" v-if="btnType==2">保存</view>
|
||||
<view class="btn addbtn" @click="handleAddFood" v-if="btnType==1">+</view>
|
||||
<view class="btn qingling" @click="handleqingling">清零</view>
|
||||
</view>
|
||||
<!-- -->
|
||||
|
|
@ -56,6 +56,7 @@
|
|||
return {
|
||||
kcal: 0,
|
||||
unit: '',
|
||||
// weight: "",
|
||||
bleTipsText: "",
|
||||
inputDialog: false,
|
||||
unitList: [{
|
||||
|
|
@ -78,10 +79,6 @@
|
|||
type: Number,
|
||||
default: 0 //当前测量食物每100g含的kcal
|
||||
},
|
||||
weightType: {
|
||||
type: Number,
|
||||
default: -1 //0分类测量,1累计测量,2购物车测量
|
||||
},
|
||||
btnType: {
|
||||
type: Number,
|
||||
default: 1 //1添加食材,2保存测量
|
||||
|
|
@ -91,7 +88,7 @@
|
|||
...mapState(["bleValue", "isBluetoothTyle", "countFoodInfo"]),
|
||||
weight() {
|
||||
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
|
||||
},
|
||||
isConnection() {
|
||||
|
|
@ -140,6 +137,7 @@
|
|||
})
|
||||
that.$ble.openBluetoothAdapter()
|
||||
},
|
||||
|
||||
changleUnits(e) {
|
||||
let that = this
|
||||
let name = that.unitList[e.detail.value].name
|
||||
|
|
@ -240,30 +238,6 @@
|
|||
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>
|
||||
|
|
@ -314,7 +288,7 @@
|
|||
|
||||
.weight {
|
||||
.val {
|
||||
font-size: 40rpx;
|
||||
font-size: 54rpx;
|
||||
color: #F0AE43;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
|
@ -328,20 +302,6 @@
|
|||
background-color: #F0AE43;
|
||||
}
|
||||
}
|
||||
|
||||
.kcal {
|
||||
font-size: 32rpx;
|
||||
|
||||
.val {
|
||||
font-size: 40rpx;
|
||||
color: #F0AE43;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.unit {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tips {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
<view class="serach-box">
|
||||
<view class="searchInput">
|
||||
<input placeholder="请输入..." class="city-serach-input" v-model="search_value" />
|
||||
<icon v-if="search_value" class="iconfont icon-error" @click="handlecolse"></icon>
|
||||
<icon v-if="search_value" class="iconfont icon-error" @click="handlecolse" size="30"></icon>
|
||||
</view>
|
||||
<view class="searchBtn">
|
||||
<view @click="handleSerach">搜索</view>
|
||||
|
|
@ -52,6 +52,24 @@
|
|||
</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_item" v-for="(ite,ind) in search_list" @click="handleDetail(ite)">
|
||||
|
|
@ -63,19 +81,62 @@
|
|||
</view>
|
||||
<view class="endtext" v-if="!lastPage || page >= lastPage">—— 到底了,看看别的吧 ——</view>
|
||||
</view>
|
||||
<!-- 购物车列表 -->
|
||||
<!-- 购物车弹框 -->
|
||||
<view class="wrapper activeList" v-if="isShop">
|
||||
<view class="bg" @click='isShop=false'>
|
||||
<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="[item.name == foodName?'active':'']" v-for="(item,index) in foodItem"
|
||||
@click="handleToggle(item.name)">
|
||||
{{item.name}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="list" v-if="ActiveList.length">
|
||||
<view class="length">共{{ActiveList.filter(ite => ite.meals_type == foodName).length}}条记录</view>
|
||||
<view class="item" v-for="(ite,ind) in ActiveList" :key="ind" v-if="ite.meals_type==foodName">
|
||||
<view class="box_list_item" v-if="ActiveList.length">
|
||||
<view class="length">共<text
|
||||
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">
|
||||
<image :src="ite.pic_url"></image>
|
||||
<view class="name">
|
||||
|
|
@ -94,11 +155,12 @@
|
|||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 测量区 -->
|
||||
</view>
|
||||
<!-- 测量弹框 -->
|
||||
<view class="wrapper" v-if="IsWeight">
|
||||
<view class="bg" @click='IsWeight=false'>
|
||||
<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">
|
||||
<view class="box-info">
|
||||
<view class="foodItem">
|
||||
|
|
@ -124,7 +186,7 @@
|
|||
</view>
|
||||
<!-- 蓝牙称重 -->
|
||||
<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>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -150,23 +212,20 @@
|
|||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 底部购物车 -->
|
||||
<view class="groupbtn">
|
||||
<view @click="isShop =! isShop" 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 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 class="mic-icon" @touchstart="onVoiceTouchStart" @touchend="onVoiceTouchEnd">
|
||||
<uni-icons type="mic-filled" size="20" :color="mic_touch ? '#777777' : '#fff'"></uni-icons>
|
||||
语音搜索
|
||||
</view>
|
||||
<!-- <view class="subbtn" @click="handlesubbtn"> 完成</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
|
@ -182,13 +241,13 @@
|
|||
export default {
|
||||
data() {
|
||||
return {
|
||||
opts: {
|
||||
background: "transparent",
|
||||
title: {
|
||||
name: "",
|
||||
chartData: {
|
||||
series: [{
|
||||
data: 0,
|
||||
color: "#3CB383"
|
||||
}]
|
||||
},
|
||||
},
|
||||
chartData: {},
|
||||
foodInfo: [],
|
||||
time: "",
|
||||
page: 1,
|
||||
foodName: "",
|
||||
|
|
@ -202,10 +261,8 @@
|
|||
search_value: '',
|
||||
ActiveList: [],
|
||||
activeType: {},
|
||||
mic_touch: false,
|
||||
voiceManager: null,
|
||||
autoSearchContent: "",
|
||||
showAutoSearchDlg: false,
|
||||
showAutoSearchDlg: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
|
|
@ -213,12 +270,12 @@
|
|||
popular_food() {
|
||||
return this.configInfo.search_guess.food_data
|
||||
},
|
||||
history_food() {
|
||||
return this.configInfo.search_history.food
|
||||
},
|
||||
foodItem() {
|
||||
return this.configInfo.meal_list
|
||||
},
|
||||
history_food() {
|
||||
return this.configInfo.search_history.food
|
||||
},
|
||||
},
|
||||
components: {
|
||||
search,
|
||||
|
|
@ -263,24 +320,37 @@
|
|||
this.handleSerach()
|
||||
},
|
||||
methods: {
|
||||
// 开始录音
|
||||
onVoiceTouchStart() {
|
||||
let that = this
|
||||
that.mic_touch = true
|
||||
that.showAutoSearchDlg = true
|
||||
that.isShop = false
|
||||
that.voiceManager.start({
|
||||
duration: 60000,
|
||||
lang: "zh_CN"
|
||||
})
|
||||
},
|
||||
// 停止录音
|
||||
onVoiceTouchEnd() {
|
||||
let that = this
|
||||
that.mic_touch = false
|
||||
that.showAutoSearchDlg = false
|
||||
that.voiceManager.stop()
|
||||
},
|
||||
// 取消录音
|
||||
cancelRecording() {
|
||||
// #ifdef MP-WEIXIN
|
||||
if (this.voiceManager) {
|
||||
this.voiceManager.stop()
|
||||
this.showAutoSearchDlg = false
|
||||
}
|
||||
// #endif
|
||||
},
|
||||
// 购物车早午晚餐切换
|
||||
handleToggle(name) {
|
||||
this.search_value = ""
|
||||
this.search_list = []
|
||||
this.foodName = name
|
||||
this.handleAddEveryMealFood()
|
||||
},
|
||||
//实时重量
|
||||
realTimeWeight(weight, unit) {
|
||||
|
|
@ -317,9 +387,9 @@
|
|||
that.isBle = true
|
||||
that.isShop = false
|
||||
that.IsWeight = true
|
||||
that.showAutoSearchDlg = false
|
||||
that.activeType = ite
|
||||
that.weightKcal = ite.kcal
|
||||
console.log("111111", ite, that.bleValue)
|
||||
if (that.bleValue.serviceId != "") {
|
||||
that.realTimeWeight(that.bleValue.countWeight, that.bleValue.unit)
|
||||
} else {
|
||||
|
|
@ -328,22 +398,6 @@
|
|||
unit: "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.meals_type = that.foodName
|
||||
list.push(that.activeType)
|
||||
console.log("list", list)
|
||||
that.$model.getAddIntakeFood({
|
||||
aud_id: that.user.aud_id,
|
||||
food_list: list,
|
||||
|
|
@ -371,12 +424,6 @@
|
|||
})
|
||||
}
|
||||
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) {
|
||||
that.ActiveList.push(that.activeType);
|
||||
} else {
|
||||
|
|
@ -384,16 +431,49 @@
|
|||
that.ActiveList[index].weight = that.activeType.weight;
|
||||
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() {
|
||||
let that = this
|
||||
that.search_list = []
|
||||
if (that.search_value == "") {
|
||||
that.$tools.msg("输入关键字后搜索")
|
||||
return
|
||||
}
|
||||
that.search_list = []
|
||||
that.$model.getFoodSearch({
|
||||
page: that.page,
|
||||
search_data: that.search_value
|
||||
|
|
@ -417,24 +497,8 @@
|
|||
handleSearchHistory(text) {
|
||||
let that = this
|
||||
that.search_value = text
|
||||
that.showAutoSearchDlg = false
|
||||
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) {
|
||||
this.search_value = ""
|
||||
|
|
@ -461,6 +525,7 @@
|
|||
time: that.time
|
||||
})
|
||||
}
|
||||
that.handleAddEveryMealFood()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -706,7 +771,7 @@
|
|||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
bottom: 75px;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 999;
|
||||
|
||||
|
|
@ -716,53 +781,11 @@
|
|||
justify-content: space-between;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
width: 70%;
|
||||
height: 350rpx;
|
||||
padding: 80rpx 0;
|
||||
width: 50%;
|
||||
padding: 60rpx 0;
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx;
|
||||
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 {
|
||||
position: absolute;
|
||||
right: 20rpx;
|
||||
top: -34rpx;
|
||||
top: -40rpx;
|
||||
background: #fff;
|
||||
font-size: 60rpx;
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
font-size: 80rpx;
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.box2 {
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 55%;
|
||||
top: 80rpx;
|
||||
bottom: 0;
|
||||
background-color: #fff;
|
||||
overflow: scroll;
|
||||
position: absolute;
|
||||
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 {
|
||||
width: 80px;
|
||||
background: #dfdfdf;
|
||||
background: #fff;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 75px;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
bottom: 0px;
|
||||
display: flex;
|
||||
border-radius: 10px;
|
||||
flex-direction: column;
|
||||
|
||||
view {
|
||||
|
|
@ -1127,25 +1184,32 @@
|
|||
}
|
||||
|
||||
.active {
|
||||
background-color: #fff;
|
||||
border-radius: 10px;
|
||||
background-color: #EDFFF4;
|
||||
color: #3CB383;
|
||||
}
|
||||
}
|
||||
|
||||
.list {
|
||||
margin-bottom: 90px;
|
||||
width: calc(100% - 80px);
|
||||
margin-left: 80px;
|
||||
.box_list_item {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 90px;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
overflow: scroll;
|
||||
padding-bottom: 15px;
|
||||
|
||||
.length {
|
||||
width: 100%;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
margin-top: -5px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.item {
|
||||
width: 100%;
|
||||
height: 45px;
|
||||
height: 50px;
|
||||
display: flex;
|
||||
padding: 5px 0;
|
||||
position: relative;
|
||||
|
|
@ -1195,7 +1259,7 @@
|
|||
color: red !important;
|
||||
font-size: 18px !important;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,9 +64,10 @@
|
|||
<text>{{ActiveList.length||0}}</text>
|
||||
<icon class="t-icon t-icon-canpan"></icon>
|
||||
</view>
|
||||
<view class="subbtn" @click="handlesubbtn"> 确定</view>
|
||||
<!-- <view class="subbtn" @click="handlesubbtn"> 确定</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>
|
||||
语音搜索
|
||||
</view>
|
||||
|
|
@ -91,6 +92,22 @@
|
|||
</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>
|
||||
</template>
|
||||
|
|
@ -158,6 +175,8 @@
|
|||
handleDetail(ite, ind) {
|
||||
let that = this
|
||||
let list = []
|
||||
let pages = getCurrentPages()
|
||||
let prevPage = pages[pages.length - 2]
|
||||
if (ind == 1) {
|
||||
list.push(ite)
|
||||
that.ActiveList = that.$tools.mergeAndDeduplicate(that.ActiveList, list, 'name')
|
||||
|
|
@ -168,15 +187,16 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
prevPage.$vm.getAddFood(that.ActiveList)
|
||||
},
|
||||
// 搜索
|
||||
handleSerach() {
|
||||
let that = this
|
||||
that.search_list = []
|
||||
if (that.search_value == "") {
|
||||
that.$tools.msg("输入关键字后搜索")
|
||||
return
|
||||
}
|
||||
that.search_list = []
|
||||
that.$model.getFoodSearch({
|
||||
page: that.page,
|
||||
search_data: that.search_value
|
||||
|
|
@ -207,7 +227,7 @@
|
|||
// 开始说话
|
||||
onVoiceTouchStart() {
|
||||
let that = this
|
||||
that.mic_touch = true
|
||||
that.showAutoSearchDlg = true
|
||||
that.voiceManager.start({
|
||||
duration: 60000,
|
||||
lang: "zh_CN"
|
||||
|
|
@ -216,9 +236,18 @@
|
|||
// 语音结束
|
||||
onVoiceTouchEnd() {
|
||||
let that = this
|
||||
that.mic_touch = false
|
||||
that.showAutoSearchDlg = false
|
||||
that.voiceManager.stop()
|
||||
},
|
||||
// 取消录音
|
||||
cancelRecording() {
|
||||
// #ifdef MP-WEIXIN
|
||||
if (this.voiceManager) {
|
||||
this.voiceManager.stop()
|
||||
this.showAutoSearchDlg = false
|
||||
}
|
||||
// #endif
|
||||
},
|
||||
// 购物车提交
|
||||
handlesubbtn() {
|
||||
let that = this
|
||||
|
|
@ -232,6 +261,9 @@
|
|||
//删除购物车食材
|
||||
handledelactive(ite) {
|
||||
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);
|
||||
},
|
||||
}
|
||||
|
|
@ -463,7 +495,7 @@
|
|||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
bottom: 75px;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 999;
|
||||
|
||||
|
|
@ -473,55 +505,14 @@
|
|||
justify-content: space-between;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
width: 70%;
|
||||
height: 350rpx;
|
||||
padding: 80rpx 0;
|
||||
width: 50%;
|
||||
padding: 60rpx 0;
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx;
|
||||
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 {
|
||||
z-index: 12;
|
||||
|
|
@ -556,14 +547,14 @@
|
|||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 20rpx 40rpx;
|
||||
padding: 0 20rpx;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
bottom: 0rpx;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 90px;
|
||||
z-index: 99;
|
||||
flex-wrap: wrap;
|
||||
height: 60px;
|
||||
padding-bottom: 15px;
|
||||
z-index: 15;
|
||||
background-color: #fff;
|
||||
overflow: hidden;
|
||||
box-shadow: 0px 1px 5px 2px #dfe2e1fc;
|
||||
|
|
@ -578,8 +569,8 @@
|
|||
background-color: #f0ae43;
|
||||
}
|
||||
|
||||
.jilu{
|
||||
width: 100%;
|
||||
.jilu {
|
||||
width: 110px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
|
@ -623,9 +614,9 @@
|
|||
|
||||
.mic-icon {
|
||||
color: #fff;
|
||||
width: 100%;
|
||||
width: calc(100% - 120px);
|
||||
padding: 8px 0;
|
||||
background: $maincolor;
|
||||
background: #3CB383;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
|
|
|||
|
|
@ -72,10 +72,6 @@
|
|||
<icon class="t-icon" :class="[info.collect_status=='yes'?'t-icon-icon3':'t-icon-icon_collect']"></icon>
|
||||
<text>收藏</text>
|
||||
</view>
|
||||
<!-- <view class="item" @click="handleshare()">
|
||||
<icon class="iconfont icon-a-fenxiang2"></icon>
|
||||
<text>分享</text>
|
||||
</view> -->
|
||||
<view class="item" v-if="type=='我的菜谱'" @click="handleEdit()">
|
||||
<icon class="iconfont icon-bianji"></icon>
|
||||
<text>编辑</text>
|
||||
|
|
@ -86,27 +82,31 @@
|
|||
</view>
|
||||
</view>
|
||||
<!--蓝牙连接区 -->
|
||||
<view class="wrapper" v-show="isBle">
|
||||
<view class="wrapper" v-if="isBle">
|
||||
<view class="bg" @click="isBle = false">
|
||||
<view class="box weightBox" @click.stop>
|
||||
<view class="table">
|
||||
<text>备料</text>
|
||||
<icon class="iconfont icon-error" @click='isBle=false'></icon>
|
||||
</view>
|
||||
<view class="foodlist">
|
||||
<view class="box weightBox">
|
||||
<icon class="iconfont icon-error" @click='isBle = false'></icon>
|
||||
<view class="foodlist" @click.stop>
|
||||
<view class="text">
|
||||
<text>食材</text>
|
||||
<text>建议</text>
|
||||
<text style="width: 30%;">食材</text>
|
||||
<text style="width: 18%;">建议</text>
|
||||
<view class="kcal">
|
||||
<text>重量</text>
|
||||
<text>热量</text>
|
||||
<text>重秤</text>
|
||||
</view>
|
||||
</view>
|
||||
<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="num">
|
||||
<view class="num" style="width: 18%;">
|
||||
{{ite.weight}}{{ite.unit}}
|
||||
</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">
|
||||
{{ite.newweight}}{{ite.newunit=="oz"?'盎司':'克'}}
|
||||
</view>
|
||||
|
|
@ -116,16 +116,13 @@
|
|||
<view class="edit" @click="handlechongzhi(ite,ind)" v-if="ite.newweight">
|
||||
<icon class="iconfont icon-reset"></icon>
|
||||
</view>
|
||||
<view class="kcal" v-if="activeType.id&&activeType.id ==ite.id&&!ite.newweight">
|
||||
正在测量...
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="title" :style="{display: (!isWeightType&&iSWeightSub) ? '' : 'none'}">
|
||||
<view class="name">{{activeType.name}}</view>
|
||||
<view class="blue-tooth" :style="{display: (!isWeightType&&iSWeightSub) ? '' : 'none'}" @click.stop>
|
||||
<blue-tooth ref="blueTooth" @handleDetailNext="handleDetailNext"
|
||||
@handleDetailSub="handleDetailSub" @connect_success="handleWeight" :weightType="weightType"
|
||||
:isLast="isLast" :weightKcal="weightKcal" />
|
||||
@handleDetailSub="handleDetailSub" :weightKcal="weightKcal" :name="activeType.name"
|
||||
:isLast="isLast" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -158,6 +155,7 @@
|
|||
info: {},
|
||||
id: null,
|
||||
index: 0,
|
||||
isLast: false,
|
||||
weightKcal: null,
|
||||
weightType: 0,
|
||||
activeType: {},
|
||||
|
|
@ -165,7 +163,6 @@
|
|||
isWeightType: true,
|
||||
iSWeightSub: true,
|
||||
listInd: 0,
|
||||
isLast: false,
|
||||
cookIndex: null,
|
||||
showSaveFood: false,
|
||||
saveFoodTypes: [
|
||||
|
|
@ -178,7 +175,7 @@
|
|||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(["user", "configInfo"]),
|
||||
...mapState(["user", "configInfo", "bleValue"]),
|
||||
menu() {
|
||||
return this.configInfo.cookbook_label
|
||||
},
|
||||
|
|
@ -214,6 +211,9 @@
|
|||
if (res.code != 0) return
|
||||
that.info = res.data
|
||||
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) {
|
||||
return
|
||||
}
|
||||
|
||||
that.listInd = 0
|
||||
that.isBle = true
|
||||
that.isLast = false
|
||||
that.activeType = {}
|
||||
that.iSWeightSub = true
|
||||
that.isWeightType = true
|
||||
that.handleWeightType(0) //默认分类测量,取消累计测量
|
||||
that.isWeightType = false
|
||||
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) {
|
||||
|
|
@ -247,6 +250,7 @@
|
|||
that.isLast = true
|
||||
console.log('已经测量完成')
|
||||
}
|
||||
console.log("下一位", that.activeType)
|
||||
},
|
||||
// 结束测量
|
||||
handleDetailSub(weight, dw, kcal) {
|
||||
|
|
@ -265,29 +269,14 @@
|
|||
that.listInd = ind
|
||||
that.isLast = false
|
||||
that.activeType = ite
|
||||
that.iSWeightSub = true
|
||||
that.isWeightType = false
|
||||
that.weightKcal = Number(Number(that.activeType.kcal) / 100).toFixed(2)
|
||||
that.weightKcal = Number(Number(ite.kcal) / 100).toFixed(2)
|
||||
that.info.tags[0].list[ind].newweight = ""
|
||||
that.info.tags[0].list[ind].newunit = ""
|
||||
that.info.tags[0].list[ind].newkcal = ""
|
||||
if (that.listInd == that.info.tags[0].list.length - 1 || that.listInd == that.info.tags[0].list.length) {
|
||||
that.isLast = true
|
||||
}
|
||||
this.$refs.blueTooth.handlechongzhi(weight)
|
||||
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
|
||||
}
|
||||
console.log("重置", ite)
|
||||
},
|
||||
//保存测量结果到计时器
|
||||
confirmSaveFood() {
|
||||
|
|
@ -299,7 +288,7 @@
|
|||
meals_type: that.saveFoodTypes[that.selectSaveType],
|
||||
id: that.info.tags[0].list[i].id,
|
||||
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: '保存成功',
|
||||
icon: 'success'
|
||||
})
|
||||
uni.switchTab({
|
||||
url: "/pages/count/count"
|
||||
})
|
||||
})
|
||||
}
|
||||
that.showSaveFood = false
|
||||
|
|
@ -568,116 +560,71 @@
|
|||
|
||||
//
|
||||
.weightBox {
|
||||
top: 64rpx;
|
||||
height: auto;
|
||||
border-radius: 0;
|
||||
top: 40px;
|
||||
background: #dfdfdf;
|
||||
|
||||
.table {
|
||||
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;
|
||||
.icon-error {
|
||||
position: absolute;
|
||||
right: 16px;
|
||||
}
|
||||
right: 20rpx;
|
||||
top: -40rpx;
|
||||
background: #fff;
|
||||
font-size: 80rpx;
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.foodlist {
|
||||
border-radius: 0;
|
||||
height: 40%;
|
||||
overflow: scroll;
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
margin-top: 30rpx;
|
||||
font-size: 14px;
|
||||
|
||||
.text {
|
||||
width: 100%;
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
|
||||
text {
|
||||
width: 18%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
:nth-child(1) {
|
||||
width: 28%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
:nth-child(5) {
|
||||
width: 15%;
|
||||
// text-align: right !important;
|
||||
}
|
||||
|
||||
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
// justify-content: space-between;
|
||||
align-items: center;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
font-size: 16px;
|
||||
|
||||
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;
|
||||
font-size: 28rpx;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.name {
|
||||
width: auto;
|
||||
float: left;
|
||||
font-size: 24rpx;
|
||||
font-weight: 500;
|
||||
width: 28% !important;
|
||||
width: calc(30% - 10px);
|
||||
text-align: left !important;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
}
|
||||
font-weight: inherit;
|
||||
font-size: 28rpx;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.title {
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
margin-top: 20rpx;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
bottom: 20rpx;
|
||||
top: 50%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
|
||||
/deep/.weightPages {
|
||||
top: 30rpx;
|
||||
display: block;
|
||||
.kcal {
|
||||
width: 52% !important;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.blue-tooth {
|
||||
background: #fff;
|
||||
border-radius: 10px;
|
||||
margin-top: 15px;
|
||||
position: relative;
|
||||
height: 50%;
|
||||
}
|
||||
|
||||
.groupbtn {
|
||||
|
|
@ -760,6 +707,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
.active2 {
|
||||
color: #8284f0;
|
||||
font-weight: bold;
|
||||
background: #ecedff;
|
||||
}
|
||||
|
||||
.title2 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<text class="overflow">{{it.create_user_nickname}}</text>
|
||||
</view>
|
||||
<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>
|
||||
<text>{{it.likes_num}}</text>
|
||||
</view>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<view v-else class="content_box">
|
||||
<!-- 称重 -->
|
||||
<view class="blue-tooth">
|
||||
<blue-tooth :weightType="'2'" :btnType="'1'"></blue-tooth>
|
||||
<blue-tooth :btnType="'1'"></blue-tooth>
|
||||
</view>
|
||||
<!-- 每日摄入 -->
|
||||
<view class="box" v-if="user.aud_id!=''">
|
||||
|
|
|
|||
|
|
@ -44,7 +44,10 @@
|
|||
<view class="jishiqi">
|
||||
<view class="top">
|
||||
<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 class="left">
|
||||
<view class="chart-wrap">
|
||||
|
|
@ -167,7 +170,8 @@
|
|||
this.handTrue = false
|
||||
this.$nextTick(() => {
|
||||
this.handTrue = true
|
||||
that.chartData.series[0].data = this.user.aud_id != "" ? Number(this.user.food_count.nutrients_four[0].proportion) / 100 : 0
|
||||
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
|
||||
}
|
||||
|
|
@ -197,7 +201,8 @@
|
|||
that.handTrue = false
|
||||
this.$nextTick(() => {
|
||||
that.handTrue = true
|
||||
that.chartData.series[0].data = that.user.aud_id != ""?Number(that.user.food_count.nutrients_four[0].proportion) / 100:0
|
||||
that.chartData.series[0].data = that.user.aud_id != "" ? Number(that.user.food_count
|
||||
.nutrients_four[0].proportion) / 100 : 0
|
||||
})
|
||||
this.startWatching()
|
||||
},
|
||||
|
|
@ -405,11 +410,28 @@
|
|||
}
|
||||
|
||||
.detail {
|
||||
color: #fff;
|
||||
color: #3CB383;
|
||||
width: auto;
|
||||
padding: 5px 20px;
|
||||
background: $yellowcolor;
|
||||
border-radius: 10px;
|
||||
padding: 3px 10px;
|
||||
background: #fff;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<text class="overflow">{{it.create_user_nickname}}</text>
|
||||
</view>
|
||||
<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>
|
||||
<text>{{it.likes_num}}</text>
|
||||
</view>
|
||||
|
|
|
|||
|
|
@ -38,29 +38,29 @@
|
|||
</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="mic-icon" @touchstart="onVoiceTouchStart" @touchend="onVoiceTouchEnd">
|
||||
<uni-icons type="mic-filled" size="20" :color="mic_touch ? '#777777' : '#fff'"></uni-icons>
|
||||
<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="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>
|
||||
</template>
|
||||
|
||||
|
|
@ -76,7 +76,7 @@
|
|||
Page: 1,
|
||||
showAll: false,
|
||||
search_value: '',
|
||||
mic_touch: false,
|
||||
showAutoSearchDlg: false,
|
||||
voiceManager: null,
|
||||
};
|
||||
},
|
||||
|
|
@ -110,7 +110,7 @@
|
|||
},
|
||||
onVoiceTouchStart() {
|
||||
let that = this
|
||||
that.mic_touch = true
|
||||
that.showAutoSearchDlg = true
|
||||
that.voiceManager.start({
|
||||
duration: 60000,
|
||||
lang: "zh_CN"
|
||||
|
|
@ -118,12 +118,22 @@
|
|||
},
|
||||
onVoiceTouchEnd() {
|
||||
let that = this
|
||||
that.mic_touch = false
|
||||
that.showAutoSearchDlg = false
|
||||
that.voiceManager.stop()
|
||||
},
|
||||
// 取消录音
|
||||
cancelRecording() {
|
||||
// #ifdef MP-WEIXIN
|
||||
if (this.voiceManager) {
|
||||
this.voiceManager.stop()
|
||||
this.showAutoSearchDlg = false
|
||||
}
|
||||
// #endif
|
||||
},
|
||||
handlecolse() {
|
||||
console.log("取消搜索")
|
||||
this.search_value = ""
|
||||
this.search_list = []
|
||||
},
|
||||
// 历史搜索
|
||||
handleSearchHistory(text) {
|
||||
|
|
@ -302,7 +312,7 @@
|
|||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
bottom: 60px;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 999;
|
||||
|
||||
|
|
@ -312,53 +322,11 @@
|
|||
justify-content: space-between;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
width: 70%;
|
||||
height: 350rpx;
|
||||
padding: 80rpx 0;
|
||||
width: 50%;
|
||||
padding: 60rpx 0;
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,8 +133,7 @@ function getBLEDeviceCharacteristics(deviceId, serviceId) {
|
|||
notify = item.uuid
|
||||
}
|
||||
}
|
||||
|
||||
getBLECharacteristicValueChange(deviceId, serviceId, notify,write)
|
||||
getBLECharacteristicValueChange(deviceId, serviceId, notify, write)
|
||||
},
|
||||
fail: res => {
|
||||
console.log('获取特征值失败:', JSON.stringify(res))
|
||||
|
|
@ -142,7 +141,7 @@ function getBLEDeviceCharacteristics(deviceId, serviceId) {
|
|||
})
|
||||
}
|
||||
|
||||
function getBLECharacteristicValueChange(deviceId, serviceId, notify,write) {
|
||||
function getBLECharacteristicValueChange(deviceId, serviceId, notify, write) {
|
||||
let that = this
|
||||
uni.notifyBLECharacteristicValueChange({
|
||||
deviceId: deviceId,
|
||||
|
|
@ -160,6 +159,9 @@ function getBLECharacteristicValueChange(deviceId, serviceId, notify,write) {
|
|||
bleTipsText: "测量中,请将食物放到秤上",
|
||||
isConnectStatus: 0
|
||||
})
|
||||
const units = ['kg', '斤', 'st:lb', 'lb', 'g', 'ml', 'Waterml',
|
||||
'milkml', 'oz', 'floz', 'lboz'
|
||||
]
|
||||
uni.onBLECharacteristicValueChange(function(res) {
|
||||
const value = res.value
|
||||
const dataView = new DataView(value)
|
||||
|
|
@ -170,9 +172,6 @@ function getBLECharacteristicValueChange(deviceId, serviceId, notify,write) {
|
|||
|
||||
switch (cmd) {
|
||||
case 0x02:
|
||||
let units = ['kg', '斤', 'st:lb', 'lb', 'g', 'ml', 'Waterml',
|
||||
'milkml', 'oz', 'floz', 'lboz'
|
||||
]
|
||||
const statusByte = dataView.getUint8(4)
|
||||
const isNegative = !!(statusByte & 0x80) // 最高位表示正负
|
||||
const statusType = statusByte & 0x0F // 状态类型
|
||||
|
|
@ -300,6 +299,7 @@ export default {
|
|||
getBLEDeviceCharacteristics,
|
||||
closeBluetoothAdapter,
|
||||
closeBLEConnection,
|
||||
getBLECharacteristicValueChange,
|
||||
onBLEConnectionStateChange,
|
||||
stopBluetoothDevicesDiscovery
|
||||
}
|
||||
|
|
@ -161,6 +161,11 @@ export default {
|
|||
return res
|
||||
})
|
||||
},
|
||||
getAddEveryMealFood(param) { // 当次食材添加的卡路里摄入记录
|
||||
return http.post("/kitchenscale2/current_food_statistics", param).then(res => {
|
||||
return res
|
||||
})
|
||||
},
|
||||
getCountfootCon(param) { // 每日记食器板块详细内容
|
||||
return http.post("/kitchenscale2/get_countfoot_content", param).then(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
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
|
|
@ -503,6 +503,9 @@ page {
|
|||
.c999 {
|
||||
color: #999 !important;
|
||||
}
|
||||
.red {
|
||||
color: red !important;
|
||||
}
|
||||
.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
|
@ -1269,6 +1272,53 @@ page {
|
|||
height: 16rpx;
|
||||
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 */
|
||||
.content {
|
||||
display: flex;
|
||||
|
|
|
|||
|
|
@ -28446,6 +28446,12 @@ var _default = (_getonlogin$getSendCo = {
|
|||
return res;
|
||||
});
|
||||
},
|
||||
getAddEveryMealFood: function getAddEveryMealFood(param) {
|
||||
// 当次食材添加的卡路里摄入记录
|
||||
return _https.default.post("/kitchenscale2/current_food_statistics", param).then(function (res) {
|
||||
return res;
|
||||
});
|
||||
},
|
||||
getCountfootCon: function getCountfootCon(param) {
|
||||
// 每日记食器板块详细内容
|
||||
return _https.default.post("/kitchenscale2/get_countfoot_content", param).then(function (res) {
|
||||
|
|
@ -29252,6 +29258,7 @@ function getBLECharacteristicValueChange(deviceId, serviceId, notify, write) {
|
|||
bleTipsText: "测量中,请将食物放到秤上",
|
||||
isConnectStatus: 0
|
||||
});
|
||||
var units = ['kg', '斤', 'st:lb', 'lb', 'g', 'ml', 'Waterml', 'milkml', 'oz', 'floz', 'lboz'];
|
||||
uni.onBLECharacteristicValueChange(function (res) {
|
||||
var value = res.value;
|
||||
var dataView = new DataView(value);
|
||||
|
|
@ -29261,7 +29268,6 @@ function getBLECharacteristicValueChange(deviceId, serviceId, notify, write) {
|
|||
var cmd = dataView.getUint8(2);
|
||||
switch (cmd) {
|
||||
case 0x02:
|
||||
var units = ['kg', '斤', 'st:lb', 'lb', 'g', 'ml', 'Waterml', 'milkml', 'oz', 'floz', 'lboz'];
|
||||
var statusByte = dataView.getUint8(4);
|
||||
var isNegative = !!(statusByte & 0x80); // 最高位表示正负
|
||||
var statusType = statusByte & 0x0F; // 状态类型
|
||||
|
|
@ -29380,6 +29386,7 @@ var _default = {
|
|||
getBLEDeviceCharacteristics: getBLEDeviceCharacteristics,
|
||||
closeBluetoothAdapter: closeBluetoothAdapter,
|
||||
closeBLEConnection: closeBLEConnection,
|
||||
getBLECharacteristicValueChange: getBLECharacteristicValueChange,
|
||||
onBLEConnectionStateChange: onBLEConnectionStateChange,
|
||||
stopBluetoothDevicesDiscovery: stopBluetoothDevicesDiscovery
|
||||
};
|
||||
|
|
|
|||
|
|
@ -79,8 +79,11 @@ __webpack_require__.r(__webpack_exports__);
|
|||
var components
|
||||
try {
|
||||
components = {
|
||||
uniIcons: 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))
|
||||
uniPopup: function () {
|
||||
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) {
|
||||
|
|
@ -144,27 +147,31 @@ Object.defineProperty(exports, "__esModule", {
|
|||
value: true
|
||||
});
|
||||
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 _vuex = __webpack_require__(/*! vuex */ 30);
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
||||
var searchTimer = null;
|
||||
var _default = {
|
||||
data: function data() {
|
||||
return {
|
||||
dw: "g",
|
||||
kcal: "",
|
||||
weight: "",
|
||||
// weight: "",
|
||||
weightALL: "",
|
||||
msgText: "蓝牙连接中",
|
||||
unit: '',
|
||||
bleTipsText: "",
|
||||
unit: 'g',
|
||||
weight0: 0,
|
||||
devicesList: [],
|
||||
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']
|
||||
};
|
||||
},
|
||||
|
|
@ -174,52 +181,34 @@ var _default = {
|
|||
default: 0 //当前测量食物每g含的kcal
|
||||
},
|
||||
|
||||
weightType: {
|
||||
type: Number,
|
||||
default: -1 //0分类测量,1累计测量,2购物车测量
|
||||
},
|
||||
|
||||
isLast: {
|
||||
type: Boolean,
|
||||
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() {
|
||||
var that = this;
|
||||
if (that.bleValue.serviceId != "") {
|
||||
that.closeBLEConnection();
|
||||
that.closeBluetoothAdapter();
|
||||
that.openBluetoothAdapter();
|
||||
} else {
|
||||
that.openBluetoothAdapter();
|
||||
}
|
||||
that.onBLEConnectionStateChange();
|
||||
uni.onBluetoothAdapterStateChange(function (res) {
|
||||
that.$store.commit("changeBluetooth", res.available);
|
||||
});
|
||||
},
|
||||
destroyed: function destroyed() {
|
||||
this.$store.commit('changeBluetoothValue', {
|
||||
deviceId: "",
|
||||
serviceId: '',
|
||||
notify: '',
|
||||
write: "",
|
||||
unit: "g",
|
||||
oldCountWeight: 0,
|
||||
countWeight: 100,
|
||||
bleTipsText: "连接超时,点击重新连接",
|
||||
isConnectStatus: 1
|
||||
});
|
||||
this.isConnection = 1;
|
||||
this.closeBLEConnection();
|
||||
this.closeBluetoothAdapter();
|
||||
},
|
||||
watch: {
|
||||
// weightType: function() {
|
||||
// let that = this
|
||||
// that.openBluetoothAdapter()
|
||||
// },
|
||||
isBluetoothTyle: function isBluetoothTyle() {
|
||||
var that = this;
|
||||
if (!that.isBluetoothTyle) {
|
||||
|
|
@ -229,318 +218,78 @@ var _default = {
|
|||
isLast: function isLast() {
|
||||
var that = this;
|
||||
that.stopblue = that.isLast;
|
||||
console.log("最后", this.isLast);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 初始化蓝牙
|
||||
openBluetoothAdapter: function openBluetoothAdapter() {
|
||||
var that = this;
|
||||
that.weight = "";
|
||||
if (that.isConnection == 0) return;
|
||||
that.kcal = "";
|
||||
that.msgText = '蓝牙连接中';
|
||||
uni.openBluetoothAdapter({
|
||||
success: function success(e) {
|
||||
that.isConnection = 0;
|
||||
that.startBluetoothDeviceDiscovery();
|
||||
searchTimer = setTimeout(function () {
|
||||
uni.stopBluetoothDevicesDiscovery();
|
||||
if (!that.devicesList.length) {
|
||||
clearTimeout(searchTimer);
|
||||
that.isConnection = 1;
|
||||
}
|
||||
}, 30000); // 30秒超时
|
||||
that.$store.commit('changeBluetoothValue', {
|
||||
deviceId: "",
|
||||
serviceId: "",
|
||||
notify: '',
|
||||
write: '',
|
||||
unit: "g",
|
||||
countWeight: "",
|
||||
bleTipsText: "蓝牙搜索中",
|
||||
isConnectStatus: 0
|
||||
});
|
||||
that.$ble.openBluetoothAdapter();
|
||||
},
|
||||
|
||||
fail: function fail(e) {
|
||||
that.isConnection = 1;
|
||||
console.log('openBluetoothAdapter', e);
|
||||
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!");
|
||||
changleUnits: function changleUnits(e) {
|
||||
var that = this;
|
||||
var name = that.unitList[e.detail.value].name;
|
||||
console.log("单位切换", name, that.unit);
|
||||
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
|
||||
});
|
||||
},
|
||||
// 开始搜寻附近的蓝牙外围设备
|
||||
startBluetoothDeviceDiscovery: function startBluetoothDeviceDiscovery() {
|
||||
handletoggleUnit: function handletoggleUnit(unit) {
|
||||
var that = this;
|
||||
uni.startBluetoothDevicesDiscovery({
|
||||
allowDuplicatesKey: true,
|
||||
services: [
|
||||
// "F0A0",
|
||||
// "A5FE"
|
||||
],
|
||||
var checksum = 0;
|
||||
var bytes = [0xC5, 0x03, 0x05, 0x11];
|
||||
bytes[4] = unit;
|
||||
for (var i = 0; i < bytes.length; i++) {
|
||||
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) {
|
||||
that.isConnection = 0;
|
||||
that.onBluetoothDeviceFound();
|
||||
console.log('下发指令成功', res.errMsg);
|
||||
},
|
||||
fail: function fail(res) {
|
||||
that.isConnection = 1;
|
||||
console.log('startBluetoothDeviceDiscovery', res);
|
||||
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!");
|
||||
console.log("下发指令失败", res);
|
||||
}
|
||||
});
|
||||
},
|
||||
// 监听蓝牙连接状态
|
||||
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() {
|
||||
var that = this;
|
||||
console.log("weight", that.weight);
|
||||
console.log("测量保存", that.weight, that.unit, that.kcal);
|
||||
if (Number(that.weight) > 0) {
|
||||
that.$emit("handleBle", that.weight, that.dw, that.kcal);
|
||||
that.stopBluetoothDevicesDiscovery(); //取消蓝牙搜索
|
||||
that.closeBLEConnection();
|
||||
that.closeBluetoothAdapter();
|
||||
that.$emit("handleBle", that.weight, that.unit, that.kcal);
|
||||
} else {
|
||||
that.$tools.msg("数据异常,请清零后重新测量!");
|
||||
}
|
||||
|
|
@ -563,25 +312,8 @@ var _default = {
|
|||
// 备料完成
|
||||
handleDetailSub: function handleDetailSub() {
|
||||
var that = this;
|
||||
if (that.weightType == 1) {
|
||||
//累计测量
|
||||
// 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;
|
||||
if (Number(that.weight) > 0) {
|
||||
that.$emit("handleDetailSub", that.weight, that.unit, that.kcal);
|
||||
} else {
|
||||
that.$tools.msg("数据异常,请重新测量!");
|
||||
}
|
||||
|
|
@ -589,87 +321,48 @@ var _default = {
|
|||
//备料下一个
|
||||
handleDetailNext: function handleDetailNext() {
|
||||
var that = this;
|
||||
if (that.weightType == 1) {
|
||||
console.log('weight:' + that.weight);
|
||||
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;
|
||||
if (Number(that.weight) > 0) {
|
||||
that.$emit("handleDetailNext", that.weight, that.unit, that.kcal);
|
||||
} else {
|
||||
that.$tools.msg("数据异常,请清零后重新测量!");
|
||||
}
|
||||
},
|
||||
handlechongzhi: function handlechongzhi(weight) {
|
||||
var that = this;
|
||||
console.log('当前总重:' + that.weightALL);
|
||||
console.log('重置重量:' + weight);
|
||||
if (that.weightType == 1) {
|
||||
that.weightALL = Number((Number(that.weightALL) - Number(weight)).toFixed(2));
|
||||
console.log('剩余重量:' + that.weightALL);
|
||||
unitConversion: function unitConversion(unit) {
|
||||
if (unit == 'kcal') {
|
||||
return '千卡';
|
||||
} else if (unit == 'g') {
|
||||
return '克';
|
||||
} else if (unit == 'lb') {
|
||||
return '磅';
|
||||
} else if (unit == 'oz') {
|
||||
return '盎司';
|
||||
}
|
||||
return unit;
|
||||
},
|
||||
handleBack: function handleBack() {
|
||||
var that = this;
|
||||
that.isConnection = 1;
|
||||
that.stopBluetoothDevicesDiscovery(); //取消蓝牙搜索
|
||||
that.closeBLEConnection();
|
||||
that.closeBluetoothAdapter();
|
||||
},
|
||||
/**
|
||||
* 断开蓝牙模块
|
||||
*/
|
||||
closeBluetoothAdapter: function closeBluetoothAdapter() {
|
||||
var that = this;
|
||||
uni.closeBluetoothAdapter({
|
||||
success: function success(res) {
|
||||
console.log('蓝牙模块关闭成功');
|
||||
}
|
||||
that.$store.commit("changeBluetoothValue", {
|
||||
bleTipsText: "连接失败,点击重新连接",
|
||||
isConnectStatus: 1
|
||||
});
|
||||
that.$ble.stopBluetoothDevicesDiscovery(); //取消蓝牙搜索
|
||||
that.$ble.closeBLEConnection(that.bleValue.deviceId);
|
||||
that.$ble.closeBluetoothAdapter();
|
||||
},
|
||||
/**
|
||||
* 断开蓝牙连接
|
||||
*/
|
||||
closeBLEConnection: function closeBLEConnection() {
|
||||
var that = this;
|
||||
uni.closeBLEConnection({
|
||||
deviceId: that.deviceId,
|
||||
success: function success(res) {
|
||||
console.log('断开蓝牙连接成功');
|
||||
}
|
||||
confirm: function confirm(value) {
|
||||
console.log("手动输入", value);
|
||||
this.$store.commit("changeBluetoothValue", {
|
||||
countWeight: value,
|
||||
unit: this.unitList[this.unitListIndex].unit
|
||||
});
|
||||
} // 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
|
||||
// }
|
||||
this.$refs.popup.close();
|
||||
},
|
||||
close: function close() {
|
||||
this.$refs.popup.close();
|
||||
},
|
||||
inputDialogToggle: function inputDialogToggle() {
|
||||
this.$refs.popup.open();
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.default = _default;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"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
|
||||
}
|
||||
|
|
@ -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>
|
||||
|
|
@ -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;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.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;
|
||||
justify-content: space-around;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 40rpx;
|
||||
top: 120rpx;
|
||||
margin-top: 40rpx;
|
||||
left: 15px;
|
||||
right: 15px;
|
||||
bottom: 30rpx;
|
||||
top: 15px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.weightPages .weight.data-v-53fa6103 {
|
||||
background: #fff;
|
||||
|
|
@ -64,34 +80,65 @@
|
|||
font-size: 24rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.weightPages .btn.data-v-53fa6103 {
|
||||
color: #fff;
|
||||
width: 80%;
|
||||
margin-left: 10%;
|
||||
.weightPages .groupbtn.data-v-53fa6103 {
|
||||
margin-top: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.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%;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,6 +107,15 @@ var render = function () {
|
|||
var _vm = this
|
||||
var _h = _vm.$createElement
|
||||
var _c = _vm._self._c || _h
|
||||
var m0 = _vm.unitConversion(_vm.unit)
|
||||
_vm.$mp.data = Object.assign(
|
||||
{},
|
||||
{
|
||||
$root: {
|
||||
m0: m0,
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
var recyclableRender = false
|
||||
var staticRenderFns = []
|
||||
|
|
@ -158,6 +167,7 @@ var _default = {
|
|||
return {
|
||||
kcal: 0,
|
||||
unit: '',
|
||||
// weight: "",
|
||||
bleTipsText: "",
|
||||
inputDialog: false,
|
||||
unitList: [{
|
||||
|
|
@ -179,11 +189,6 @@ var _default = {
|
|||
default: 0 //当前测量食物每100g含的kcal
|
||||
},
|
||||
|
||||
weightType: {
|
||||
type: Number,
|
||||
default: -1 //0分类测量,1累计测量,2购物车测量
|
||||
},
|
||||
|
||||
btnType: {
|
||||
type: Number,
|
||||
default: 1 //1添加食材,2保存测量
|
||||
|
|
@ -193,7 +198,7 @@ var _default = {
|
|||
computed: _objectSpread(_objectSpread({}, (0, _vuex.mapState)(["bleValue", "isBluetoothTyle", "countFoodInfo"])), {}, {
|
||||
weight: function weight() {
|
||||
this.kcal = (Number(this.weightKcal) / 100 * this.bleValue.countWeight).toFixed(2);
|
||||
this.unit = this.unitConversion(this.bleValue.unit);
|
||||
this.unit = this.bleValue.unit;
|
||||
return this.bleValue.countWeight;
|
||||
},
|
||||
isConnection: function isConnection() {
|
||||
|
|
@ -338,27 +343,7 @@ var _default = {
|
|||
},
|
||||
close: function 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;
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -65,7 +65,7 @@ image.data-v-5fc22dca {
|
|||
background-color: #F8F8F8;
|
||||
}
|
||||
.weightPages .weight-wrap .weight .val.data-v-5fc22dca {
|
||||
font-size: 40rpx;
|
||||
font-size: 54rpx;
|
||||
color: #F0AE43;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
|
@ -77,17 +77,6 @@ image.data-v-5fc22dca {
|
|||
border-radius: 8rpx;
|
||||
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 {
|
||||
font-size: 24rpx;
|
||||
text-align: center;
|
||||
|
|
|
|||
|
|
@ -129,41 +129,42 @@ var render = function () {
|
|||
var g1 = !g0 ? _vm.history_food.length : null
|
||||
var g2 = !g0 && g1 ? _vm.history_food.length : null
|
||||
var g3 = !g0 && g1 && !_vm.showAll ? _vm.history_food.slice(0, 10) : null
|
||||
var g4 = _vm.search_list.length
|
||||
var g5 = _vm.isShop ? _vm.ActiveList.length : null
|
||||
var g6 =
|
||||
_vm.isShop && g5
|
||||
var g4 =
|
||||
_vm.ActiveList.filter(function (ite) {
|
||||
return ite.meals_type == _vm.foodName
|
||||
}).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) {
|
||||
return ite.meals_type == _vm.foodName
|
||||
}).length
|
||||
: null
|
||||
var l0 = _vm.IsWeight
|
||||
var l1 = _vm.IsWeight
|
||||
? _vm.__map(_vm.activeType.nutrients_four, function (item, index) {
|
||||
var $orig = _vm.__get_orig(item)
|
||||
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 {
|
||||
$orig: $orig,
|
||||
m0: m0,
|
||||
g7: g7,
|
||||
g8: g8,
|
||||
}
|
||||
})
|
||||
: null
|
||||
var g8 = _vm.IsWeight ? Math.floor(_vm.activeType.weight) : null
|
||||
var l1 = _vm.IsWeight
|
||||
var g9 = _vm.IsWeight ? Math.floor(_vm.activeType.weight) : null
|
||||
var l2 = _vm.IsWeight
|
||||
? _vm.__map(_vm.activeType.nutrients_list, function (item, index) {
|
||||
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 {
|
||||
$orig: $orig,
|
||||
g9: g9,
|
||||
g10: g10,
|
||||
}
|
||||
})
|
||||
: null
|
||||
var g10 =
|
||||
_vm.ActiveList.filter(function (ite) {
|
||||
return ite.meals_type == _vm.foodName
|
||||
}).length || 0
|
||||
if (!_vm._isMounted) {
|
||||
_vm.e0 = function ($event) {
|
||||
_vm.showAll = !_vm.showAll
|
||||
|
|
@ -179,13 +180,13 @@ var render = function () {
|
|||
_vm.isShop = false
|
||||
}
|
||||
_vm.e3 = function ($event) {
|
||||
_vm.IsWeight = false
|
||||
_vm.isShop = false
|
||||
}
|
||||
_vm.e4 = function ($event) {
|
||||
_vm.IsWeight = false
|
||||
}
|
||||
_vm.e5 = function ($event) {
|
||||
_vm.isShop = !_vm.isShop
|
||||
_vm.IsWeight = false
|
||||
}
|
||||
}
|
||||
_vm.$mp.data = Object.assign(
|
||||
|
|
@ -198,11 +199,12 @@ var render = function () {
|
|||
g3: g3,
|
||||
g4: g4,
|
||||
g5: g5,
|
||||
g6: g6,
|
||||
l0: l0,
|
||||
g8: g8,
|
||||
g6: g6,
|
||||
g7: g7,
|
||||
l1: l1,
|
||||
g10: g10,
|
||||
g9: g9,
|
||||
l2: l2,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
|
@ -248,7 +250,6 @@ Object.defineProperty(exports, "__esModule", {
|
|||
exports.default = void 0;
|
||||
var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ 11));
|
||||
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 _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");
|
||||
|
|
@ -270,13 +271,13 @@ var qiunDataCharts = function qiunDataCharts() {
|
|||
var _default = {
|
||||
data: function data() {
|
||||
return {
|
||||
opts: {
|
||||
background: "transparent",
|
||||
title: {
|
||||
name: ""
|
||||
}
|
||||
chartData: {
|
||||
series: [{
|
||||
data: 0,
|
||||
color: "#3CB383"
|
||||
}]
|
||||
},
|
||||
chartData: {},
|
||||
foodInfo: [],
|
||||
time: "",
|
||||
page: 1,
|
||||
foodName: "",
|
||||
|
|
@ -290,9 +291,7 @@ var _default = {
|
|||
search_value: '',
|
||||
ActiveList: [],
|
||||
activeType: {},
|
||||
mic_touch: false,
|
||||
voiceManager: null,
|
||||
autoSearchContent: "",
|
||||
showAutoSearchDlg: false
|
||||
};
|
||||
},
|
||||
|
|
@ -300,11 +299,11 @@ var _default = {
|
|||
popular_food: function popular_food() {
|
||||
return this.configInfo.search_guess.food_data;
|
||||
},
|
||||
history_food: function history_food() {
|
||||
return this.configInfo.search_history.food;
|
||||
},
|
||||
foodItem: function foodItem() {
|
||||
return this.configInfo.meal_list;
|
||||
},
|
||||
history_food: function history_food() {
|
||||
return this.configInfo.search_history.food;
|
||||
}
|
||||
}),
|
||||
components: {
|
||||
|
|
@ -349,25 +348,36 @@ var _default = {
|
|||
this.page++;
|
||||
this.handleSerach();
|
||||
},
|
||||
methods: (_methods = {
|
||||
methods: {
|
||||
// 开始录音
|
||||
onVoiceTouchStart: function onVoiceTouchStart() {
|
||||
var that = this;
|
||||
that.mic_touch = true;
|
||||
that.showAutoSearchDlg = true;
|
||||
that.isShop = false;
|
||||
that.voiceManager.start({
|
||||
duration: 60000,
|
||||
lang: "zh_CN"
|
||||
});
|
||||
},
|
||||
// 停止录音
|
||||
onVoiceTouchEnd: function onVoiceTouchEnd() {
|
||||
var that = this;
|
||||
that.mic_touch = false;
|
||||
that.showAutoSearchDlg = false;
|
||||
that.voiceManager.stop();
|
||||
},
|
||||
// 取消录音
|
||||
cancelRecording: function cancelRecording() {
|
||||
if (this.voiceManager) {
|
||||
this.voiceManager.stop();
|
||||
this.showAutoSearchDlg = false;
|
||||
}
|
||||
},
|
||||
// 购物车早午晚餐切换
|
||||
handleToggle: function handleToggle(name) {
|
||||
this.search_value = "";
|
||||
this.search_list = [];
|
||||
this.foodName = name;
|
||||
this.handleAddEveryMealFood();
|
||||
},
|
||||
//实时重量
|
||||
realTimeWeight: function realTimeWeight(weight, unit) {
|
||||
|
|
@ -405,9 +415,9 @@ var _default = {
|
|||
that.isBle = true;
|
||||
that.isShop = false;
|
||||
that.IsWeight = true;
|
||||
that.showAutoSearchDlg = false;
|
||||
that.activeType = ite;
|
||||
that.weightKcal = ite.kcal;
|
||||
console.log("111111", ite, that.bleValue);
|
||||
if (that.bleValue.serviceId != "") {
|
||||
that.realTimeWeight(that.bleValue.countWeight, that.bleValue.unit);
|
||||
} else {
|
||||
|
|
@ -416,22 +426,6 @@ var _default = {
|
|||
unit: "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.meals_type = that.foodName;
|
||||
list.push(that.activeType);
|
||||
console.log("list", list);
|
||||
that.$model.getAddIntakeFood({
|
||||
aud_id: that.user.aud_id,
|
||||
food_list: list,
|
||||
|
|
@ -459,12 +452,6 @@ var _default = {
|
|||
});
|
||||
}
|
||||
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) {
|
||||
that.ActiveList.push(that.activeType);
|
||||
} else {
|
||||
|
|
@ -472,16 +459,48 @@ var _default = {
|
|||
that.ActiveList[index].weight = that.activeType.weight;
|
||||
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() {
|
||||
var that = this;
|
||||
that.search_list = [];
|
||||
if (that.search_value == "") {
|
||||
that.$tools.msg("输入关键字后搜索");
|
||||
return;
|
||||
}
|
||||
that.search_list = [];
|
||||
that.$model.getFoodSearch({
|
||||
page: that.page,
|
||||
search_data: that.search_value
|
||||
|
|
@ -505,25 +524,16 @@ var _default = {
|
|||
handleSearchHistory: function handleSearchHistory(text) {
|
||||
var that = this;
|
||||
that.search_value = text;
|
||||
that.showAutoSearchDlg = false;
|
||||
that.handleSerach();
|
||||
}
|
||||
}, (0, _defineProperty2.default)(_methods, "onVoiceTouchStart", function onVoiceTouchStart() {
|
||||
var that = this;
|
||||
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) {
|
||||
},
|
||||
// 早午晚餐筛选
|
||||
changeClickType: function changeClickType(e) {
|
||||
this.search_value = "";
|
||||
this.search_list = [];
|
||||
this.foodName = this.foodItem[e.target.value].name;
|
||||
}), (0, _defineProperty2.default)(_methods, "handledelactive", function handledelactive(ite) {
|
||||
},
|
||||
//删除购物车食材
|
||||
handledelactive: function handledelactive(ite) {
|
||||
var _this = this;
|
||||
var that = this;
|
||||
uni.showModal({
|
||||
|
|
@ -543,11 +553,13 @@ var _default = {
|
|||
time: that.time
|
||||
});
|
||||
}
|
||||
that.handleAddEveryMealFood();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}), _methods)
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.default = _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
|
|
@ -226,7 +226,7 @@
|
|||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
bottom: 75px;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 999;
|
||||
}
|
||||
|
|
@ -236,49 +236,12 @@
|
|||
justify-content: space-between;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
width: 70%;
|
||||
height: 350rpx;
|
||||
padding: 80rpx 0;
|
||||
width: 50%;
|
||||
padding: 60rpx 0;
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx;
|
||||
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 {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
|
|
@ -553,56 +516,93 @@
|
|||
.wrapper .icon-error.data-v-d4f38c70 {
|
||||
position: absolute;
|
||||
right: 20rpx;
|
||||
top: -34rpx;
|
||||
top: -40rpx;
|
||||
background: #fff;
|
||||
font-size: 60rpx;
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
font-size: 80rpx;
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.wrapper .box2.data-v-d4f38c70 {
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 55%;
|
||||
top: 80rpx;
|
||||
bottom: 0;
|
||||
background-color: #fff;
|
||||
overflow: scroll;
|
||||
position: absolute;
|
||||
padding: 20rpx;
|
||||
padding-bottom: 90px;
|
||||
background-color: #dfdfdf;
|
||||
}
|
||||
.wrapper .box2 .left.data-v-d4f38c70 {
|
||||
width: 80px;
|
||||
background: #dfdfdf;
|
||||
.wrapper .box2 .jishiqi.data-v-d4f38c70 {
|
||||
width: calc(100% - 20px);
|
||||
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;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 75px;
|
||||
left: 10px;
|
||||
right: 10px;
|
||||
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;
|
||||
border-radius: 10px;
|
||||
flex-direction: column;
|
||||
}
|
||||
.wrapper .box2 .left view.data-v-d4f38c70 {
|
||||
.wrapper .box2 .box_list .left view.data-v-d4f38c70 {
|
||||
height: 25%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.wrapper .box2 .left .active.data-v-d4f38c70 {
|
||||
background-color: #fff;
|
||||
.wrapper .box2 .box_list .left .active.data-v-d4f38c70 {
|
||||
border-radius: 10px;
|
||||
background-color: #EDFFF4;
|
||||
color: #3CB383;
|
||||
}
|
||||
.wrapper .box2 .list.data-v-d4f38c70 {
|
||||
margin-bottom: 90px;
|
||||
width: calc(100% - 80px);
|
||||
margin-left: 80px;
|
||||
.wrapper .box2 .box_list .box_list_item.data-v-d4f38c70 {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
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%;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
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%;
|
||||
height: 45px;
|
||||
height: 50px;
|
||||
display: flex;
|
||||
padding: 5px 0;
|
||||
position: relative;
|
||||
|
|
@ -610,18 +610,18 @@
|
|||
justify-content: space-between;
|
||||
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);
|
||||
display: flex;
|
||||
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;
|
||||
height: 90rpx;
|
||||
border-radius: 50%;
|
||||
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);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
@ -632,14 +632,14 @@
|
|||
white-space: nowrap;
|
||||
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%;
|
||||
}
|
||||
.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;
|
||||
color: #999;
|
||||
}
|
||||
.wrapper .box2 .list .icon-ashbin.data-v-d4f38c70 {
|
||||
.wrapper .box2 .box_list .box_list_item .icon-ashbin.data-v-d4f38c70 {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 15px;
|
||||
|
|
|
|||
|
|
@ -277,6 +277,8 @@ var _default = {
|
|||
handleDetail: function handleDetail(ite, ind) {
|
||||
var that = this;
|
||||
var list = [];
|
||||
var pages = getCurrentPages();
|
||||
var prevPage = pages[pages.length - 2];
|
||||
if (ind == 1) {
|
||||
list.push(ite);
|
||||
that.ActiveList = that.$tools.mergeAndDeduplicate(that.ActiveList, list, 'name');
|
||||
|
|
@ -287,15 +289,16 @@ var _default = {
|
|||
}
|
||||
}
|
||||
}
|
||||
prevPage.$vm.getAddFood(that.ActiveList);
|
||||
},
|
||||
// 搜索
|
||||
handleSerach: function handleSerach() {
|
||||
var that = this;
|
||||
that.search_list = [];
|
||||
if (that.search_value == "") {
|
||||
that.$tools.msg("输入关键字后搜索");
|
||||
return;
|
||||
}
|
||||
that.search_list = [];
|
||||
that.$model.getFoodSearch({
|
||||
page: that.page,
|
||||
search_data: that.search_value
|
||||
|
|
@ -326,7 +329,7 @@ var _default = {
|
|||
// 开始说话
|
||||
onVoiceTouchStart: function onVoiceTouchStart() {
|
||||
var that = this;
|
||||
that.mic_touch = true;
|
||||
that.showAutoSearchDlg = true;
|
||||
that.voiceManager.start({
|
||||
duration: 60000,
|
||||
lang: "zh_CN"
|
||||
|
|
@ -335,9 +338,16 @@ var _default = {
|
|||
// 语音结束
|
||||
onVoiceTouchEnd: function onVoiceTouchEnd() {
|
||||
var that = this;
|
||||
that.mic_touch = false;
|
||||
that.showAutoSearchDlg = false;
|
||||
that.voiceManager.stop();
|
||||
},
|
||||
// 取消录音
|
||||
cancelRecording: function cancelRecording() {
|
||||
if (this.voiceManager) {
|
||||
this.voiceManager.stop();
|
||||
this.showAutoSearchDlg = false;
|
||||
}
|
||||
},
|
||||
// 购物车提交
|
||||
handlesubbtn: function handlesubbtn() {
|
||||
var that = this;
|
||||
|
|
@ -351,6 +361,9 @@ var _default = {
|
|||
//删除购物车食材
|
||||
handledelactive: function handledelactive(ite) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -220,7 +220,7 @@
|
|||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
bottom: 75px;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 999;
|
||||
}
|
||||
|
|
@ -230,49 +230,12 @@
|
|||
justify-content: space-between;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
width: 70%;
|
||||
height: 350rpx;
|
||||
padding: 80rpx 0;
|
||||
width: 50%;
|
||||
padding: 60rpx 0;
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx;
|
||||
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 {
|
||||
z-index: 12;
|
||||
bottom: 200rpx;
|
||||
|
|
@ -299,14 +262,14 @@
|
|||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 20rpx 40rpx;
|
||||
padding: 0 20rpx;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
bottom: 0rpx;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 90px;
|
||||
z-index: 99;
|
||||
flex-wrap: wrap;
|
||||
height: 60px;
|
||||
padding-bottom: 15px;
|
||||
z-index: 15;
|
||||
background-color: #fff;
|
||||
overflow: hidden;
|
||||
box-shadow: 0px 1px 5px 2px #dfe2e1fc;
|
||||
|
|
@ -321,7 +284,7 @@
|
|||
background-color: #f0ae43;
|
||||
}
|
||||
.groupbtn .jilu.data-v-c58b4fba {
|
||||
width: 100%;
|
||||
width: 110px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
|
@ -359,7 +322,7 @@
|
|||
}
|
||||
.mic-icon.data-v-c58b4fba {
|
||||
color: #fff;
|
||||
width: 100%;
|
||||
width: calc(100% - 120px);
|
||||
padding: 8px 0;
|
||||
background: #3CB383;
|
||||
display: flex;
|
||||
|
|
|
|||
|
|
@ -104,7 +104,16 @@ var render = function () {
|
|||
var _c = _vm._self._c || _h
|
||||
var g0 = _vm.info.tags && _vm.info.tags[_vm.index].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
|
||||
return {
|
||||
$orig: $orig,
|
||||
g2: g2,
|
||||
}
|
||||
})
|
||||
: null
|
||||
if (!_vm._isMounted) {
|
||||
_vm.e0 = function ($event) {
|
||||
_vm.isBle = false
|
||||
|
|
@ -129,7 +138,7 @@ var render = function () {
|
|||
$root: {
|
||||
g0: g0,
|
||||
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 _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() {
|
||||
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));
|
||||
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
|
||||
};
|
||||
|
|
@ -189,6 +198,7 @@ var _default = {
|
|||
info: {},
|
||||
id: null,
|
||||
index: 0,
|
||||
isLast: false,
|
||||
weightKcal: null,
|
||||
weightType: 0,
|
||||
activeType: {},
|
||||
|
|
@ -196,14 +206,13 @@ var _default = {
|
|||
isWeightType: true,
|
||||
iSWeightSub: true,
|
||||
listInd: 0,
|
||||
isLast: false,
|
||||
cookIndex: null,
|
||||
showSaveFood: false,
|
||||
saveFoodTypes: ['早餐', '午餐', '晚餐', '加餐'],
|
||||
selectSaveType: 0
|
||||
};
|
||||
},
|
||||
computed: _objectSpread(_objectSpread({}, (0, _vuex.mapState)(["user", "configInfo"])), {}, {
|
||||
computed: _objectSpread(_objectSpread({}, (0, _vuex.mapState)(["user", "configInfo", "bleValue"])), {}, {
|
||||
menu: function menu() {
|
||||
return this.configInfo.cookbook_label;
|
||||
},
|
||||
|
|
@ -241,6 +250,9 @@ var _default = {
|
|||
that.cookIndex = that.menu.findIndex(function (ite) {
|
||||
return ite.id == res.data.cook_label;
|
||||
});
|
||||
if (that.bleValue.serviceId != '') {
|
||||
that.handleWeight();
|
||||
}
|
||||
});
|
||||
},
|
||||
//连接测量
|
||||
|
|
@ -249,12 +261,16 @@ var _default = {
|
|||
if (that.isBle) {
|
||||
return;
|
||||
}
|
||||
that.listInd = 0;
|
||||
that.isBle = true;
|
||||
that.isLast = false;
|
||||
that.activeType = {};
|
||||
that.iSWeightSub = true;
|
||||
that.isWeightType = true;
|
||||
that.handleWeightType(0); //默认分类测量,取消累计测量
|
||||
that.isWeightType = false;
|
||||
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) {
|
||||
|
|
@ -275,6 +291,7 @@ var _default = {
|
|||
that.isLast = true;
|
||||
console.log('已经测量完成');
|
||||
}
|
||||
console.log("下一位", that.activeType);
|
||||
},
|
||||
// 结束测量
|
||||
handleDetailSub: function handleDetailSub(weight, dw, kcal) {
|
||||
|
|
@ -295,29 +312,14 @@ var _default = {
|
|||
that.listInd = ind;
|
||||
that.isLast = false;
|
||||
that.activeType = ite;
|
||||
that.iSWeightSub = true;
|
||||
that.isWeightType = false;
|
||||
that.weightKcal = Number(Number(that.activeType.kcal) / 100).toFixed(2);
|
||||
that.weightKcal = Number(Number(ite.kcal) / 100).toFixed(2);
|
||||
that.info.tags[0].list[ind].newweight = "";
|
||||
that.info.tags[0].list[ind].newunit = "";
|
||||
that.info.tags[0].list[ind].newkcal = "";
|
||||
if (that.listInd == that.info.tags[0].list.length - 1 || that.listInd == that.info.tags[0].list.length) {
|
||||
that.isLast = true;
|
||||
}
|
||||
this.$refs.blueTooth.handlechongzhi(weight);
|
||||
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;
|
||||
}
|
||||
console.log("重置", ite);
|
||||
},
|
||||
//保存测量结果到计时器
|
||||
confirmSaveFood: function confirmSaveFood() {
|
||||
|
|
@ -329,7 +331,7 @@ var _default = {
|
|||
meals_type: that.saveFoodTypes[that.selectSaveType],
|
||||
id: that.info.tags[0].list[i].id,
|
||||
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: '保存成功',
|
||||
icon: 'success'
|
||||
});
|
||||
uni.switchTab({
|
||||
url: "/pages/count/count"
|
||||
});
|
||||
});
|
||||
}
|
||||
that.showSaveFood = false;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -188,99 +188,64 @@
|
|||
width: 100%;
|
||||
}
|
||||
.weightBox.data-v-4a383a52 {
|
||||
top: 64rpx;
|
||||
height: auto;
|
||||
border-radius: 0;
|
||||
top: 40px;
|
||||
background: #dfdfdf;
|
||||
}
|
||||
.weightBox .table.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;
|
||||
.weightBox .icon-error.data-v-4a383a52 {
|
||||
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 {
|
||||
border-radius: 0;
|
||||
height: 40%;
|
||||
overflow: scroll;
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
margin-top: 30rpx;
|
||||
font-size: 14px;
|
||||
}
|
||||
.weightBox .foodlist .text.data-v-4a383a52 {
|
||||
width: 100%;
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
}
|
||||
.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%;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.weightBox .foodlist .item.data-v-4a383a52 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
font-size: 16px;
|
||||
}
|
||||
.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;
|
||||
font-size: 28rpx;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.weightBox .foodlist .name.data-v-4a383a52 {
|
||||
width: auto;
|
||||
float: left;
|
||||
font-size: 24rpx;
|
||||
font-weight: 500;
|
||||
width: 28% !important;
|
||||
width: calc(30% - 10px);
|
||||
text-align: left !important;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
font-weight: inherit;
|
||||
font-size: 28rpx;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.weightBox .title.data-v-4a383a52 {
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
margin-top: 20rpx;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
bottom: 20rpx;
|
||||
top: 50%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
.weightBox .foodlist .kcal.data-v-4a383a52 {
|
||||
width: 52% !important;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.weightBox .title.data-v-4a383a52 .weightPages {
|
||||
top: 30rpx;
|
||||
display: block;
|
||||
.weightBox .blue-tooth.data-v-4a383a52 {
|
||||
background: #fff;
|
||||
border-radius: 10px;
|
||||
margin-top: 15px;
|
||||
position: relative;
|
||||
height: 50%;
|
||||
}
|
||||
.weightBox .groupbtn.data-v-4a383a52 {
|
||||
position: absolute;
|
||||
|
|
@ -351,6 +316,11 @@
|
|||
.saveFood .saveFoodInner .btn-wrap view.data-v-4a383a52:first-child {
|
||||
border-right: 1px solid #f1f1f1;
|
||||
}
|
||||
.active2.data-v-4a383a52 {
|
||||
color: #8284f0;
|
||||
font-weight: bold;
|
||||
background: #ecedff;
|
||||
}
|
||||
.title2.data-v-4a383a52 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
|
|||
|
|
@ -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
|
|
@ -150,11 +150,25 @@
|
|||
font-weight: bold;
|
||||
}
|
||||
.jishiqi .detail.data-v-57280228 {
|
||||
color: #fff;
|
||||
color: #3CB383;
|
||||
width: auto;
|
||||
padding: 5px 20px;
|
||||
background: #F7931E;
|
||||
border-radius: 10px;
|
||||
padding: 3px 10px;
|
||||
background: #fff;
|
||||
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 {
|
||||
width: 100rpx;
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -202,7 +202,7 @@ var _default = {
|
|||
Page: 1,
|
||||
showAll: false,
|
||||
search_value: '',
|
||||
mic_touch: false,
|
||||
showAutoSearchDlg: false,
|
||||
voiceManager: null
|
||||
};
|
||||
},
|
||||
|
|
@ -233,7 +233,7 @@ var _default = {
|
|||
},
|
||||
onVoiceTouchStart: function onVoiceTouchStart() {
|
||||
var that = this;
|
||||
that.mic_touch = true;
|
||||
that.showAutoSearchDlg = true;
|
||||
that.voiceManager.start({
|
||||
duration: 60000,
|
||||
lang: "zh_CN"
|
||||
|
|
@ -241,12 +241,20 @@ var _default = {
|
|||
},
|
||||
onVoiceTouchEnd: function onVoiceTouchEnd() {
|
||||
var that = this;
|
||||
that.mic_touch = false;
|
||||
that.showAutoSearchDlg = false;
|
||||
that.voiceManager.stop();
|
||||
},
|
||||
// 取消录音
|
||||
cancelRecording: function cancelRecording() {
|
||||
if (this.voiceManager) {
|
||||
this.voiceManager.stop();
|
||||
this.showAutoSearchDlg = false;
|
||||
}
|
||||
},
|
||||
handlecolse: function handlecolse() {
|
||||
console.log("取消搜索");
|
||||
this.search_value = "";
|
||||
this.search_list = [];
|
||||
},
|
||||
// 历史搜索
|
||||
handleSearchHistory: function handleSearchHistory(text) {
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -166,7 +166,7 @@
|
|||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
bottom: 60px;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 999;
|
||||
}
|
||||
|
|
@ -176,49 +176,12 @@
|
|||
justify-content: space-between;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
width: 70%;
|
||||
height: 350rpx;
|
||||
padding: 80rpx 0;
|
||||
width: 50%;
|
||||
padding: 60rpx 0;
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx;
|
||||
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 {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
|
|
|
|||
Loading…
Reference in New Issue