ru--guo 3 months ago
parent f2e4e09fda
commit eabe9ee144

@ -1 +0,0 @@
Subproject commit 8bf8671abfd7e034c559507dd85b7918b3d4666f

@ -0,0 +1,14 @@
# Windows
[Dd]esktop.ini
Thumbs.db
$RECYCLE.BIN/
# macOS
.DS_Store
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
# Node.js
node_modules/

@ -0,0 +1,55 @@
import Init from '/utils/init.js'
//app.js
App({
/**
* 页面的初始数据
*/
data: {
...Init.data,},
onLaunch: function () {
wx.getSystemInfo({
success: e => {
this.globalData.StatusBar = e.statusBarHeight;
let custom = wx.getMenuButtonBoundingClientRect();
this.globalData.Custom = custom;
this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
}
})
Init.init(true);//初始化meal
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})
},
globalData: {
userInfo: null
},
})

@ -0,0 +1,68 @@
{
"pages": [
"pages/index/index",
"pages/shop/shop",
"pages/build/build",
"pages/search/search",
"pages/search-food/search",
"pages/details/details",
"pages/confirmOrder/confirmOrder",
"pages/user/home",
"pages/diary/diary",
"pages/home/home",
"pages/logs/logs",
"pages/meals/index",
"pages/foods/index",
"pages/searchresult/searchresult",
"pages/body/body",
"pages/calendar/calendar",
"pages/help/help",
"pages/mode/mode",
"pages/Recipe_details/index"
],
"window": {
"navigationStyle": "custom"
},
"usingComponents": {
"cu-custom": "/colorui/components/cu-custom"
},
"tabBar": {
"backgroundColor": "#fff",
"selectedColor": "#0e9eda",
"color": "#8a8a8a",
"list": [
{
"pagePath": "pages/index/index",
"text": "搜索",
"iconPath": "images/search.png",
"selectedIconPath": "images/search-blue.png"
},
{
"pagePath": "pages/build/build",
"text": "制作",
"iconPath": "images/build.png",
"selectedIconPath": "images/build-active.png"
},
{
"pagePath": "pages/diary/diary",
"text": "日记",
"iconPath": "images/diary.png",
"selectedIconPath": "images/diary-active.png"
},
{
"pagePath": "pages/shop/shop",
"text": "推荐",
"iconPath": "images/shop.png",
"selectedIconPath": "images/shop-active.png"
},
{
"pagePath": "pages/user/home",
"text": "用户",
"iconPath": "images/self.png",
"selectedIconPath": "images/self-active.png"
}
]
},
"sitemapLocation": "sitemap.json"
}

@ -0,0 +1,31 @@
@import 'weui.wxss';
@import 'common.wxss';
@import "colorui/main.wxss";
@import "colorui/icon.wxss";
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
.bc_red{
background-color:dodgerblue;
}
.bc_white{
background-color: #ffffff;
}
.new_padd{
padding: 0rpx 30rpx 15rpx 30rpx;
}
.color_white{
color: #fff;
}
.bg_white{
color:#ffffff;
}

@ -0,0 +1,184 @@
/*
Animation 微动画
基于ColorUI组建库的动画模块 by 文晓港 2019年3月26日19:52:28
*/
/* css 滤镜 控制黑白底色gif的 */
.gif-black{
mix-blend-mode: screen;
}
.gif-white{
mix-blend-mode: multiply;
}
/* Animation css */
[class*=animation-] {
animation-duration: .5s;
animation-timing-function: ease-out;
animation-fill-mode: both
}
.animation-fade {
animation-name: fade;
animation-duration: .8s;
animation-timing-function: linear
}
.animation-scale-up {
animation-name: scale-up
}
.animation-scale-down {
animation-name: scale-down
}
.animation-slide-top {
animation-name: slide-top
}
.animation-slide-bottom {
animation-name: slide-bottom
}
.animation-slide-left {
animation-name: slide-left
}
.animation-slide-right {
animation-name: slide-right
}
.animation-shake {
animation-name: shake
}
.animation-reverse {
animation-direction: reverse
}
@keyframes fade {
0% {
opacity: 0
}
100% {
opacity: 1
}
}
@keyframes scale-up {
0% {
opacity: 0;
transform: scale(.2)
}
100% {
opacity: 1;
transform: scale(1)
}
}
@keyframes scale-down {
0% {
opacity: 0;
transform: scale(1.8)
}
100% {
opacity: 1;
transform: scale(1)
}
}
@keyframes slide-top {
0% {
opacity: 0;
transform: translateY(-100%)
}
100% {
opacity: 1;
transform: translateY(0)
}
}
@keyframes slide-bottom {
0% {
opacity: 0;
transform: translateY(100%)
}
100% {
opacity: 1;
transform: translateY(0)
}
}
@keyframes shake {
0%,
100% {
transform: translateX(0)
}
10% {
transform: translateX(-9px)
}
20% {
transform: translateX(8px)
}
30% {
transform: translateX(-7px)
}
40% {
transform: translateX(6px)
}
50% {
transform: translateX(-5px)
}
60% {
transform: translateX(4px)
}
70% {
transform: translateX(-3px)
}
80% {
transform: translateX(2px)
}
90% {
transform: translateX(-1px)
}
}
@keyframes slide-left {
0% {
opacity: 0;
transform: translateX(-100%)
}
100% {
opacity: 1;
transform: translateX(0)
}
}
@keyframes slide-right {
0% {
opacity: 0;
transform: translateX(100%)
}
100% {
opacity: 1;
transform: translateX(0)
}
}

@ -0,0 +1,54 @@
const app = getApp();
Component({
/**
* 组件的一些选项
*/
options: {
addGlobalClass: true,
multipleSlots: true
},
/**
* 组件的对外属性
*/
properties: {
bgColor: {
type: String,
default: ''
},
isCustom: {
type: [Boolean, String],
default: false
},
isBack: {
type: [Boolean, String],
default: false
},
bgImage: {
type: String,
default: ''
},
},
/**
* 组件的初始数据
*/
data: {
StatusBar: app.globalData.StatusBar,
CustomBar: app.globalData.CustomBar,
Custom: app.globalData.Custom
},
/**
* 组件的方法列表
*/
methods: {
BackPage() {
wx.navigateBack({
delta: 1
});
},
toHome(){
wx.reLaunch({
url: '/pages/index/index',
})
}
}
})

@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

@ -0,0 +1,16 @@
<view class="cu-custom" style="height:{{CustomBar}}px">
<view class="cu-bar fixed {{bgImage!=''?'none-bg text-white bg-img':''}} {{bgColor}}" style="height:{{CustomBar}}px;padding-top:{{StatusBar}}px;{{bgImage?'background-image:url(' + bgImage+')':''}}">
<view class="action" bindtap="BackPage" wx:if="{{isBack}}">
<text class="cuIcon-back"></text>
<slot name="backText"></slot>
</view>
<view class="action border-custom" wx:if="{{isCustom}}" style="width:{{Custom.width}}px;height:{{Custom.height}}px;margin-left:calc(750rpx - {{Custom.right}}px)">
<text class="cuIcon-back" bindtap="BackPage"></text>
<text class="cuIcon-homefill" bindtap="toHome"></text>
</view>
<view class="content" style="top:{{StatusBar}}px">
<slot name="content"></slot>
</view>
<slot name="right"></slot>
</view>
</view>

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

@ -0,0 +1,34 @@
/*icon图标 */
@font-face {
font-family: 'iconfont';
src: url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAXcAA0AAAAACFgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAFwAAAABoAAAAcf7+j60dERUYAAAWkAAAAHAAAAB4AJwAMT1MvMgAAAaAAAABCAAAAVlbmSABjbWFwAAAB/AAAAE4AAAFKy8chmmdhc3AAAAWcAAAACAAAAAj//wADZ2x5ZgAAAlwAAAHLAAACLGyxjtFoZWFkAAABMAAAADAAAAA2DrhOw2hoZWEAAAFgAAAAHQAAACQH0gOGaG10eAAAAeQAAAAWAAAAFg1MADZsb2NhAAACTAAAAA4AAAAOAYwAvm1heHAAAAGAAAAAHwAAACABFQBdbmFtZQAABCgAAAFJAAACiCnmEVVwb3N0AAAFdAAAACgAAAA7ElgeUHicY2BkYGAA4jNbVWvj+W2+MnCzMIDA1bOtSXCa638P8xfmMiCXg4EJJAoATAQL9XicY2BkYGBu+N/AEMPCAALMXxgYGVABKwBZEwNhAAAAeJxjYGRgYGBjCGRgZQABJiDmAkIGhv9gPgMAEUgBcwB4nGNgZP7BOIGBlYGBqZPpDAMDQz+EZnzNYMTIARRlYGVmwAoC0lxTGBwYKp6JMTf8b2CIYW5gaAAKM4LkACKWDHoAAAQAAAAAAAAAAVUAAAPpACwEAAAKAA4AAHicY2BgYGaAYBkGRgYQcAHyGMF8FgYNIM0GpBkZmBgqnon9/w/kVzwT/f//f7fke6h6IGBkY4BzGJmABBMDKmBkoBlgpp3RJAEAQpQKSAAAAAAAAAAAAAAAdgC+ARYAAHicfZC/btNQFMbPuTfXsXMdp7Hj/00Tx9QGtUQiccNQtR1g4c9QiYmRBwCkDu3C0AWJoUN5BYTEA2TtlOQNnEgMLAiidmRgtG64JsDI1dHV90m/o/OdAwx2V1/pFfXAgttwDx7CMQAqO9gzSBujNOuTHbQjZrstg6ZxGlXjXp8eoNtTWs5glCWuUlUaaOAWDqPBKO2TFPeyQ7KPA6eN6IfBM3N706SXWPPSrbfiMfmAdifebBzeFY92j1qDrqWe6abpm+aFqjCmElJpGPjSdTSm1RTxkTUC+6pzh3RQ99Pg6fN6NzRfvMtetbddDfH8HK2wa3w6agZNWW8CxzL96kZd9YJ6fKuFZ9+5Z+nt5BvIR6G2uqA/6SlwcCEu94SqA+4I7idAE0ilkFYBKyq3K/fJElzNxVJRMJwvMGRMLBdTUTCGlekMK9IXTLxWdV3F9/KnpyWwEEsJhAvZUDyQ5OwPOZuJAr9wk8ta5zFWl/QHPfmdZ/ifPPFelvSUNsZlrn20y9Mf4HCdLxc3Mp+Xz9GTU27mEyHkeDKZIpFeVMa8ycca59pfQU+YuM5zcS0xP8/RL56U/GTNT2Q/fh6rnKtjfUP/J+AXSs57JgB4nH2QPU4DMRCFn/MHJBJCIKhdUQDa/JQpEyn0CKWjSDbekGjXXnmdSDkBLRUHoOUYHIAbINFyCl6WSZMia+3o85uZ57EBnOMbCv/fJe6EFY7xKFzBETLhKvUX4Rr5XbiOFj6FG9R/hJu4VQPhFi7UGx1U7YS7m9JtywpnGAhXcIon4Sr1lXCN/CpcxxU+hBvUv4SbGONXuIVrZakM4WEwQWCcQWOKDeMCMRwskjIG1qE59GYSzExPN3oRO5s4GyjvV2KXAx5oOeeAKe09t2a+Sif+YMuB1JhuHgVLtimNLiJ0KBtfLJzV3ahzsP2e7ba02L9rgTXH7FENbNT8Pdsz0khsDK+QkjXyMrekElOPaGus8btnKdbzXgiJTrzL9IjHmjR1OvduaeLA4ufyjBx9tLmSPfeoHD5jWQh5v91OxCCKXYY/k9hxGQAAAHicY2BigAAuBuyADYgZGZgYohmZGJnZcjPzSouNWAtySosNASgNBNYAAAAB//8AAnicY2BkYGDgAWIxIGZiYARCViBmAfMYAAPVADR4nGNgYGBkAIIrKjPVQPTVs61JMBoAQ08GywAA) format('woff'),
url('iconfont.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
.iconfont {
font-family:"iconfont" !important;
font-size:16px;
font-style:normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-minus2:before { content: "\e615"; }
.icon-plus1:before { content: "\e616"; }
/*公共头部 */
.posi_fiexd {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 100;
}
/*店铺图片圆角 */
.bd_radius {
border-radius: 50%;
}

@ -0,0 +1,244 @@
// components/calendar/calendar.js
/**
* 日历选择组件
* 2018-03-04
* mehaotian
* github https://github.com/mehaotian
*/
Component({
/**
* 组件的属性列表
* data [Date] 当前现实的月份
* selected [Array] 所有被选择的天
*/
properties: {
date: {
type: null,
value: new Date()
},
selected: {
type: Array,
value: [],
observer(newVal, oldVal) {
this.getWeek(new Date())
}
},
isOpen: {
type: Boolean,
value: false,
}
},
/**
* 组件的初始数据
*/
data: {
calShow: true, // 日历组件是否打开
dateShow: false, // 日期是否选择
selectDay: '', // 当前选择日期
canlender: {
"weeks": []
}
},
ready() {
this.getWeek(new Date())
if (this.data.isOpen) {
this.setData({
calShow: false,
dateShow: true
})
}
},
/**
* 组件的方法列表
*/
methods: {
dateSelection() {
if (this.data.isOpen) {
return
}
let self = this;
if (self.data.calShow) {
self.setData({
calShow: false
}, () => {
setTimeout(() => {
self.setData({
dateShow: true
}, () => {
self.triggerEvent('select', { ischeck: !self.data.calShow })
})
}, 100)
})
} else {
self.setData({
dateShow: false
}, () => {
setTimeout(() => {
self.setData({
calShow: true
}, () => {
self.triggerEvent('select', { ischeck: !self.data.calShow })
})
}, 300)
})
}
},
selectDay(e) {
let index = e.currentTarget.dataset.index;
let week = e.currentTarget.dataset.week;
let ischeck = e.currentTarget.dataset.ischeck;
let canlender = this.data.canlender;
if (!ischeck) return false;
let month = canlender.weeks[week][index].month < 10 ? "0" + canlender.weeks[week][index].month : canlender.weeks[week][index].month
let date = canlender.weeks[week][index].date < 10 ? "0" + canlender.weeks[week][index].date : canlender.weeks[week][index].date
this.getWeek(canlender.year + "-" + month + "-" + date);
},
packup() {
let self = this;
if (this.data.isOpen) {
let year = self.data.canlender.year + "-" + self.data.canlender.month + "-" + self.data.canlender.date
let _date = self.getDate(year, 0);
self.getWeek(_date);
return
}
self.setData({
dateShow: false
}, () => {
setTimeout(() => {
self.setData({
calShow: true
}, () => {
let year = self.data.canlender.year + "-" + self.data.canlender.month + "-" + self.data.canlender.date
let _date = self.getDate(year, 0);
self.getWeek(_date);
self.triggerEvent('select', { ischeck: !self.data.calShow })
})
}, 300)
})
},
// 返回今天
backtoday() { this.getWeek(new Date()); },
// 前一天|| 后一天
dataBefor(e) {
let num = 0;
let types = e.currentTarget.dataset.type;
if (e.currentTarget.dataset.id === "0") {
num = -1;
} else {
num = 1
}
let year = this.data.canlender.year + "-" + this.data.canlender.month + "-" + this.data.canlender.date
let _date = this.getDate(year, num, types === 'month' ? "month" : "day");
this.getWeek(_date);
},
// 获取日历内容
getWeek(dateData) {
let selected = this.data.selected
let a = new Date()
// console.log("im date ", a, typeof a === 'object')
// 判断当前是 安卓还是ios ,传入不容的日期格式
if (typeof dateData !== 'object') {
dateData = dateData.replace(/-/g, "/")
}
let _date = new Date(dateData);
let year = _date.getFullYear(); //年
let month = _date.getMonth() + 1; //月
let date = _date.getDate();//日
let day = _date.getDay();// 天
let canlender = [];
// console.log(selected)
let dates = {
firstDay: new Date(year, month - 1, 1).getDay(),
lastMonthDays: [],// 上个月末尾几天
currentMonthDys: [], // 本月天数
nextMonthDays: [], // 下个月开始几天
endDay: new Date(year, month, 0).getDay(),
weeks: []
}
// 循环上个月末尾几天添加到数组
for (let i = dates.firstDay; i > 0; i--) {
dates.lastMonthDays.push({
'date': new Date(year, month, -i).getDate() + '',
'month': month - 1
})
}
// 循环本月天数添加到数组
for (let i = 1; i <= new Date(year, month, 0).getDate(); i++) {
let have = false;
for (let j = 0; j < selected.length; j++) {
let selDate = selected[j].date.split('-');
if (Number(year) === Number(selDate[0]) && Number(month) === Number(selDate[1]) && Number(i) === Number(selDate[2])) {
have = true;
}
}
dates.currentMonthDys.push({
'date': i + "",
'month': month,
have
})
}
// 循环下个月开始几天 添加到数组
for (let i = 1; i < 7 - dates.endDay; i++) {
dates.nextMonthDays.push({
'date': i + '',
'month': month + 1
})
}
canlender = canlender.concat(dates.lastMonthDays, dates.currentMonthDys, dates.nextMonthDays)
// 拼接数组 上个月开始几天 + 本月天数+ 下个月开始几天
for (let i = 0; i < canlender.length; i++) {
if (i % 7 == 0) {
dates.weeks[parseInt(i / 7)] = new Array(7);
}
dates.weeks[parseInt(i / 7)][i % 7] = canlender[i]
}
// 渲染数据
this.setData({
selectDay: month + "月" + date + "日",
"canlender.weeks": dates.weeks,
'canlender.month': month,
'canlender.date': date,
"canlender.day": day,
'canlender.year': year,
})
month = month < 10 ? "0" + month : month
date = date < 10 ? "0" + date : date
this.triggerEvent('getdate', { year, month, date })
},
/**
* 时间计算
*/
getDate(date, AddDayCount, str = 'day') {
if (typeof date !== 'object') {
date = date.replace(/-/g, "/")
}
let dd = new Date(date)
switch (str) {
case 'day':
dd.setDate(dd.getDate() + AddDayCount)// 获取AddDayCount天后的日期
break;
case 'month':
dd.setMonth(dd.getMonth() + AddDayCount)// 获取AddDayCount天后的日期
break;
case 'year':
dd.setFullYear(dd.getFullYear() + AddDayCount)// 获取AddDayCount天后的日期
break;
}
let y = dd.getFullYear()
let m = (dd.getMonth() + 1) < 10 ? '0' + (dd.getMonth() + 1) : (dd.getMonth() + 1)// 获取当前月份的日期不足10补0
let d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate()// 获取当前几号不足10补0
return y + '-' + m + '-' + d
}
}
})

@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

@ -0,0 +1,59 @@
<view class="header">
<view class="iconfont" data-id="0" bindtap='dataBefor'>
<image class='iconimage' src='/images/roundleft.png'></image>
</view>
<view class="btn flex-center" bindtap="dateSelection">
<view class="text">{{selectDay}}</view>
</view>
<view class="iconfont" data-id="1" bindtap='dataBefor'>
<image class='iconimage' src='/images/roundright.png'></image>
</view>
</view>
<view wx:if='{{!calShow}}' class="{{isOpen?'':'calendar-box'}} {{dateShow?'active':''}}">
<view class="calendar-wrapper {{dateShow?'active':''}}">
<view class="calendar-panel">
<view class="date-befor" data-id="0" data-type="month" bindtap='dataBefor'>
<text class="iconfont">
<text class='left color'></text>
</text>
</view>
<view class="calendar-panel-box">
<view>{{canlender.year}}年</view>
<view>{{canlender.month}}月</view>
</view>
<view class="date-after" data-id="1" data-type="month" bindtap='dataBefor'>
<text class="iconfont">
<text class='right color'></text>
</text>
</view>
<view class='backtoday' bindtap='backtoday'>
回到今天
</view>
</view>
<view class="calendar-header">
<view>日</view>
<view>一</view>
<view>二</view>
<view>三</view>
<view>四</view>
<view>五</view>
<view>六</view>
</view>
<view class="calendar-body">
<block wx:for="{{canlender.weeks}}" wx:for-item="weeks" wx:for-index="week" wx:key="weeks">
<view class="calender-body-date-week">
<block wx:for="{{weeks}}" wx:for-item="day" wx:key="day">
<view class="date {{canlender.month === day.month? '' : 'placeholder'}} {{(day.date==canlender.date||day.checked) && canlender.month == day.month?'date-current': ''}} " data-week="{{week}}" data-index="{{index}}" data-ischeck="{{canlender.month === day.month}}"
bindtap='selectDay'>
{{day.date}}
<view wx:if="{{day.have}}" class="data-circle"></view>
</view>
</block>
</view>
</block>
</view>
<view class="packup" bindtap='packup'>确定</view>
</view>
</view>

@ -0,0 +1,195 @@
/* pages/calendar/calendar.wxss */
.calendar-box {
position: absolute;
top: 50rpx;
left: 0;
width: 100%;
height: 100vh;
background: rgba(0, 0, 0, 0.5);
z-index: 999;
padding-top: 100rpx;
box-sizing: border-box;
transition: all 0.3s;
opacity: 0;
}
.calendar-box.active {
opacity: 1;
}
.calendar-wrapper {
width: 100%;
border-top: 1px #f5f5f5 solid;
box-sizing: border-box;
font-size: 26rpx;
background: #fff;
transition: all 0.3s;
transform: translateY(-100%);
}
.calendar-wrapper.active {
transform: translateY(0%);
}
.header {
display: flex;
justify-content: center;
align-items: center;
position: relative;
height: 100rpx;
/* width: 100%; */
background:#fff;
/* padding: 0 30rpx; */
z-index: 10000;
}
.top-jiantou {
width: 100rpx;
height: 100rpx;
text-align: center;
box-sizing: border-box;
line-height: 100rpx;
}
.iconfont {
display: flex;
justify-content: center;
align-items: center;
position: relative;
width: 53rpx;
height: 53rpx;
color:#0e9eda;
}
.iconimage{
width:40rpx;
height: 40rpx;
}
.btn {
margin: 0 30rpx;
width: 150rpx;
height: 53rpx;
color: #0e9eda;
font-size: 30rpx;
box-sizing: border-box;
}
.calendar-panel {
position: relative;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
height: 80rpx;
}
.backtoday {
position: absolute;
right: 0;
top: 15rpx;
padding: 0 10rpx;
padding-left: 20rpx;
height: 50rpx;
line-height: 50rpx;
border: 1px #0e9eda solid;
border-right: none;
font-size: 28rpx;
border-top-left-radius: 50rpx;
border-bottom-left-radius: 50rpx;
color: #0e9eda;
background: rgba(82, 184, 245, 0.1);
}
.date-befor, .date-after {
/* border: 1px red solid; */
display: flex;
justify-content: center;
align-items: center;
height: 80rpx;
width: 80rpx;
text-align: center;
line-height: 80rpx;
/* margin-right: 20rpx; */
}
/* .date-after {
margin-left: 20rpx;
} */
.calendar-panel-box {
display: flex;
}
.calendar-header {
display: flex;
}
.calendar-header view {
width: 100%;
text-align: center;
line-height: 80rpx;
color: #0e9eda;
}
.calendar-body {
display: flex;
flex-wrap: wrap;
}
.calender-body-date-week {
display: flex;
width: 100%;
border-bottom: 1px #f5f5f5 solid;
}
.date {
position: relative;
width: 100%;
text-align: center;
color: #1c1c1c;
background: #fff;
line-height: 100rpx;
}
.date.active {
background: red;
}
.placeholder {
color: #a4a4a4;
}
.date-current {
background: #0e9eda;
color: #fff;
}
.data-circle {
position: absolute;
bottom: 25.5rpx;
left: 0;
right: 0;
margin: auto;
width: 50rpx;
height: 50rpx;
border-radius: 50%;
border:1px solid #0e9eda;
background: #0e9eda;
z-index: 2;
opacity: 0.5;
}
.packup {
width: 100%;
height: 100rpx;
line-height: 100rpx;
text-align: center;
color: #0e9eda;
}
.flex-center {
display: flex;
align-items: center;
justify-content: center;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

@ -0,0 +1,186 @@
import Data from '../../utils/data.js'
Page({
/**
* 页面的初始数据
*/
data: {
recommendList:[],
foods: [{ name: '鸡蛋', quantity: '5个' }, { name: '番茄', quantity: '5个' }, { name: '葱', quantity: '1根' }, { name: '盐', quantity: '1勺' }, { name: '油', quantity: '适量' }, { name: '砂糖', quantity: '少许' },],
steps: [{
image:'http://i2.chuimg.com/5bcd1e1f8acb4179a73231b37783b80b_2048w_1722h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "选择比较成熟的番茄,捏着比较软,这样的番茄多汁,味道好一些,然后用刀划十字,放入开水里面烫一下,过入凉水,去皮"
}, {
image: 'http://i2.chuimg.com/38fbba613b844b198311dbd43f5c6683_2022w_2048h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "番茄切成小块儿,喜欢多汁的就切碎一点"
}, {
image: 'http://i2.chuimg.com/2fd03bec614a46ab841d8208d3e28bf9_2000w_2668h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "大蒜去皮切成蒜末"
}, {
image: 'http://i2.chuimg.com/c0b9dea31a90433092d43dea7ea54363_2208w_1536h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "小葱切碎"
}, {
image: 'http://i2.chuimg.com/d539ffda408d4214ae22d57b2d1d4bd5_2048w_1804h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "鸡蛋加少许盐打散"
}, {
image: 'http://i2.chuimg.com/b683696efb95484c90500761b491a8b7_2668w_2668h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "锅里放油烧热,倒入蛋液,用筷子划,凝固就可以出锅备用"
}, {
image: 'http://i2.chuimg.com/7797e400f6c345dcb27e05fa2dfafaa8_2668w_2668h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "就着炒鸡蛋的油,可以不再放油,锅里放入番茄翻炒,加入盐"
}, {
image: 'http://i2.chuimg.com/295a0a61d7f64641b1e709cb04ed16bb_2000w_2668h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "汤汁比较浓厚时,放入炒好的鸡蛋"
}, {
image: 'http://i2.chuimg.com/c96a27ef3e1c45c0910d920c2c281cf8_1000w_1000h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "翻炒一下,就可以出锅了,最后撒上葱花。"
},],
Tab:['营养成分','烹饪方法'],
build:false,
id:1,
carts: [], // 购物车列表
delFlag: true,
buiFlag: true,
fat:10,
carbs:10,
protein:42,
TabCur: 0,
},
/**
* 生命周期函数--监听页面加载
*/
onShow: function (options) {
},
onLoad: function (options) {
var id = options.id;
var build = options.build || false;
var value = wx.getStorageSync('meal2') || [];
var diary = wx.getStorageSync('diary') || [];
var temp = value[id];
var tab = ['营养成分','推荐食谱']
if(temp.cata.indexOf("food")!=-1){
this.setData({
buiFlag: false,
Tab:tab
});
}
var carts = [];
carts.push(temp);
this.getRecommend(temp);
for (var i = 0; i < diary.length; i++) {
if(diary[i].id == carts[0].id){
this.setData({
delFlag:false
});};
}
this.setData({
build:build,
carts:carts
});
},
add: function () {
this.setData({
delFlag: false
});
var value = wx.getStorageSync('diary') || [];
var id = this.data.remarks;
var carts = this.data.carts;
value.push(carts[0]);
wx.setStorageSync('diary', value);
var meal2 = wx.getStorageSync('meal2');
console.log(meal2[carts[0].id].name)
meal2[carts[0].id].add=true;
wx.setStorageSync('meal2', meal2);
wx.showToast({
title: '已加入今日食谱',
icon: 'success',
duration: 2000
})
},
del: function () {//删除diary中的食谱
this.setData({
delFlag: true
});
var diary = wx.getStorageSync('diary');
var carts = this.data.carts;
var index = 0;
for (var i = 0; i < diary.length; i++) {
if (diary[i].id == carts[0].id) {
index = i;
};
}
diary.splice(index, 1);
wx.setStorageSync('diary', diary)
var meal2 = wx.getStorageSync('meal2');
meal2[carts[0].id].add = false;
wx.setStorageSync('meal2', meal2);
wx.showToast({
title: '已移出今日食谱!',
icon: 'success',
duration: 2000
})
},
bui: function () {//跳转到home
var cart = wx.getStorageSync('cart') || [];
var tcarts = this.data.carts;
var build = this.data.build;
for(var i=0;i<cart.length;i++){
if(tcarts[0].id == cart[i].id){
cart[i].quantity+=1;
tcarts[0].quantity += 1;
}
}
if (tcarts[0].quantity < 1) { tcarts[0].quantity += 1;cart.push(tcarts[0]);}
wx.setStorageSync('cart', cart);
if(build){
wx.navigateBack()
}else{
wx.redirectTo({
url: '../home/home'
})}
},
tabSelect(e) {
this.setData({
TabCur: e.currentTarget.dataset.id,
})
},
getRecommend(tmp) {
var meal2 = wx.getStorageSync('meal2') || [];
var swiperList = []
var food = tmp
for (var j = Data.getFoodNum(); j < meal2.length; j++) {
var m = meal2[j]
m.foodscore = m.foodscore || parseInt(m.score)
var list = m.list
for (var k = 0; k < list.length; k++) {
if (list[k] == food.id) {
console.log(m.name)
m.foodscore += 10
break
}
}
}
console.log(meal2)
meal2.sort(function (a, b) {
return (a.foodscore || 0) - (b.foodscore || 0)
})
console.log(meal2)
for (var i = meal2.length - 1; i > meal2.length - 6; i--) {
swiperList.push(meal2[i])
}
console.log(swiperList)
this.setData({
recommendList: swiperList
})
}
})

@ -0,0 +1,4 @@
{
"navigationBarTitleText": "菜谱详情"
}

@ -0,0 +1,120 @@
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">菜谱详情</view>
</cu-custom>
<view class="cart-list" wx:for="{{carts}}" wx:key="{{index}}">
<view class="cart-thumb-box">
<image class="cart-thumb" src="{{item.image}}"></image>
</view>
<text class="cart-pro-name">{{item.name}}</text>
<text class="cart-pro-info">{{item.cal}}kcal·{{item.amount}}g</text>
<view class="cart-pro-score" style='border-color:{{item.color}}'><text>{{item.score}}</text></view>
<text class="cart-pro-eva">{{item.eva}}</text>
<button class="add" bindtap="add"><text class="cuIcon-roundadd"> </text> 加入今日份食谱</button>
<button hidden="{{delFlag}}" class="del" bindtap="del"><text class="cuIcon-roundclose"> </text> 移出今日份食谱</button>
<button hidden="{{buiFlag}}" class="bui" bindtap="bui"><text class="cuIcon-roundadd"> </text> 制作膳食</button>
<view class="more-info-bg">
<scroll-view scroll-x class="bg-white nav">
<view class="flex text-center">
<view class="cu-item flex-sub {{index==TabCur?'text-blue cur':''}}" wx:for="{{2}}" wx:key bindtap="tabSelect" data-id="{{index}}">
{{Tab[index]}}
</view>
</view>
</scroll-view>
<view class="more-info shadow-warp" wx:if="{{TabCur==0}}">
<view class="padding flex text-center text-grey bg-white">
<view class="flex flex-sub flex-direction solid-right">
<view class="flex align-end justify-center">
<view class="text-xxl text-blue ">{{item.nutrition[0]}}</view>
<view class="text-s text-blue padding-left-xs padding-bottom-xs" >g</view>
</view>
<view class="margin-top-sm">糖</view>
</view>
<view class="flex flex-sub flex-direction solid-right">
<view class="flex align-end justify-center">
<view class="text-xxl text-blue ">{{item.nutrition[1]}}</view>
<view class="text-s text-blue padding-left-xs padding-bottom-xs" >g</view>
</view>
<view class="margin-top-sm">蛋白质</view>
</view>
<view class="flex flex-sub flex-direction">
<view class="flex align-end justify-center">
<view class="text-xxl text-blue ">{{item.nutrition[2]}}</view>
<view class="text-s text-blue padding-left-xs padding-bottom-xs" >g</view>
</view>
<view class="margin-top-sm">脂肪</view>
</view>
</view>
<view class="detail-info-box text-xl">
<text class="left">膳食纤维</text>
<text class="right">{{item.nutrition[3]}}g</text>
<text class="left">\n胆固醇</text>
<text class="right">{{item.nutrition[4]}}mg</text>
<text class="left">\n维生素A</text>
<text class="right">{{item.nutrition[5]}}ug</text>
<text class="left">\n维生素B1</text>
<text class="right">{{item.nutrition[6]}}mg</text>
<text class="left">\n维生素B2</text>
<text class="right">{{item.nutrition[7]}}mg</text>
<text class="left">\n维生素C</text>
<text class="right">{{item.nutrition[8]}}mg</text>
<text class="left">\n维生素E</text>
<text class="right">{{item.nutrition[9]}}mg</text>
<text class="left">\n叶酸</text>
<text class="right">{{item.nutrition[10]}}ug</text>
<text class="left">\n钙</text>
<text class="right">{{item.nutrition[11]}}ug</text>
<text class="left">\n铁</text>
<text class="right">{{item.nutrition[12]}}mg</text>
<text class="left">\n钾</text>
<text class="right">{{item.nutrition[13]}}mg</text>
<text class="left">\n锌</text>
<text class="right">{{item.nutrition[14]}}mg</text>
</view>
</view>
<view class="more-info shadow-warp" wx:if="{{TabCur==1 && buiFlag}}">
<view class="detail-info-box">
<view class='text-blue text-xl'>用料:</view>
<view class="infood" wx:for="{{foods}}" wx:key="{{index}}">
<text class="left">{{item.name}}</text>
<text class="right">{{item.quantity}}</text>
</view>
<view class='margin-top text-blue text-xl'>步骤:</view>
<view class="infood" wx:for="{{steps}}" wx:key="{{index}}">
<text class="">第 {{index+1}} 步:</text>
<image class='steps radius shadow-wrap' src='{{item.image}}'></image>
<text>{{item.text}}</text>
</view>
</view>
</view>
<view class="more-info shadow-warp" wx:if="{{TabCur==1 && !buiFlag}}">
<view class="cu-list menu-avatar">
<view class="solid-bottom cu-item" wx:for="{{recommendList}}" wx:key="{{index}}">
<navigator url="../details/details?id={{item.id}}">
<image class="thumb" src="{{item.image}}" mode="widthFix"></image></navigator>
<view class="content">
<view class="text-black">{{item.name}}</view>
<view class="text-gray text-sm">{{item.cal}}kcal·{{item.amount}}g</view>
</view>
<view class="right-box" style="text-align:center;padding:10rpx;width:100rpx">
<view class="text-black text-xxl" style='border:1px solid {{item.color}};border-radius:15rpx;'>
{{item.score}}</view>
<view class="text-grey text-xs">{{item.eva}}</view>
</view>
</view>
</view>
</view>
</view>
</view>

@ -0,0 +1,144 @@
page{
background-color: #fff;
}
.cart-list{
background-color: #fff;
position: relative;
border-bottom: 1rpx solid #e9e9e9;
}
.cart-list .cart-thumb-box{
border-bottom: 1rpx solid #e9e9e9;
position: absolute;
width: 100%;
height: 400rpx;
overflow: hidden;
}
.cart-list .cart-thumb{
position: absolute;
top:-100rpx;
width:100%;
height:600rpx;
}
.cart-list .cart-pro-name{
position:absolute;
top:410rpx;
left:20rpx;
padding: 20rpx 20rpx 20rpx 20rpx;
width: 60%;
height: 100rpx;
text-align: left;
font-size: 80rpx;
overflow: hidden;
}
.cart-list .cart-pro-info{
color:#999;
font-size: 40rpx;
position:absolute;
top:540rpx;
left:20rpx;
padding: 20rpx 20rpx 20rpx 20rpx;
width: 60%;
line-height: 50rpx;
overflow: hidden;
}
.cart-list .cart-pro-score{
border:lightgray;
border-style: solid;
border-width: 1px;
border-radius: 10px;
position: absolute;
font-size: 75rpx;
top: 440rpx;
right: 30rpx;
display: flex; justify-content: center;align-items: center;
padding: 10rpx 10rpx 10rpx 10rpx;
width: 150rpx;
height: 130rpx;
}
.cart-list .cart-pro-eva{
color:#999;
position: absolute;
font-size: 30rpx;
top: 570rpx;
right: 30rpx;
overflow: hidden;
text-align: center;
width: 150rpx;
}
.add{
position: absolute;
top:325px;
left:2.5%;
border-radius: 30px;
border-bottom: 1rpx solid #e9e9e9;
background-image: linear-gradient(45deg, #0081ff, #1cbbb4);
width: 95%;
color:#fff;
}
.del{
position: absolute;
top:325px;
left:2.5%;
border-radius: 30px;
border-bottom: 1rpx solid #e9e9e9;
background-image: linear-gradient(45deg, #f43f3b, #ec008c);
width: 95%;
color:#fff;
}
.bui{
position: absolute;
top:325px;
left:2.5%;
border-radius: 30px;
border-bottom: 1rpx solid #e9e9e9;
background-image: linear-gradient(45deg, #0081ff, #1cbbb4);
width: 95%;
color:#fff;
}
.more-info-bg{
position: absolute;
top:400px;
border-top: 1rpx solid #e9e9e9;
width: 100%;
height:100%;
}
.more-info-bg .more-info{
position: absolute;
top:120rpx;
left:3%;
background-color:#fff;
width: 94%;
}
.detail-info-box{
font-size:28rpx;
line-height: 40px;
padding: 20px 20px 20px 20px;
}
.right{
float: right;
}
.steps{
width:600rpx;
}
.thumb{
border: lightgrey;
border-style: solid;
border-width: 1px;
border-bottom-left-radius: 10px;
border-top-left-radius: 10px;
border-bottom-right-radius: 10px;
border-top-right-radius: 10px;
position: absolute;
top: 20rpx;
left: 30rpx;
width: 100rpx;
height: 100rpx;
}

@ -0,0 +1,230 @@
// page/component/new-pages/user/user.js
import Data from '../../utils/data.js'
Page({
data: {
array1: ['男', '女'],
array2: [],
array3: [],
array4: [],
array5: [],
array6: ['低','中','高'],
sports:1,
multiArray:[[],[]],
gender:0,
birthday: "1996-08-03",
place: ["四川省", "成都市", "郫都区"],
height:170,
weight:60,
tnb:false,
gxy:false,
xieya: [115, 75],
fatrate:17,
xietang:50,
thumb: '',
nickname: '',
},
onLoad() {
wx.showLoading({
title: '数据加载中',
})
var array2=this.data.array2;
var array3 =this.data.array3;
var array4 = this.data.array4;
var array5 = this.data.array5;
var multiArray = this.data.multiArray;
for (var i = 100; i <= 250; i++) {
array2.push(i);
}
for (var i = 0; i <= 200; i++) {
array3.push(i);
multiArray[0].push(i);
multiArray[1].push(i);
}
for (var i = 0; i <= 50; i++) {
array4.push(i);
}
for (var i = 0; i <= 15; i+=0.1) {
array5.push(i.toFixed(1));
}
var self = this;
/**
* 获取用户信息
*/
wx.getUserInfo({
success: function (res) {
self.setData({
thumb: res.userInfo.avatarUrl,
nickname: res.userInfo.nickName
})
}
})
var user =wx.getStorageSync("user");
var gender = user.gender;
var height = user.height;
var weight = user.weight;
var birthday = user.birthday;
var place = user.place;
var xieya = user.xieya;
var fatrate = user.fatrate;
var xietang = user.xietang;
var tnb = user.tnb;
var gxy = user.gxy;
var sports = user.sports;
this.setData({
height: height,
weight: weight,
gender: gender,
birthday:birthday,
place:place,
tnb: tnb,
gxy: gxy,
xieya:xieya,
xietang: xietang,
fatrate: fatrate,
sports: sports,
array2:array2,
array3:array3,
array4: array4,
array5: array5,
multiArray: multiArray,
})
wx.hideLoading()
},
genderChange: function (e) {
var t = e.detail.value;
this.setData({
gender: t,
})
},
sportsChange: function (e) {
var t = e.detail.value;
this.setData({
sports: t,
})
},
birthdayChange: function (e) {
var t = e.detail.value;
this.setData({
birthday: t,
})
},
placeChange: function (e) {
var t = e.detail.value;
this.setData({
place: t,
})
},
heightChange: function (e) {
var t = e.detail.value;
this.setData({
height: t,
})
},
weightChange: function (e) {
var t = e.detail.value;
this.setData({
weight: t,
})
},
gxyChange: function (e) {
var t = e.detail.value;
this.setData({
gxy: t,
})
},
tnbChange: function (e) {
var t = e.detail.value;
this.setData({
tnb: t,
})
},
xieyaChange(e) {
this.setData({
xieya: e.detail.value
})
},
xietangChange(e) {
this.setData({
xietang: e.detail.value
})
},
fatrateChange(e) {
this.setData({
fatrate: e.detail.value
})
},
confirm:function(){
var that = this
wx.showLoading({
title: '数据提交中',
})
var u = wx.getStorageSync('user') || {}
var m = wx.getStorageSync('meal') || []
u.gender = this.data.gender;
u.birthday = this.data.birthday;
u.place = this.data.place;
u.height = this.data.height;
u.weight = this.data.weight;
u.gxy = this.data.gxy;
u.tnb = this.data.tnb;
u.xieya = this.data.xieya;
u.xietang = this.data.xietang;
u.fatrate = this.data.fatrate;
u.sports = this.data.sports;
var score = Data.getScore(u)
console.log(u);
//更新健康指数
wx.setStorageSync("healthy", score)
wx.setStorageSync("user", u)
wx.request({
url: Data.getUrl() + 'score',
data: {
'meal':m,
'user':u,
'all':m
},
method: 'POST',
header: {
'content-type': 'application/json' // 默认值
},
success: function (res) {
console.log(res.data)
for(var i=0;i<res.data.length;i++){
var m=res.data[i]
var s=m.score
m.eva = that.getEva(s)
m.color = that.getColor(s)
}
wx.setStorageSync('meal', res.data)
wx.hideLoading();
wx.switchTab({
url: '../user/home',
})
wx.showToast({
title: '数据提交成功!',
icon: 'success',
duration: 2000
})
},
})
},
getEva: function (s) {
var eva = "Bad";
if (s >= 2) { eva = "Limit" }
if (s >= 4) { eva = "Normal" }
if (s >= 6) { eva = "Good" }
if (s >= 9) { eva = "Excellent" }
return eva;
},
getColor: function (s) {
var c = "#e54d42";
if (s >= 2) { c = "#fbbd08" }
if (s >= 4) { c = "#666666" }
if (s >= 6) { c = "#8dc63f" }
if (s >= 9) { c = "#39b54a" }
return c;
},
})

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "身体数据"
}

@ -0,0 +1,83 @@
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">身体数据</view>
</cu-custom>
<button class="upload" bindtap="confirm"><text class="cuIcon-upload"> </text> 智能设备云同步</button>
<view class="cu-form-group margin-top">
<view class="title">性别</view>
<picker bindchange="genderChange" value="{{gender}}" range="{{array1}}">
<view class="picker">
{{array1[gender]}}
</view>
</picker>
</view>
<view class="cu-form-group">
<view class="title">生日</view>
<picker mode="date" value="{{birthday}}" start="1900-01-01" end="2020-01-01" bindchange="birthdayChange">
<view class="picker">
{{birthday}}
</view>
</picker>
</view>
<view class="cu-form-group">
<view class="title">常住</view>
<picker mode="region" bindchange="placeChange" value="{{place}}">
<view class="picker">
{{place[0]}}{{place[1]}}{{place[2]}}
</view>
</picker>
</view>
<view class="cu-form-group">
<view class="title">身高</view>
<picker bindchange="heightChange" value="{{height}}" range="{{array2}}">
<view class="picker">
{{array2[height]}}cm
</view>
</picker>
</view>
<view class="cu-form-group">
<view class="title">体重</view>
<picker bindchange="weightChange" value="{{weight}}" range="{{array3}}">
<view class="picker">
{{array3[weight]}}kg
</view>
</picker>
</view>
<view class="cu-form-group">
<view class="title">体脂率</view>
<picker bindchange="fatrateChange" value="{{fatrate}}" range="{{array4}}">
<view class="picker">
{{array4[fatrate]}}%
</view>
</picker>
</view>
<view class="cu-form-group">
<view class="title">血压</view>
<picker mode="multiSelector" bindchange="xieyaChange" value="{{xieya}}"
range="{{multiArray}}">
<view class="picker">
{{multiArray[0][xieya[0]]}}mmHg / {{multiArray[1][xieya[1]]}}mmHg
</view>
</picker>
</view>
<view class="cu-form-group">
<view class="title">血糖</view>
<picker bindchange="xietangChange" value="{{xietang}}" range="{{array5}}">
<view class="picker">
{{array5[xietang]}}mmol/L
</view>
</picker>
</view>
<view class="cu-form-group">
<view class="title">运动强度</view>
<picker bindchange="sportsChange" value="{{sports}}" range="{{array6}}">
<view class="picker">
{{array6[sports]}}
</view>
</picker>
</view>
<view class="cu-form-group">
<view class="title">精神压力</view>
<switch class="blue sm" bindchange='gxyChange' checked='{{gxy}}'></switch>
</view>
<button class="confirm" bindtap="confirm"><text class="cuIcon-roundcheck"> </text> 提交</button>

@ -0,0 +1,21 @@
.confirm{
font-size:35rpx;
position: relative;
top:10px;
border-radius: 30px;
border-bottom: 1rpx solid #e9e9e9;
background-image: linear-gradient(45deg, #0081ff, #1cbbb4);
width: 95%;
color:#fff;
}
.upload{
font-size:35rpx;
position: relative;
top:10px;
border-radius: 5px;
border-bottom: 1rpx solid #e9e9e9;
background-image: linear-gradient(45deg, #39b54a, #8dc63f);
width: 97.5%;
color:#fff;
}

@ -0,0 +1,74 @@
Page({
/**
* 页面的初始数据
*/
data: {
updown:false,
carts: [], // 购物车列表
hasList: false, // 列表是否有数据
selected: [],
totalPrice:9.9,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
//查找那些时间已经打过卡了
wx.showLoading({
title: '加载中',
})
var selected = wx.getStorageSync('selected')
this.setData({
selected:selected
})
wx.hideLoading();
},
/**
* 日历是否被打开
*/
bindselect(e) {
console.log(e.detail.ischeck)
},
/**
* 获取选择日期
*/
bindgetdate(e) {
wx.showLoading({
title: '加载中',
})
let time = e.detail;
let today = time.year +"-"+ time.month + "-" + time.date;
console.log(today)
var carts = wx.getStorageSync(today);
if (carts.length) {
this.setData({
hasList: true,
carts: carts,
});
} else {
this.setData({
hasList: false,
});
}
this.getScore();
wx.hideLoading()
},
getScore() {
let carts = this.data.carts; // 获取购物车列表
let total = 0;
let updown = true;
let h = wx.getStorageSync("healthy") || 0
for (let i = 0; i < carts.length; i++) { // 循环列表得到每个数据
total += carts[i].score / carts.length;
}
if(total>=h){updown =true;}else{updown=false;}
this.setData({ // 最后赋值到data中渲染到页面
carts: carts,
updown:updown,
totalPrice: total.toFixed(1)
});
},
})

@ -0,0 +1,6 @@
{
"usingComponents": {
"calendar": "/components/calendar/calendar"
},
"navigationBarTitleText": "打卡记录"
}

@ -0,0 +1,39 @@
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">打卡记录</view>
</cu-custom>
<calendar selected="{{selected}}" bindselect="bindselect" bindgetdate="bindgetdate" />
<view wx:if="{{hasList}}">
<view class='box'>当日得分:<view class='totalPrice'>{{totalPrice}}</view>
<view class='updown'><image src='/images/up.png' hidden='{{!updown}}' class='up'></image>
<image src='/images/down.png' hidden='{{updown}}' class='down'></image></view>
</view>
<view class="cart-title">
<text>当日份食谱:</text>
</view>
<view class="cu-list menu-avatar">
<view class="solid-bottom cu-item {{modalName=='move-box-'+ index?'move-cur':''}}" wx:for="{{carts}}" wx:key="{{index}}" data-target="move-box-{{index}}">
<navigator url="../details/details?id={{item.id}}">
<image class="thumb" src="{{item.image}}"></image></navigator>
<view class="content">
<view class="text-black">{{item.name}}</view>
<view class="text-gray text-sm">{{item.cal}}kcal·{{item.amount}}g</view>
</view>
<view class="right-box" style="text-align:center;padding:10rpx;width:100rpx">
<view class="text-black text-xxl" style='border:1px solid {{item.color}};border-radius:15rpx;'>
{{item.score}}</view>
<view class="text-grey text-xs">{{item.eva}}</view>
</view>
<view class="move">
<view class="bg-red" bindtap='deleteList'>删除</view>
</view>
</view>
</view>
</view>
<view wx:else>
<view class="cart-no-data">这一天没有打卡~</view>
</view>

@ -0,0 +1,65 @@
/**index.wxss**/
.box {
border-top: 1px solid #e9e9e9;
display: flex;
justify-content: center;
align-items:baseline;
width: 100%;
height: 200rpx;
background: #fff;
font-size: 30rpx;
color: #666;
padding-bottom: 10rpx;
}
.box .totalPrice{
font-size:50px;
color:#0e9eda;
}
.box .updown{
width:20px;
height:40px;
}
.box .up{
position: absolute;
right:25%;
width:20px;
height: 40px;
}
.box .down{
position: absolute;
right:25%;
width:20px;
height: 40px;
}
.cart-title{
bottom: 0;
left: 0;
width: 100%;
height: 90rpx;
line-height: 90rpx;
padding:0 100rpx 0 30rpx;
box-sizing: border-box;
background: ghostwhite;
color: #000;
}
.cart-no-data{
padding:40rpx 0;
color: #999;
text-align: center;
}
.thumb{
border: lightgrey;
border-style: solid;
border-width: 1px;
border-bottom-left-radius: 10px;
border-top-left-radius: 10px;
border-bottom-right-radius: 10px;
border-top-right-radius: 10px;
position: absolute;
top: 20rpx;
left: 30rpx;
width: 100rpx;
height: 100rpx;
}

@ -0,0 +1,287 @@
import Data from '../../utils/data.js'
Page({
//页面的初始数据
data: {
swiperList: [],
classes_array: [{ name: '炒', checked: true, id: 1 }, { name: '煎', checked: false, id: 2 }, { name: '蒸', checked: false, id: 3 }, { name: '炖', checked: false, id: 4 }, { name: '煮', checked: false, id: 5 }, { name: '烤', checked: false, id: 6 }, { name: '焖', checked: false, id: 7 }, { name: '炸', checked: false,id: 8 }],
id:0,
cook : 1,
confirmOrder: [],
number:0,
// 备注信息
remarks:"",
// 购物车数据
cartList:{},
totalPrice: 0,
displayPrice: 0,
totalNum: 0,
totalCal:0,
totalWeight:0,
totalNutrition: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
// 遮罩
maskFlag:true,
orderlist:[],
imgList: [],
list:[]
},
// 生命周期函数--监听页面加载
onLoad:function(Options){
this.getRecommend()
var that = this;
var arr = wx.getStorageSync('cart') ||[];
// 打印arr以及meal全局变量查看差异然后写入就行
for(var i in arr){
for(var j=0;j<arr[i].quantity;j++){
this.data.list.push(arr[i].id);
}
this.data.totalNum += arr[i].quantity;
this.data.totalPrice += arr[i].quantity * arr[i].score;
this.data.totalWeight += arr[i].quantity * arr[i].amount;
this.data.totalCal += arr[i].quantity*arr[i].cal;
for(var j =0;j<=14;j++){
this.data.totalNutrition[j] += arr[i].quantity * arr[i].nutrition[j];
}
}
this.data.totalPrice /= this.data.totalNum;
this.data.totalPrice = this.data.totalPrice.toFixed(1),
this.data.displayPrice = Number(this.data.totalPrice);
this.data.displayPrice += 0.075;
console.log(this.data.displayPrice)
for (var j = 0; j <= 14; j++) {
this.data.totalNutrition[j] = (this.data.totalNutrition[j]).toFixed(2);
}
this.setData({
cartList:arr,
totalPrice: this.data.totalPrice,
displayPrice: this.data.displayPrice.toFixed(1),
totalNum: this.data.totalNum,
totalWeight: this.data.totalWeight,
totalCal: this.data.totalCal.toFixed(1),
totalNutrition: this.data.totalNutrition
})
},
// 获取输入的烹饪方式
//点击radio-group中的列表项事件
radiochange: function (res) {
console.log("选中的标签:" + res.detail.value);
var arrs = this.data.classes_array;
var that = this;
for (const x in arrs) {
if (arrs[x].id == res.detail.value) {
arrs[x].checked = true;
} else {
arrs[x].checked = false;
}
}
that.setData({
classes_array: arrs
})
this.updateScore(res.detail.value);
},
updateScore: function (e) {
var tp = parseFloat(this.data.totalPrice);
var id = parseFloat(e);
tp=tp+id*0.075;
if(tp>9.9){tp=9.9};
console.log(tp);
this.setData({
cook:id,
displayPrice: tp.toFixed(1)
})
},
// 获取菜谱名称
getRemark: function (e) {
var remarks = this.data.remarks;
this.setData({
number:0,
remarks: e.detail.value
})
},
getEva: function (s) {
var eva = "Bad";
if (s >= 2) { eva = "Limit" }
if (s >= 4) { eva = "Normal" }
if (s >= 6) { eva = "Good" }
if (s >= 9) { eva = "Excellent" }
return eva;
},
getColor: function (s) {
var c = "#e54d42";
if (s >= 2) { c = "#fbbd08" }
if (s >= 4) { c = "#666666" }
if (s >= 6) { c = "#8dc63f" }
if (s >= 9) { c = "#39b54a" }
return c;
},
complete: function () {//完成meal创建写入到build和meal中
var that=this
wx.showLoading({
title: '制作膳食中',
})
var value = wx.getStorageSync('build') || [];
var value2 = wx.getStorageSync('meal') || [];
var length = value2.length;
var name =this.data.remarks;
var cal = this.data.totalCal;
var amount = this.data.totalWeight;
var nutrition = this.data.totalNutrition;
var list = this.data.list
var ima = this.data.imgList[0] || wx.getStorageSync('cart')[0].image;
if(name.length==0){name="没有名字的膳食"}
var m = [{
id: length,
name: name,
image: ima,
cal: cal,
amount: amount,
nutrition:nutrition,
cata:'meal',
list:list,
}]
var u = wx.getStorageSync('user')
wx.request({
url: Data.getUrl() + 'score',
data: {
'meal': m,
'user': u,
'all':value2
},
method: 'POST',
header: {
'content-type': 'application/json' // 默认值
},
success: function (res) {
console.log(res.data)
var m = res.data[0]
var score = Number(that.data.displayPrice);
var cook = that.data.cook
//score = score + cook*0.075;
if(score>9.9){score=9.9}
m.score = score.toFixed(1);
m.eva = that.getEva(score);
m.color = that.getColor(score);
value.push(m);//很关键
value2.push(m);
wx.setStorageSync('cart', []);
wx.setStorageSync('build', value)
wx.setStorageSync('meal', value2)
wx.hideLoading();
wx.switchTab({
url: '../build/build',
})
},
})
},
ChooseImage() {
wx.chooseImage({
count: 1, //默认9
sizeType: [ 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album'], //从相册选择
success: (res) => {
if (this.data.imgList.length != 0) {
this.setData({
imgList: this.data.imgList.concat(res.tempFilePaths)
})
} else {
this.setData({
imgList: res.tempFilePaths
})
}
}
});
},
ViewImage(e) {
wx.previewImage({
urls: this.data.imgList,
current: e.currentTarget.dataset.url
});
},
DelImg(e) {
this.data.imgList.splice(e.currentTarget.dataset.index, 1);
this.setData({
imgList: this.data.imgList
})
},
SearchImg(e) {
wx.showLoading({
title: '图片匹配中',
})
var that = this
var name = this.data.remarks || '牛油果';
var number = this.data.number
wx.request({
url: Data.getUrl() + 'searchImage',
data: {
'name': name,
'number':number,
},
method: 'POST',
header: {
'content-type': 'application/json' // 默认值
},
success: function (res) {
console.log(res.data)
var imgList = []
imgList = imgList.concat(res.data)
var number = that.data.number
that.setData({
imgList: imgList,
number: number+1
})
wx.hideLoading()
wx.showToast({
title: '图片匹配成功!',
icon: 'success',
duration: 2000
})
},
})
},
cardSwiper(e) {
this.setData({
cardCur: e.detail.current
})
},
getRecommend(){
var cart = wx.getStorageSync('cart') || [];
var meal = wx.getStorageSync('meal') || [];
var swiperList = []
for(var i=0;i<cart.length;i++){
var food = cart[i]
for (var j=Data.getFoodNum();j<meal.length;j++){
var m = meal[j]
console.log(m);
m.foodscore = m.foodscore || parseInt(m.score)
var list = m.list
for(var k=0;k<list.length;k++){
if (list[k] == food.id) {
console.log(m.name)
m.foodscore += 5
break
}
}
}
}
meal.sort(function (a, b) {
return (a.foodscore || 0) - (b.foodscore || 0)
})
console.log(meal)
for(var i=meal.length-1;i>meal.length-6;i--){
swiperList.push(meal[i])
}
console.log(swiperList)
this.setData({
swiperList: swiperList
})
}
})

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "制作膳食"
}

@ -0,0 +1,84 @@
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">制作膳食</view>
</cu-custom>
<!--头部 -->
<view class="cu-bar bg-white margin-top">
<view class="action">
<text class="cuIcon-title text-blue"></text> 根据您所选的食材,我们为您推荐以下膳食
</view>
</view>
<view class='swp solid-bottom'>
<swiper class="card-swiper {{DotStyle?'square-dot':'round-dot'}}" indicator-dots="true" circular="true" autoplay="true" interval="5000" duration="500" bindchange="cardSwiper" indicator-color="#8799a3" indicator-active-color="#0081ff">
<swiper-item wx:for="{{swiperList}}" wx:key class="{{cardCur==index?'cur':''}}">
<navigator url="../details/details?id={{item.id}}" class="swiper-item">
<image src="{{item.image}}" mode="aspectFill"></image>
</navigator>
</swiper-item>
</swiper>
</view>
<!--内容 -->
<view class="">
<view class="weui-panel__hd weui_titleBox">已选食材</view>
<view class="weui-panel__bd">
<view class="weui-media-box weui-media-box_small-appmsg">
<view class="weui-cells weui-cells_in-small-appmsg" wx:for="{{cartList}}" wx:key="">
<view class="weui-cell weui-cell_access weui_orderBox" hover-class="weui-cell_active">
<view class="weui-cell__hd">
<image src="{{item.image}}" style="width: 26px;height: 26px;margin-right: 15px;" />
</view>
<view class="weui-cell__bd weui-cell_primary">
<view>{{item.name}}</view>
</view>
<view class="weui-cell__ft order_price">{{item.quantity}}x{{item.amount}}g</view>
</view>
</view>
</view>
</view>
<view class="fenxi"></view>
<!--输入用餐人数 -->
<view class="guest_numInput">请选择烹调方式:</view>
<view class='rggg_view solid-bottom'>
<radio-group class='rggg' bindchange='radiochange'><!-- 事件绑定 -->
<view class="class_r_g" wx:for="{{classes_array}}">
<radio id="{{item.name}}" hidden value="{{item.id}}" checked="{{item.checked}}" data-id='item.index'></radio>
<label class="label-2__text" for="{{item.name}}">
<text class='{{item.checked?"checkedt":"normalt"}}'>{{item.name}}</text><!-- 根据每一项的checked属性来切换点击radio中的文本的点击效果 -->
</label>
</view>
</radio-group>
</view>
<!--备注 -->
<view class="cu-form-group margin-top">
<input class="Remark" bindinput="getRemark" value="{{remarks}}" placeholder="给你的膳食起个名吧~"></input>
</view>
<view class="cu-form-group">
<view class="grid col-4 grid-square flex-sub margin-top">
<view class="bg-img" wx:for="{{imgList}}" wx:key="{{index}}" bindtap="ViewImage" data-url="{{imgList[index]}}">
<image src='{{imgList[index]}}' mode='aspectFill'></image>
<view class="cu-tag bg-red" catchtap="DelImg" data-index="{{index}}">
<text class="cuIcon-close"></text>
</view>
</view>
<view class="solids" bindtap="ChooseImage" wx:if="{{imgList.length<1}}">
<text class="cuIcon-cameraadd"></text>
</view>
<view class="solids" bindtap="SearchImg">
<text class="cuIcon-search"></text>
</view>
</view>
</view>
<view class="weui-panel__hd order_sum">评分:<span class="order_sumMoney">{{displayPrice}}</span></view>
<view class='fenxi2'></view>
<!--付款方式 -->
<view class="footer_box">
<button class="complete" size="{{primarySize}}" bindtap="complete">制作完成!</button>
</view>
</view>

@ -0,0 +1,287 @@
page {
background-color: #fff;
}
.window {
position: relative;
top:10rpx;
width: 100%;
}
.classesbox {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.classes_item {
padding: 3px auto 3px auto;
border: #e6e6e6 1px solid;
margin: 5px;
border-radius: 4px;
font-size: 28rpx;
width: 100%;
}
.rggg_view {
width: 100%;
height: 200rpx;
padding: 10rpx;
background-color: #fff;
}
/* 注意点使用columns时每一行中的组件本身的高度不能高于组件所在行的行高
否则会发现组件的好似被切割成2块或多块了 */
.rggg {
width: 100%;
height: 200rpx;
columns: 4;
column-gap: 20rpx;
letter-spacing: 5px;
line-height: 40px;
}
/*
注意点columns分列后最好使用margin-bottom控制行间距
margin-top会导致第一项与后面的项不一致很丑
*/
.class_r_g {
text-align: center;
margin-bottom: 5rpx;
}
/* radio文本的点击效果 */
.checkedt {
color: #0e9eda;
border: #0e9eda 1px solid;
border-radius: 4px;
font-size: 32rpx;
padding: 3px 18px;
}
/*
radio文本的默认效果
注意点组件本身的高度不能高于组件所在行的行高否则会发现组件的好似被切割成2块或多块了
*/
.normalt {
color: #666666;
border: #e6e6e6 1px solid;
border-radius: 4px;
font-size: 32rpx;
padding: 3px 18px;
}
.cont_box {
width: 100%;
height: 100%;
background-color: #fff;
padding-bottom: 120rpx;
}
/*订单最外层包裹 */
.weui-panel_box {
margin-top: 10rpx;
}
/*去掉默认的bordr-bottom */
.weui_titleBox::after {
border-bottom: none;
}
/*订单盒子 */
.weui_orderBox {
height: 100rpx;
/* line-height: 100rpx; */
padding: 0 30rpx;
vertical-align: sub;
border-bottom: 1px solid #e5e5e5;
}
/*去掉默认的bordr-bottom */
.weui_orderBox::before {
border-top: none;
}
/*合计 */
.order_sum {
float:right;
height: 100rpx;
padding: 0 30rpx;
line-height: 100rpx;
color: #000;
font-size: 32rpx;
}
/*去掉默认的bordr-bottom */
.order_sum::after {
border-bottom: none;
}
/*总钱数颜色 */
.order_sumMoney {
font-size:40px;
color: #0e9eda;
}
/*价格,份数 */
.order_price {
font-size: 28rpx;
}
/*缝隙 */
.fenxi {
width: 100%;
height: 1rpx;
background: #ddd;
}
/*烹调方式 */
.guest_numInput {
margin-top: 10px;
margin-left: 20px;
font-size: 32rpx;
color: #0e9eda;
height: 50rpx;
}
::-webkit-input-placeholder {
color: #000;
}
/*选用餐人数按钮盒子 */
/*输入备注 */
.beizhu_input {
border-bottom: 1px #d9d9d9 solid;
font-size: 32rpx;
padding: 0 30rpx;
height: 100rpx;
width:80%;
position: relative;
left:5%;
line-height: 100rpx;
}
/*选择支付方式 */
.pay_way {
background-color: #fff;
padding: 0 30rpx;
line-height: 100rpx;
color: #202020;
}
/*支付方式选项 */
.pay_wayName {
overflow: hidden;
display: block;
}
/*支付方式名称 */
.pay_wayNameL {
float: left;
}
/*支付状态 */
.pay_wayNameR {
float: right;
}
/*提交订单按钮 */
.footer_box {
width: 100%;
height: 100rpx;
position: fixed;
left: 0;
bottom: 0rpx;
z-index: 100;
background-color: #fff;
}
/*总计金额、件数 */
.all_money {
width: 90%;
margin: 0 auto;
height: 84rpx;
line-height: 84rpx;
text-align: center;
color: #fff;
font-size: 32rpx;
background-color: #09ba07;
border-radius: 20rpx;
}
/*弹窗遮罩层 */
.modal-mask {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity:0.6;
background: #000;
z-index: 666;
}
/*选择支付方式弹窗 */
.cart_popup {
width: 100%;
height: 285px;
background: #fff;
position: fixed;
z-index: 999;
left: 0;
bottom: -285px;
overflow: auto;
}
.shopcart_title {
width: 100%;
height: 70rpx;
line-height: 80rpx;
text-align: center;
position: fixed;
left: 0;
background-color: #0e9eda;
color: #fff;
}
/*返回按钮 */
.shopcart_close {
position: absolute;
right: 30rpx;
font-size: 28rpx;
}
.margin_r {
margin-right: 30rpx;
}
/*购物车列表 */
.cart_cells {
width: 100%;
height: 98rpx;
position: relative;
}
.cells_name {
padding-left: 20rpx;
width: 50%;
position: absolute;
left:0;
top: 20rpx;
}
.price-box {
width: 40%;
font-size: 32rpx;
position: absolute;
left: 60%;
top: 20rpx;
color: #01bf05;
}
.complete{
background-image: linear-gradient(45deg, #0081ff, #1cbbb4);
color:white;
position: absolute;
left:2.5%;
width:95%;
border-radius: 50rpx;
}
.fenxi2 {
position: relative;
top:100rpx;
width: 100%;
height: 200rpx;
background: #fff;
}

@ -0,0 +1,186 @@
import Data from '../../utils/data.js'
Page({
/**
* 页面的初始数据
*/
data: {
recommendList:[],
foods: [{ name: '鸡蛋', quantity: '5个' }, { name: '番茄', quantity: '5个' }, { name: '葱', quantity: '1根' }, { name: '盐', quantity: '1勺' }, { name: '油', quantity: '适量' }, { name: '砂糖', quantity: '少许' },],
steps: [{
image:'http://i2.chuimg.com/5bcd1e1f8acb4179a73231b37783b80b_2048w_1722h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "选择比较成熟的番茄,捏着比较软,这样的番茄多汁,味道好一些,然后用刀划十字,放入开水里面烫一下,过入凉水,去皮"
}, {
image: 'http://i2.chuimg.com/38fbba613b844b198311dbd43f5c6683_2022w_2048h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "番茄切成小块儿,喜欢多汁的就切碎一点"
}, {
image: 'http://i2.chuimg.com/2fd03bec614a46ab841d8208d3e28bf9_2000w_2668h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "大蒜去皮切成蒜末"
}, {
image: 'http://i2.chuimg.com/c0b9dea31a90433092d43dea7ea54363_2208w_1536h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "小葱切碎"
}, {
image: 'http://i2.chuimg.com/d539ffda408d4214ae22d57b2d1d4bd5_2048w_1804h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "鸡蛋加少许盐打散"
}, {
image: 'http://i2.chuimg.com/b683696efb95484c90500761b491a8b7_2668w_2668h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "锅里放油烧热,倒入蛋液,用筷子划,凝固就可以出锅备用"
}, {
image: 'http://i2.chuimg.com/7797e400f6c345dcb27e05fa2dfafaa8_2668w_2668h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "就着炒鸡蛋的油,可以不再放油,锅里放入番茄翻炒,加入盐"
}, {
image: 'http://i2.chuimg.com/295a0a61d7f64641b1e709cb04ed16bb_2000w_2668h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "汤汁比较浓厚时,放入炒好的鸡蛋"
}, {
image: 'http://i2.chuimg.com/c96a27ef3e1c45c0910d920c2c281cf8_1000w_1000h.jpg?imageView2/2/w/300/interlace/1/q/90',
text: "翻炒一下,就可以出锅了,最后撒上葱花。"
},],
Tab:['营养成分'],
build:false,
id:1,
carts: [], // 购物车列表
delFlag: true,
buiFlag: true,
fat:10,
carbs:10,
protein:42,
TabCur: 0,
},
/**
* 生命周期函数--监听页面加载
*/
onShow: function (options) {
},
onLoad: function (options) {
var id = options.id;
var build = options.build || false;
var value = wx.getStorageSync('meal') || [];
var diary = wx.getStorageSync('diary') || [];
var temp = value[id];
var tab = ['营养成分','推荐食谱']
if(temp.cata.indexOf("food")!=-1){
this.setData({
buiFlag: false,
Tab:tab
});
}
var carts = [];
carts.push(temp);
this.getRecommend(temp);
for (var i = 0; i < diary.length; i++) {
if(diary[i].id == carts[0].id){
this.setData({
delFlag:false
});};
}
this.setData({
build:build,
carts:carts
});
},
add: function () {
this.setData({
delFlag: false
});
var value = wx.getStorageSync('diary') || [];
var id = this.data.remarks;
var carts = this.data.carts;
value.push(carts[0]);
wx.setStorageSync('diary', value);
var meal = wx.getStorageSync('meal');
console.log(meal[carts[0].id].name)
meal[carts[0].id].add=true;
wx.setStorageSync('meal', meal);
wx.showToast({
title: '已加入今日食谱',
icon: 'success',
duration: 2000
})
},
del: function () {//删除diary中的食谱
this.setData({
delFlag: true
});
var diary = wx.getStorageSync('diary');
var carts = this.data.carts;
var index = 0;
for (var i = 0; i < diary.length; i++) {
if (diary[i].id == carts[0].id) {
index = i;
};
}
diary.splice(index, 1);
wx.setStorageSync('diary', diary)
var meal = wx.getStorageSync('meal');
meal[carts[0].id].add = false;
wx.setStorageSync('meal', meal);
wx.showToast({
title: '已移出今日食谱!',
icon: 'success',
duration: 2000
})
},
bui: function () {//跳转到home
var cart = wx.getStorageSync('cart') || [];
var tcarts = this.data.carts;
var build = this.data.build;
for(var i=0;i<cart.length;i++){
if(tcarts[0].id == cart[i].id){
cart[i].quantity+=1;
tcarts[0].quantity += 1;
}
}
if (tcarts[0].quantity < 1) { tcarts[0].quantity += 1;cart.push(tcarts[0]);}
wx.setStorageSync('cart', cart);
if(build){
wx.navigateBack()
}else{
wx.redirectTo({
url: '../home/home'
})}
},
tabSelect(e) {
this.setData({
TabCur: e.currentTarget.dataset.id,
})
},
getRecommend(tmp) {
var meal = wx.getStorageSync('meal') || [];
var swiperList = []
var food = tmp
for (var j = Data.getFoodNum(); j < meal.length; j++) {
var m = meal[j]
m.foodscore = m.foodscore || parseInt(m.score)
var list = m.list
for (var k = 0; k < list.length; k++) {
if (list[k] == food.id) {
console.log(m.name)
m.foodscore += 10
break
}
}
}
console.log(meal)
meal.sort(function (a, b) {
return (a.foodscore || 0) - (b.foodscore || 0)
})
console.log(meal)
for (var i = meal.length - 1; i > meal.length - 6; i--) {
swiperList.push(meal[i])
}
console.log(swiperList)
this.setData({
recommendList: swiperList
})
}
})

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "食物详情"
}

@ -0,0 +1,120 @@
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">食物详情</view>
</cu-custom>
<view class="cart-list" wx:for="{{carts}}" wx:key="{{index}}">
<view class="cart-thumb-box">
<image class="cart-thumb" src="{{item.image}}"></image>
</view>
<text class="cart-pro-name">{{item.name}}</text>
<text class="cart-pro-info">{{item.cal}}kcal·{{item.amount}}g</text>
<view class="cart-pro-score" style='border-color:{{item.color}}'><text>{{item.score}}</text></view>
<text class="cart-pro-eva">{{item.eva}}</text>
<button class="add" bindtap="add"><text class="cuIcon-roundadd"> </text> 加入今日份食谱</button>
<button hidden="{{delFlag}}" class="del" bindtap="del"><text class="cuIcon-roundclose"> </text> 移出今日份食谱</button>
<button hidden="{{buiFlag}}" class="bui" bindtap="bui"><text class="cuIcon-roundadd"> </text> 制作膳食</button>
<view class="more-info-bg">
<scroll-view scroll-x class="bg-white nav">
<view class="flex text-center">
<view class="cu-item flex-sub {{index==TabCur?'text-blue cur':''}}" wx:for="{{2}}" wx:key bindtap="tabSelect" data-id="{{index}}">
{{Tab[index]}}
</view>
</view>
</scroll-view>
<view style="width:100vw;">
<view class="padding flex text-center text-grey bg-white">
<view class="flex flex-sub flex-direction solid-right">
<view class="flex align-end justify-center">
<view class="text-xxl text-blue ">{{item.nutrition[0]}}</view>
<view class="text-s text-blue padding-left-xs padding-bottom-xs" >g</view>
</view>
<view class="margin-top-sm">糖</view>
</view>
<view class="flex flex-sub flex-direction solid-right">
<view class="flex align-end justify-center">
<view class="text-xxl text-blue ">{{item.nutrition[1]}}</view>
<view class="text-s text-blue padding-left-xs padding-bottom-xs" >g</view>
</view>
<view class="margin-top-sm">蛋白质</view>
</view>
<view class="flex flex-sub flex-direction">
<view class="flex align-end justify-center">
<view class="text-xxl text-blue ">{{item.nutrition[2]}}</view>
<view class="text-s text-blue padding-left-xs padding-bottom-xs" >g</view>
</view>
<view class="margin-top-sm">脂肪</view>
</view>
</view>
<view class="detail-info-box text-xl">
<text class="left">膳食纤维</text>
<text class="right">{{item.nutrition[3]}}g</text>
<text class="left">\n胆固醇</text>
<text class="right">{{item.nutrition[4]}}mg</text>
<text class="left">\n维生素A</text>
<text class="right">{{item.nutrition[5]}}ug</text>
<text class="left">\n维生素B1</text>
<text class="right">{{item.nutrition[6]}}mg</text>
<text class="left">\n维生素B2</text>
<text class="right">{{item.nutrition[7]}}mg</text>
<text class="left">\n维生素C</text>
<text class="right">{{item.nutrition[8]}}mg</text>
<text class="left">\n维生素E</text>
<text class="right">{{item.nutrition[9]}}mg</text>
<text class="left">\n叶酸</text>
<text class="right">{{item.nutrition[10]}}ug</text>
<text class="left">\n钙</text>
<text class="right">{{item.nutrition[11]}}ug</text>
<text class="left">\n铁</text>
<text class="right">{{item.nutrition[12]}}mg</text>
<text class="left">\n钾</text>
<text class="right">{{item.nutrition[13]}}mg</text>
<text class="left">\n锌</text>
<text class="right">{{item.nutrition[14]}}mg</text>
</view>
</view>
<!--
<view class="more-info shadow-warp" wx:if="{{TabCur==1 && buiFlag}}">
<view class="detail-info-box">
<view class='text-blue text-xl'>用料:</view>
<view class="infood" wx:for="{{foods}}" wx:key="{{index}}">
<text class="left">{{item.name}}</text>
<text class="right">{{item.quantity}}</text>
</view>
<view class='margin-top text-blue text-xl'>步骤:</view>
<view class="infood" wx:for="{{steps}}" wx:key="{{index}}">
<text class="">第 {{index+1}} 步:</text>
<image class='steps radius shadow-wrap' src='{{item.image}}'></image>
<text>{{item.text}}</text>
</view>
</view>
</view> -->
<!-- <view class="more-info shadow-warp" wx:if="{{TabCur==1 && !buiFlag}}">
<view class="cu-list menu-avatar">
<view class="solid-bottom cu-item" wx:for="{{recommendList}}" wx:key="{{index}}">
<navigator url="../details/details?id={{item.id}}">
<image class="thumb" src="{{item.image}}" mode="widthFix"></image></navigator>
<view class="content">
<view class="text-black">{{item.name}}</view>
<view class="text-gray text-sm">{{item.cal}}kcal·{{item.amount}}g</view>
</view>
<view class="right-box" style="text-align:center;padding:10rpx;width:100rpx">
<view class="text-black text-xxl" style='border:1px solid {{item.color}};border-radius:15rpx;'>
{{item.score}}</view>
<view class="text-grey text-xs">{{item.eva}}</view>
</view>
</view>
</view>
</view> -->
</view>
</view>

@ -0,0 +1,144 @@
page{
background-color: #fff;
}
.cart-list{
background-color: #fff;
position: relative;
border-bottom: 1rpx solid #e9e9e9;
}
.cart-list .cart-thumb-box{
border-bottom: 1rpx solid #e9e9e9;
position: absolute;
width: 100%;
height: 400rpx;
overflow: hidden;
}
.cart-list .cart-thumb{
position: absolute;
top:-100rpx;
width:100%;
height:600rpx;
}
.cart-list .cart-pro-name{
position:absolute;
top:410rpx;
left:20rpx;
padding: 20rpx 20rpx 20rpx 20rpx;
width: 60%;
height: 100rpx;
text-align: left;
font-size: 80rpx;
overflow: hidden;
}
.cart-list .cart-pro-info{
color:#999;
font-size: 40rpx;
position:absolute;
top:540rpx;
left:20rpx;
padding: 20rpx 20rpx 20rpx 20rpx;
width: 60%;
line-height: 50rpx;
overflow: hidden;
}
.cart-list .cart-pro-score{
border:lightgray;
border-style: solid;
border-width: 1px;
border-radius: 10px;
position: absolute;
font-size: 75rpx;
top: 440rpx;
right: 30rpx;
display: flex; justify-content: center;align-items: center;
padding: 10rpx 10rpx 10rpx 10rpx;
width: 150rpx;
height: 130rpx;
}
.cart-list .cart-pro-eva{
color:#999;
position: absolute;
font-size: 30rpx;
top: 570rpx;
right: 30rpx;
overflow: hidden;
text-align: center;
width: 150rpx;
}
.add{
position: absolute;
top:325px;
left:2.5%;
border-radius: 30px;
border-bottom: 1rpx solid #e9e9e9;
background-image: linear-gradient(45deg, #0081ff, #1cbbb4);
width: 95%;
color:#fff;
}
.del{
position: absolute;
top:325px;
left:2.5%;
border-radius: 30px;
border-bottom: 1rpx solid #e9e9e9;
background-image: linear-gradient(45deg, #f43f3b, #ec008c);
width: 95%;
color:#fff;
}
.bui{
position: absolute;
top:325px;
left:2.5%;
border-radius: 30px;
border-bottom: 1rpx solid #e9e9e9;
background-image: linear-gradient(45deg, #0081ff, #1cbbb4);
width: 95%;
color:#fff;
}
.more-info-bg{
position: absolute;
top:400px;
border-top: 1rpx solid #e9e9e9;
width: 100%;
height:100%;
}
.more-info-bg .more-info{
position: absolute;
top:120rpx;
left:3%;
background-color:#fff;
width: 94%;
}
.detail-info-box{
font-size:28rpx;
line-height: 40px;
padding: 20px 20px 20px 20px;
}
.right{
float: right;
}
.steps{
width:600rpx;
}
.thumb{
border: lightgrey;
border-style: solid;
border-width: 1px;
border-bottom-left-radius: 10px;
border-top-left-radius: 10px;
border-bottom-right-radius: 10px;
border-top-right-radius: 10px;
position: absolute;
top: 20rpx;
left: 30rpx;
width: 100rpx;
height: 100rpx;
}

@ -0,0 +1,161 @@
import Canvas from '../../utils/canvas.js'
var util = require('../../utils/util.js');
Page({
...Canvas.options,
/**
* 页面的初始数据
*/
data: {
...Canvas.data,
carts: [], // 购物车列表
hasList: false, // 列表是否有数据
totalScore: 10, // 总价初始为0
daka:true,
hasdaka:true,
canvasShow:false,
},
/**
* 生命周期函数--监听页面加载
*/
onShow: function (options) {
//检查今天是否已经打了卡
var time = util.formatTime(new Date());
var today = wx.getStorageSync(time);
if(today.length>0){
this.setData({
hasdaka:false,
})
}else{
this.setData({
hasdaka: true,
})
}
var value = wx.getStorageSync('diary')
if (value.length) {
this.setData({
hasList: true, // 既然有数据了那设为true吧
carts: value,
});}else{
this.setData({
hasList: false,
carts: [],
});
}
this.getScore();
},
deleteList(e) {
const index = e.currentTarget.dataset.index;
let carts = this.data.carts;
var meal = wx.getStorageSync("meal");
meal[carts[index].id].add=false;
wx.setStorageSync("meal", meal)
carts.splice(index, 1);
wx.setStorageSync('diary', carts);
this.setData({
carts: carts
});
if (!carts.length) {
this.setData({
hasList: false
});
}
this.getScore();
wx.showToast({
title: '已移出今日食谱!',
icon: 'success',
duration: 2000
})
},
getScore() {
let carts = this.data.carts; // 获取购物车列表
let total = 0;
let has=this.data.hasdaka;
for (let i = 0; i < carts.length; i++) { // 循环列表得到每个数据
total += carts[i].score / carts.length;
}
this.setData({ // 最后赋值到data中渲染到页面
carts: carts,
totalScore: total.toFixed(1)*10
});
this.draw('runCanvas', total*10, 500);
if(total>=5 && has==true){
this.setData({ // 最后赋值到data中渲染到页面
daka: false,
});
}else{
this.setData({ // 最后赋值到data中渲染到页面
daka: true,
});
}
},
daka: function(e){
this.setData({
hasdaka: false,
daka:true,
modalName: 'dakaSuccess',
})
var time = util.formatTime(new Date());
console.log(time);
var gold = wx.getStorageSync('gold') || 0
gold += 1;
wx.setStorageSync('gold', gold)
var selected = wx.getStorageSync('selected') || []
selected.push({date:time})
wx.setStorageSync('selected', selected)
var diary = this.data.carts;
wx.setStorageSync(time, diary);
var daka=wx.getStorageSync("daka") || 0
wx.setStorageSync("daka", daka+1);
},
// ListTouch触摸开始
ListTouchStart(e) {
this.setData({
ListTouchStart: e.touches[0].pageX
})
},
// ListTouch计算方向
ListTouchMove(e) {
this.setData({
ListTouchDirection: e.touches[0].pageX - this.data.ListTouchStart > 0 ? 'right' : 'left'
})
},
// ListTouch计算滚动
ListTouchEnd(e) {
if (this.data.ListTouchDirection == 'left') {
this.setData({
modalName: e.currentTarget.dataset.target
})
} else {
this.setData({
modalName: null
})
}
this.setData({
ListTouchDirection: null
})
},
showModal(e) {
this.setData({
canvasShow:true,
modalName: e.currentTarget.dataset.target
})
},
hideModal(e) {
this.setData({
canvasShow: false,
modalName: null
})
},
})

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "今日得分"
}

@ -0,0 +1,70 @@
<view class='canvasBox'>
<view class="bg-gradual-blue">
<view class='canvas-score' hidden='{{canvasShow}}'>
<view class='biggerCircle'></view>
<view class='bigCircle'></view>
<view class='littleCircle'></view>
<canvas canvas-id="runCanvas" id="runCanvas" class='canvas'></canvas>
</view>
</view>
</view>
<view class="cart-title">
<text>今日份食谱:</text>
<view class="daka2" hidden='{{!hasdaka||!daka}}'>打卡</view>
<view class="daka" hidden='{{daka}}' bindtap="showModal" data-target="dakaConfirm"> 打卡 </view>
<view class="daka" hidden='{{hasdaka}}'>已打卡</view>
</view>
<view wx:if="{{hasList}}">
<view class="cu-list menu-avatar">
<view class="solid-bottom cu-item {{modalName=='move-box-'+ index?'move-cur':''}}" wx:for="{{carts}}" wx:key="{{index}}" bindtouchstart="ListTouchStart" bindtouchmove="ListTouchMove" bindtouchend="ListTouchEnd" data-target="move-box-{{index}}">
<navigator url="../details/details?id={{item.id}}">
<image class="thumb" src="{{item.image}}"></image></navigator>
<view class="content">
<view class="text-black">{{item.name}}</view>
<view class="text-gray text-sm">{{item.cal}}kcal·{{item.amount}}g</view>
</view>
<view class="right-box" style="text-align:center;padding:10rpx;width:100rpx">
<view class="text-black text-xxl" style='border:1px solid {{item.color}};border-radius:15rpx;'>
{{item.score}}</view>
<view class="text-grey text-xs">{{item.eva}}</view>
</view>
<view class="move">
<view class="bg-gradual-red" data-index="{{index}}" bindtap='deleteList'>
<text class="cuIcon-roundclose xxl text-white"></text></view>
</view>
</view>
</view>
</view>
<view wx:else>
<view class="cart-no-data">今日份食谱是空的哦~</view>
</view>
<view class="cu-modal {{modalName=='dakaConfirm'?'show':''}}">
<view class="cu-dialog">
<view class="cu-bar bg-white justify-end">
<view class="content">确定要打卡吗?</view>
</view>
<view class="cu-bar bg-white justify-center">
<view class="action">
<button class="cu-btn bg-blue" bindtap="daka">确定</button>
<button class="cu-btn line-blue text-blue margin-left" bindtap="hideModal">取消</button>
</view>
</view>
</view>
</view>
<view class="cu-modal {{modalName=='dakaSuccess'?'show':''}}">
<view class="cu-dialog">
<view class="cu-bar bg-white justify-end">
<view class="content">打卡成功</view>
<view class="action" bindtap="hideModal">
<text class="cuIcon-close text-blue"></text>
</view>
</view>
<view class="padding-xl">
获得1枚金币
</view>
</view>
</view>

@ -0,0 +1,123 @@
.canvasBox{
height: 600rpx;
position: relative;
background-image: linear-gradient(45deg, #0081ff, #1cbbb4);
}
.title{
position: relative;
top:50rpx;
font-size:35rpx;
text-align: center;
color:#fff;
}
.biggerCircle{
border:2px solid springgreen;
width: 435rpx;
height: 435rpx;
border-radius: 50%;
position: absolute;
top:100rpx;
bottom: 0;
left: 0;
right: 0;
margin: auto auto;
background-image: linear-gradient(45deg, #0081ff, #1cbbb4);
}
.bigCircle{
width: 415rpx;
height: 415rpx;
border-radius: 50%;
position: absolute;
top:100rpx;
bottom: 0;
left: 0;
right: 0;
margin: auto auto;
background-color: #ddd;
}
.littleCircle{
width: 392rpx;
height: 392rpx;
border-radius: 50%;
position: absolute;
top:100rpx;
bottom: 0;
left: 0;
right: 0;
margin: auto auto;
background-image: linear-gradient(45deg, #0081ff, #1cbbb4);
}
.canvas{
width: 420rpx;
height: 420rpx;
position: absolute;
left: 0;
top:100rpx;
bottom: 0;
right: 0;
margin: auto auto;
z-index: 99;
}
.cart-title{
bottom: 0;
left: 0;
width: 100%;
height: 90rpx;
padding:20rpx 30rpx 20rpx 30rpx;
box-sizing: border-box;
background: ghostwhite;
color: #000;
}
.cart-no-data{
padding:40rpx 0;
color: #999;
text-align: center;
}
.daka{
position: relative;
float: right;
top: 0rpx;
right:0rpx;
text-align: center;
color: #0e9eda;
width:120rpx;
height: 50rpx;
border: 1px solid #0e9eda;
border-radius: 10rpx;
z-index: 2;
}
.daka2{
position: relative;
float: right;
top: 0rpx;
right:0rpx;
text-align: center;
color: #e9e9e9;
width:120rpx;
height: 50rpx;
border: 1px solid #e9e9e9;
border-radius: 10rpx;
z-index: 1;
}
.thumb{
border: lightgrey;
border-style: solid;
border-width: 1px;
border-bottom-left-radius: 10px;
border-top-left-radius: 10px;
border-bottom-right-radius: 10px;
border-top-right-radius: 10px;
position: absolute;
top: 20rpx;
left: 30rpx;
width: 100rpx;
height: 100rpx;
}

@ -0,0 +1,15 @@
//index.js
//获取应用实例
const app = getApp()
Page({
data: {
},
onLoad: function () {
},
search: function (e) {
wx.navigateTo({
url: '../search/search?cata=food',
})
},
})

@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "膳食"
}

@ -0,0 +1,49 @@
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">食材</view>
</cu-custom>
<!--index.wxml-->
<view class="container">
<view class='main-block'>
<view class="weui-search-bar">
<view class="weui-search-bar__form">
<view class="weui-search-bar__box">
<icon class="weui-icon-search_in-box" type="search" size="14"></icon>
<view bindtap="search"class="weui-search-bar__input">今天你想吃什么?</view>
</view>
</view>
</view>
</view>
<view class='list'>
<view class='list-row'>
<view class='list1' >
<view class='list-img'><navigator url="../searchresult/searchresult?cata=grain"><image src='../../images/grain.jpg'></image></navigator> </view>
<view class='list-type'><text class='xxl'>五谷杂粮</text></view>
</view>
<view class='list1' >
<view class='list-img'><navigator url="../searchresult/searchresult?cata=vegetable"><image src='../../images/vegetables.jpg'></image></navigator> </view>
<view class='list-type'><text class='xxl'>蔬菜</text></view>
</view>
</view>
<view class='list-row'>
<view class='list1' >
<view class='list-img'><navigator url="../searchresult/searchresult?cata=fruit"><image src='../../images/fruit.jpg'></image></navigator> </view>
<view class='list-type'><text class='xxl'>水果</text></view>
</view>
<view class='list1' >
<view class='list-img'><navigator url="../searchresult/searchresult?cata=meat"><image src='../../images/meat.jpg'></image></navigator> </view>
<view class='list-type'><text class='xxl'>肉、蛋和水产</text></view>
</view>
</view>
</view>
</view>

@ -0,0 +1,31 @@
/**index.wxss**/
page{
background-color: #fff;
}
.main-block{
height: 50px;
width: 100%;
background-color: rgba(153, 153, 153, 0.103);
margin-top: -100px;
}
.list{
position: relative;
left:-3%;
}
.list-img image{
width: 150px;
height: 150px;
border-radius: 15px;
}
.list1{
margin-left: 20px;
margin-top: 20px;
float: left;
}
.weui-search-bar__input {
height: 28px;
line-height: 28px;
font-size: 14px;
color:#999;
}

@ -0,0 +1,85 @@
// pages/help/help.js
Page({
data: {
memberList: [
{
cont: "如何使用iNutrition",
hiddena: true,
id: "0",
invalidActivty: [
{help: "iNutrition很容易使用您只需要在User-身体数据面板中输入您的个人信息和身体数据,就可以得到您的健康指数和为您订制的每种食材、膳食和零食的个性化评分。您可以选择我们预设的膳食或者自己制作膳食加入到食谱中,获得每日食谱的健康评分(0~10)。"
},
]
},
{
cont: "如何查找我想吃的食物?",
hiddena: true,
id: "1",
invalidActivty: [
{
help: "在Search面板中选择食物的分类或者在上方的搜索框输入食物名称即可。食物栏以您的个性化评分进行排序。我们支持在不同的分类中查找食物。同时我们为每个食物分类都加入了我们的推荐可供您进行参考。",
},
]
},
{
cont: "如何查看膳食的详细信息?",
hiddena: true,
id: "2",
invalidActivty: [
{
help: "点击膳食图片即可跳转到膳食详情面板中。在膳食详情面板中,你可以将其加入或移除今日食谱。此外,在食材的详情面板中,你可以跳转到制作膳食界面,系统将为您将要制作的膳食添加一份该项食材。",
},
]
},
{
cont: "如何制作自定义的膳食?",
hiddena: true,
id: "3",
invalidActivty: [
{
help: "在Build面板中点击[+ 制作膳食]按钮,选择食材的种类和数量,以及膳食的烹饪方式,即可制作属于你的膳食,系统会自动给出它的健康评分。你也可以在食材栏优化点击[+]按钮或者在食材的详情面板选择[+ 制作膳食],系统会为你跳转到制作膳食界面,并为您将要制作的膳食添加一份该项食材。",
},
]
},
{
cont: "如何将膳食加入到每日食谱中?",
hiddena: true,
id: "4",
invalidActivty: [
{
help: "在膳食栏向左滑动,点击[+]按钮即可。或者点击膳食图片进入膳食的详情界面,点击[+ 加入今日食谱]即可。您也可以点击[- 移除今日食谱]或在Diary面板中点击[x]按钮来从今日食谱中删除此膳食。",
},
]
},
{
cont: "如何为当天的食谱打卡?",
hiddena: true,
id: "5",
invalidActivty: [
{
help: "在Diary面板中点击打卡按钮即可将当天的食谱和评分保存到打卡记录中。我们设置的是当日食谱的健康评分达到5分后才会开放打卡按钮。在User-打卡记录面板中,你可以直观地看到你的打卡情况和食谱记录,以及健康指数的变化情况。",
},
]
},
]},
isOpen: function (e) {
var that = this;
var idx = e.currentTarget.dataset.index;
console.log(idx);
var memberList = that.data.memberList;
console.log(memberList);
for (let i = 0; i < memberList.length; i++) {
if (idx == i) {
memberList[i].hiddena = !memberList[i].hiddena;
} else {
memberList[i].hiddena = true;
}
}
this.setData({ memberList: memberList });
return true;
},
})

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "帮助中心"
}

@ -0,0 +1,21 @@
<cu-custom bgColor="bg-gradual-blue" isBack="{{true}}">
<view slot="backText">返回</view>
<view slot="content">帮助中心</view>
</cu-custom>
<view class="cells">
<view class="item" wx:for="{{memberList}}" wx:for-index="idx" wx:for-item="item" wx:key="idx">
<view bindtap="isOpen" class="cdn" data-index="{{item.id}}">
<view>
<image class="img" src="/images/helphelp.png" mode="aspectFill"/><text class="content">{{item.cont}}</text>
</view>
<view>
<image class="icon_img" src="{{item.hiddena ? '/images/dow.png' : '/images/upp.png'}}" mode="aspectFill"/>
</view>
</view>
<view hidden="{{item.hiddena}}" class="hidden">
<block wx:for="{{item.invalidActivty}}" wx:for-index="index" wx:for-item="items" wx:key="index">
<view class="help">{{items.help}}</view>
</block>
</view>
</view>
</view>

@ -0,0 +1,115 @@
page{
background: #fff;
}
.swiper-img{
width: 750rpx;
height: 300rpx;
}
.cells .item .cdn{
position: relative;
box-sizing:border-box;
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 30rpx;
/*border-bottom: 1rpx solid #f0f0f0;*/
background-color: #fff;
font-size: 32rpx;
}
.cells .item .cdn::after{
content:'';position:absolute;top:0;left:0;width:200%;height:200%;-webkit-transform:scale(.5);transform:scale(.5);-webkit-transform-origin:0 0;transform-origin:0 0;pointer-events:none;box-sizing:border-box;border-bottom:0 solid #f0f0f0;border-width:1px
}
.img{
height: 50rpx;
width: 50rpx;
vertical-align: middle;
display: inline-block;
line-height: 82rpx;
margin-right:10px;
}
.icon_img{
height:30rpx;
width:30rpx;
}
.content{
font-size:30rpx;
margin-left: 15rpx;
line-height: 82rpx;
vertical-align: middle;
}
.video-item{
display: flex;
flex-direction: column;
}
.buys{
width:750rpx;
height: 141.6rpx;
position: relative;
box-sizing: border-box;
padding: 20rpx 30rpx;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
background-color:#FAFAFA;
}
.buys::after {
content:'';position:absolute;top:0;left:0;width:200%;height:200%;-webkit-transform:scale(.5);transform:scale(.5);-webkit-transform-origin:0 0;transform-origin:0 0;pointer-events:none;box-sizing:border-box;
border-bottom:0 solid #DCDCDC;border-width:1px;
}
.v1{
width: 35%;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.new-price{
font-size: 32rpx;
color: #3B3B3B;
}
.oldPrice{
text-decoration:line-through;
font-size: 24rpx;
color: #B0B0B0;
margin-left: 20rpx;
}
.buy{
font-size: 24rpx;
color: #2DAF73;
text-align: center;
width: 80rpx;
height: 40rpx;
line-height: 40rpx;
display: inline-block;
position: relative;
box-sizing: border-box;
}
.buy::after{
content:'';position:absolute;top:0;left:0;width:200%;height:200%;-webkit-transform:scale(.5);transform:scale(.5);-webkit-transform-origin:0 0;transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #2DAF73;border-width:1px;border-radius:8rpx
}
.shopping{
width: 128rpx;
height: 56rpx;
line-height: 56rpx;
position: relative;
box-sizing: border-box;
font-size: 28rpx;
color: #2DAF73;
text-align: center;
}
.shopping::after{
content:'';position:absolute;top:0;left:0;width:200%;height:200%;-webkit-transform:scale(.5);transform:scale(.5);-webkit-transform-origin:0 0;transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #2DAF73;border-width:1px;border-radius:16rpx
}
.help{
font-size:30rpx;
padding: 35rpx 35rpx 35rpx 35rpx;
}

@ -0,0 +1,499 @@
//logs.js
var util = require('../../utils/util.js')
import Data from '../../utils/data.js'
var sliderWidth = 190// 需要设置slider的宽度用于计算中间位置
// 最大行数
var max_row_height = 5;
// 行高
var food_row_height = 50;
// 底部栏偏移量
var cart_offset = 90;
Page({
data: {
array:['五谷杂粮','蔬菜','水果','肉、蛋、水产'],
next:true,
logs: [],
activeIndex: 0,
sliderOffset: 0,
sliderLeft: 0,
sliderWidth: 0.5,
// 右菜单
menu_list: [],
// 左菜单
foodList: [],//展示菜品
allFoodList: [],//所有获取到的菜品
//我的订单列表
orderList: [],
// 购物车
cartList: [],
hasList: true,// 列表是否有数据
totalPrice: 0,// 总价初始为0
totalNum: 0, //总数初始为0
totalWeight: 0, //总数初始为0
// 购物车动画
animationData: {},
animationMask: {},
maskVisual: "hidden",
maskFlag: true,
// 左右两侧菜单的初始显示次序
curNav: 0,
},
onShow: function (options) {
// 购物车总量、总价
var totalPrice = 0
var totalNum = 0
var totalWeight = 0
var flag = true;
// 更新购物车数量和总价、总重量、总数量
var arr = wx.getStorageSync('cart') || [];
var resFood = this.data.foodList;
console.log("下面打印foodList");
console.log(resFood)
// 进入页面后判断购物车是否有数据如果有将菜单与购物车quantity数据统一
if (arr.length > 0) {
flag = false;
for (var i in arr) {
for (var j in resFood) {
if (resFood[j].id == arr[i].id) {
resFood[j].quantity = arr[i].quantity;
}
}
}
for (var i in arr) {
totalPrice += arr[i].score * arr[i].quantity;
totalWeight += arr[i].amount * arr[i].quantity;
totalNum += Number(arr[i].quantity);
}
console.log(totalPrice);
totalPrice /= totalNum;
}
// 赋值数据
this.setData({
next: flag,
foodList: resFood,
allFoodList: resFood,
cartList: arr,
totalPrice: totalPrice.toFixed(1),
totalNum: totalNum,
totalWeight: totalWeight
})
wx.hideLoading();
},
onLoad: function (options) {
wx.showLoading({
title: '加载中',
})
var cata = options.cata || "food";
var keyword = options.keyword || "";
var flag = true;
var that = this
// 获取购物车缓存数据
var arr = wx.getStorageSync('cart') || [];
// 右菜品菜单
var foodList = that.data.foodList;
var allFoodList = that.data.allFoodList;
// 购物车总量、总价
var totalPrice = 0
var totalNum = 0
var totalWeight = 0
// 获取菜品列表数据
var meal = wx.getStorageSync("meal")
var resFood = [];
for (var i = 0; i < meal.length; i++) {
if (meal[i].name.indexOf(keyword) != -1 && meal[i].cata.indexOf(cata) != -1) {
resFood.push(meal[i]);
}
};
resFood.sort(that.compare("score"));
if(resFood.length>0){
that.setData({
hasList:true
})
}else{
that.setData({
hasList: false
})
}
// 进入页面后判断购物车是否有数据如果有将菜单与购物车quantity数据统一
if (arr.length > 0) {
flag = false;
for (var i in arr) {
for (var j in resFood) {
if (resFood[j].id == arr[i].id) {
resFood[j].quantity = arr[i].quantity;
}
}
}
for (var i in arr) {
totalPrice += arr[i].score * arr[i].quantity;
totalWeight += arr[i].amount * arr[i].quantity;
totalNum += Number(arr[i].quantity);
}
totalPrice /= totalNum;
}
// 赋值数据
that.setData({
next: flag,
cartList: arr,
foodList: resFood,
allFoodList: resFood,
totalPrice: totalPrice.toFixed(1),
totalNum: totalNum,
totalWeight: totalWeight
})
wx.hideLoading();
},
// 用户离开页面时触发的函数
onUnload: function() {
wx.setStorageSync('cart', [])
console.log("清空了cart")
},
// 购物车增加数量
addCount: function (e) {
var id = e.currentTarget.dataset.id;
var arr = wx.getStorageSync('cart') || [];
var f = false;
for (var i in this.data.foodList) {// 遍历菜单找到被点击的菜品数量加1
if (this.data.foodList[i].id == id) {
this.data.foodList[i].quantity += 1;
if (arr.length > 0) {
for (var j in arr) {// 遍历购物车找到被点击的菜品数量加1
if (arr[j].id == id) {
arr[j].quantity += 1;
f = true;
try {
wx.setStorageSync('cart', arr)
} catch (e) {
console.log(e)
}
break;
}
}
if (!f) {
arr.push(this.data.foodList[i]);
}
} else {
arr.push(this.data.foodList[i]);
}
try {
wx.setStorageSync('cart', arr)
} catch (e) {
console.log(e)
}
break;
}
}
this.setData({
next:false,
cartList: arr,
foodList: this.data.foodList
})
this.getTotalPrice();
},
// 定义根据id删除数组的方法
removeByValue: function (array, val) {
for (var i = 0; i < array.length; i++) {
if (array[i].id == val) {
array.splice(i, 1);
break;
}
}
},
// 购物车减少数量
minusCount: function (e) {
var id = e.currentTarget.dataset.id;
var arr = wx.getStorageSync('cart') || [];
for (var i in this.data.foodList) {
if (this.data.foodList[i].id == id) {
this.data.foodList[i].quantity -= 1;
if (this.data.foodList[i].quantity <= 0) {
this.data.foodList[i].quantity = 0;
}
if (arr.length > 0) {
for (var j in arr) {
if (arr[j].id == id) {
arr[j].quantity -= 1;
if (arr[j].quantity <= 0) {
this.removeByValue(arr, id)
}
if (arr.length <= 0) {
var p=0;
this.setData({
next:true,
foodList: this.data.foodList,
cartList: [],
totalNum: 0,
totalPrice: p.toFixed(1),
totalWeight:0,
})
this.cascadeDismiss()
}
try {
wx.setStorageSync('cart', arr)
} catch (e) {
console.log(e)
}
}
}
}
}
}
this.setData({
cartList: arr,
foodList: this.data.foodList
})
this.getTotalPrice();
},
// 获取购物车总价、总数
getTotalPrice: function () {
var cartList = this.data.cartList; // 获取购物车列表
var totalP = 0;
var totalN = 0;
var totalW = 0
for (var i in cartList) { // 循环列表得到每个数据
totalP += cartList[i].quantity * cartList[i].score; // 所有价格加起来
totalW += cartList[i].quantity * cartList[i].amount;
totalN += cartList[i].quantity
}
if(totalN!=0) {totalP /= totalN;}
this.setData({
cartList: cartList,
totalNum: totalN,
totalWeight: totalW,
totalPrice: totalP.toFixed(1)
});
},
// 清空购物车
cleanList: function (e) {
for (var i in this.data.foodList) {
this.data.foodList[i].quantity = 0;
}
try {
wx.setStorageSync('cart', "")
} catch (e) {
console.log(e)
}
this.setData({
next:true,
foodList: this.data.foodList,
cartList: [],
cartFlag: false,
totalNum: 0,
totalPrice: 0,
totalWeight:0 ,
})
this.cascadeDismiss()
},
//删除购物车单项
deleteOne: function (e) {
var id = e.currentTarget.dataset.id;
var index = e.currentTarget.dataset.index;
var arr = wx.getStorageSync('cart')
for (var i in this.data.foodList) {
if (this.data.foodList[i].id == id) {
this.data.foodList[i].quantity = 0;
}
}
arr.splice(index, 1);
if (arr.length <= 0) {
this.setData({
next:true,
foodList: this.data.foodList,
cartList: [],
cartFlag: false,
totalNum: 0,
totalPrice: 0.0,
})
this.cascadeDismiss()
}
try {
wx.setStorageSync('cart', arr)
} catch (e) {
console.log(e)
}
this.setData({
cartList: arr,
foodList: this.data.foodList
})
this.getTotalPrice()
},
//切换购物车开与关
cascadeToggle: function () {
var that = this;
var arr = this.data.cartList
if (arr.length > 0) {
if (that.data.maskVisual == "hidden") {
that.cascadePopup()
} else {
that.cascadeDismiss()
}
} else {
that.cascadeDismiss()
}
},
// 打开购物车方法
cascadePopup: function () {
var that = this;
// 购物车打开动画
var animation = wx.createAnimation({
duration: 200,
timingFunction: 'ease-in-out',
delay: 0
});
that.animation = animation;
animation.translate(0, -285).step();
that.setData({
animationData: that.animation.export(),
});
// 遮罩渐变动画
var animationMask = wx.createAnimation({
duration: 200,
timingFunction: 'linear',
});
that.animationMask = animationMask;
animationMask.opacity(0.8).step();
that.setData({
animationMask: that.animationMask.export(),
maskVisual: "show",
maskFlag: false,
});
},
// 关闭购物车方法
cascadeDismiss: function () {
var that = this
// 购物车关闭动画
that.animation.translate(0,285).step();
that.setData({
animationData: that.animation.export()
});
// 遮罩渐变动画
that.animationMask.opacity(0).step();
that.setData({
animationMask: that.animationMask.export(),
});
// 隐藏遮罩层
that.setData({
maskVisual: "hidden",
maskFlag: true
});
},
// 跳转确认订单页面
gotoOrder: function () {
wx.navigateTo({
url: '../confirmOrder/confirmOrder'
})
},
GetQueryString:function (name){
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
},
search: function (e) {
wx.navigateTo({
url: '../search-food/search',
})
},
compare: function (property) {
return function (a, b) {
var value1 = a[property];
var value2 = b[property];
return value2 - value1;
}
},
tabSelect: function (e) {
var that = this
var id = e.currentTarget.dataset.id
var array = ['grain','vegetable','fruit','meat']
var options = {
cata: array[id],
}
that.onLoad(options)
that.onShow()
},
camera() {
var that = this
var meal = wx.getStorageSync('meal')
wx.chooseImage({
count: 1, //默认9
sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], //从相册选择
success: function (res) {
wx.showLoading({
title: '识别中',
})
const tempFilePaths = res.tempFilePaths
console.log('upload...');
wx.uploadFile({
url: Data.getUrl()+'classifyImage',
filePath: tempFilePaths[0],
name: 'image',
success: function (res) {
console.log(res.data);
wx.hideLoading();
if(res.data==-1){
that.setData({
modalName: 'fail',
})
}else{
that.setData({
id:res.data,
camera:meal[res.data].name,
modalName: 'camera',
})
}
},fail: function(res){
wx.showToast({
title: '上传失败!',
})
}})
}, fail: function (res) {
wx.showToast({
title: '选择图片失败!',
})
}
});
},
cameraConfirm(e) {
this.setData({
canvasShow: false,
modalName: null
})
this.setData({
modalName: 'success',
})
var id =this.data.id
var cart = wx.getStorageSync('cart') || [];
var meal = wx.getStorageSync('meal')
var m =meal[id]
for (var i = 0; i < cart.length; i++) {
if (id == cart[i].id) {
cart[i].quantity += 1;
m.quantity += 1;
}
}
if (m.quantity < 1) {m.quantity += 1; cart.push(m);}
wx.setStorageSync('cart', cart);
this.onShow();
},
hideModal(e) {
this.setData({
canvasShow: false,
modalName: null
})
},
})

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "制作膳食"
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save