leon преди 1 година
родител
ревизия
a431ec8181

+ 19 - 19
config/dev.ts

@@ -5,25 +5,25 @@ module.exports = {
   defineConstants: {
   },
   mini: {
-    // webpackChain: (chain, webpack) => {
-    //   chain.merge({
-    //     plugin: {
-    //       install: {
-    //         plugin: require('terser-webpack-plugin'),
-    //         args: [
-    //           {
-    //             terserOptions: {
-    //               compress: true, // 默认使用terser压缩
-    //               // mangle: false,
-    //               keep_classnames: true, // 不改变class名称
-    //               keep_fnames: true, // 不改变函数名称
-    //             },
-    //           },
-    //         ],
-    //       },
-    //     },
-    //   })
-    // },
+    webpackChain: (chain, webpack) => {
+      chain.merge({
+        plugin: {
+          install: {
+            plugin: require('terser-webpack-plugin'),
+            args: [
+              {
+                terserOptions: {
+                  compress: true, // 默认使用terser压缩
+                  // mangle: false,
+                  keep_classnames: true, // 不改变class名称
+                  keep_fnames: true, // 不改变函数名称
+                },
+              },
+            ],
+          },
+        },
+      })
+    },
   },
   h5: {}
 }

+ 62 - 0
src/_eat/components/add_label.scss

@@ -0,0 +1,62 @@
+.header1{
+    height: 128px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    color: #4D4D4D;
+    font-size: 32px;
+}
+
+.body1{
+    height: 600px;
+}
+
+.input_lb{
+    margin-left: 40px;
+    margin-right: 40px;
+    height: 96px;
+    border: solid 2px #B2B2B2;
+    border-radius: 24px;
+    padding-left: 20px;
+    padding-right: 20px;
+    text-align: center;
+}
+
+.label_bg{
+    display: flex;
+    flex-direction: row;
+    flex-wrap: wrap;
+    margin-left: 40px;
+    margin-right: 40px;
+    margin-top: 40px;
+}
+
+.label{
+    margin-right: 16px;
+    margin-bottom: 16px;
+    height: 64px;
+    border-radius: 32px;
+    padding-left: 30px;
+    padding-right: 30px;
+    color: #B2B2B2;
+    background-color: #b2b2b225;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+
+}
+
+.pop_footer{
+    display: flex;
+    height: 88px;
+    border-radius: 44px;
+    margin-left: 84px;
+    margin-right: 84px;
+    background-color: #FF751A;
+    align-items: center;
+    justify-content: center;
+    color: #fff;
+    font-size: 32px;
+    font-weight: bold;
+    margin-bottom: 116px;
+}

+ 73 - 0
src/_eat/components/add_label.tsx

@@ -0,0 +1,73 @@
+import { View, Text, Input } from "@tarojs/components";
+import './add_label.scss'
+import { useState } from "react";
+import Modal from "@/components/layout/Modal.weapp";
+import TimePicker from "@/features/common/TimePicker";
+import dayjs from "dayjs";
+import { MainColorType } from "@/context/themes/color";
+import { createSchedule } from "@/services/health";
+import Taro from "@tarojs/taro";
+
+export default function AddLabel(props: { labels: any }) {
+    const [showTimePicker,setShowTimePicker] = useState(false)
+    const [value,setValue] = useState('')
+
+    function timeContent() {
+        return <Modal
+            testInfo={null}
+            dismiss={() => {
+                setShowTimePicker(false)
+            }}
+            confirm={() => { }}>
+            {
+                pickerContent()
+            }
+        </Modal>
+    }
+
+    function pickerContent(){
+        const strTime = dayjs().format('HH:mm')
+        return <TimePicker time={strTime}
+            color={MainColorType.eat}
+            title='开始时间'
+            confirm={(e) => {
+                confirmPickerTime(e)
+            }}
+            cancel={() => {
+                setShowTimePicker(false)
+            }} />
+    }
+
+    function confirmPickerTime(e){
+        createSchedule({
+            category:'EAT',
+            label:value,
+            time:e
+        }).then(res=>{
+            global.refreshFastEat()
+            if (process.env.TARO_ENV=='weapp'){
+                Taro.navigateBack()
+            }
+        })
+    }
+    
+    return <View>
+        <View className="header1">标记为</View>
+        <View className="body1">
+            <Input className="input_lb" placeholder="选择或输入标签" value={value} onInput={(e:any)=>{
+                setValue(e.target.value)
+            }}/>
+            <View className="label_bg">
+                {
+                    props.labels.map((item,index)=>{
+                        return <View className="label" key={index} onClick={()=>setValue(item.label)}>{item.label}</View>
+                    })
+                }
+            </View>
+        </View>
+        <View className="pop_footer" onClick={()=>setShowTimePicker(true)}>下一步</View>
+        {
+            showTimePicker && timeContent()
+        }
+    </View>
+}

+ 62 - 0
src/_eat/pages/meal_list.scss

@@ -0,0 +1,62 @@
+.container {
+    display: flex;
+    flex-direction: column;
+    flex: 1;
+}
+
+.item {
+    margin-left: 46px;
+    margin-right: 46px;
+    height: 114px;
+    align-items: center;
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    position: relative;
+}
+
+.item_line{
+    height: 2px;
+    background-color: #B2B2B2;
+    transform: scaleY(0.5);
+    position: absolute;
+    left: 0;
+    right: 0;
+    bottom: 0;
+}
+
+.item_left{
+    display: flex;
+    flex-direction: column;
+    flex: 1;
+}
+
+.item_index{
+    color: #B2B2B2;
+    font-size: 18px;
+}
+
+.item_name{
+    color: #4D4D4D;
+    font-size: 34px;
+}
+
+.item_time{
+    color: #B2B2B2;
+    font-size: 34px;
+}
+
+.toolbar{
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    margin-top: 20px;
+    margin-bottom: 20px;
+    padding-left: 46px;
+    padding-right: 46px;
+}
+
+.toolbar_btn{
+    color: #FF751A;
+    font-size: 30px;
+}

+ 0 - 0
src/components/input/Pickers.tsx → src/_eat/pages/meal_list.ts.config


+ 64 - 0
src/_eat/pages/meal_list.tsx

@@ -0,0 +1,64 @@
+import { View, Text } from '@tarojs/components'
+import './meal_list.scss'
+import { useEffect, useState } from 'react'
+import Modal from '@/components/layout/Modal.weapp'
+import AddLabel from '../components/add_label'
+import { getLabels, getSchedules } from '@/services/health'
+
+export default function MealList() {
+    const [showModal, setShowModal] = useState(false)
+    const [list, setList] = useState<any>([])
+    const [labels,setLabels] = useState<any>([])
+
+    useEffect(() => {
+        schedules()
+    }, [])
+
+    function schedules() {
+        getSchedules({ category: 'EAT' }).then(res => {
+            if ((res as any).schedules && (res as any).schedules.length > 0) {
+                setList((res as any).schedules[0].items)
+            }
+        }).catch(e => {
+
+        })
+
+        getLabels({category: 'EAT'}).then(res=>{
+            setLabels((res as any).labels)
+        })
+    }
+
+    function add() {
+        setShowModal(true)
+    }
+
+    return <View>
+        {
+            list.map((item, index) => {
+                return <View className='item' key={index}>
+                    <View className='item_left'>
+                        <Text className='item_index'>第{index+1}餐</Text>
+                        <Text className='item_name'>{item.label}</Text>
+                    </View>
+                    <Text className='item_time'>{item.time}</Text>
+                    <View className='item_line' />
+                </View>
+            })
+        }
+
+        <View className='toolbar'>
+            <View className='toolbar_btn' onClick={add}>添加一餐</View>
+            <View style={{ flex: 1 }} />
+            <View className='toolbar_btn'>移除</View>
+        </View>
+        {
+            showModal && <Modal testInfo={null}
+                dismiss={() => {
+                    setShowModal(false)
+                }}
+                confirm={() => { }}>
+                <AddLabel labels={labels}/>
+            </Modal>
+        }
+    </View>
+}

+ 8 - 0
src/app.config.ts

@@ -41,6 +41,14 @@ const appConfig = defineAppConfig({
   //     ]
   //   }
   // ],
+  subPackages:[
+    {
+      root:'_eat',
+      pages:[
+        'pages/meal_list'
+      ]
+    }
+  ],
   usingComponents: {
     'mysvg': './components/basic/svg',
     // 't-popup':'tdesgin-miniprogram/popup/popup'

+ 9 - 9
src/components/input/LimitPickers.scss

@@ -3,10 +3,10 @@
 .picker-mask {
     max-width: auto;
     // background: red;
-    background: linear-gradient(0deg, rgba(28, 28, 28, 1) 0%,
-            rgba(28, 28, 28, 0) 45%,
-            rgba(28, 28, 28, 0) 55%,
-            rgba(28, 28, 28, 1) 100%);
+    // background: linear-gradient(0deg, rgba(28, 28, 28, 1) 0%,
+    //         rgba(28, 28, 28, 0) 45%,
+    //         rgba(28, 28, 28, 0) 55%,
+    //         rgba(28, 28, 28, 1) 100%);
     background-size: 750px 500px !important;
     height: 500px ;
     background-position: center center;
@@ -17,10 +17,10 @@
 .picker-mask-small{
     max-width: auto;
     // background: red;
-    background: linear-gradient(0deg, rgba(28, 28, 28, 1) 0%,
-            rgba(28, 28, 28, 0) 45%,
-            rgba(28, 28, 28, 0) 55%,
-            rgba(28, 28, 28, 1) 100%);
+    // background: linear-gradient(0deg, rgba(28, 28, 28, 1) 0%,
+    //         rgba(28, 28, 28, 0) 45%,
+    //         rgba(28, 28, 28, 0) 55%,
+    //         rgba(28, 28, 28, 1) 100%);
     background-size: 750px 340px !important;
     height: 340px ;
     background-position: center center;
@@ -56,7 +56,7 @@
 
 .pickerEndTime{
     text-align: center;
-    color: #fff;
+    color: #000;
     opacity: 0.4;
     font-size: 20px;
     line-height: 20px;

+ 6 - 6
src/components/input/LimitPickers.tsx

@@ -218,11 +218,11 @@ const Component = forwardRef((props: {
             <Text className='modal_title' style={{ color: color }}>{props.title ? props.title : '测试标题 '}</Text>
             <View style={{ backgroundColor: 'transparent', position: 'relative' }}>
                 <PickerView
-                    itemStyle={{ color: '#fff', margin: 0, padding: 0 }}
+                    itemStyle={{ color: '#000', margin: 0, padding: 0 }}
                     value={values}
                     className="picker"
-                    maskClass="picker-mask"
-                    style={{ color: '#fff' }}
+                    // maskClass="picker-mask"
+                    style={{ color: '#000' }}
                     onChange={onPickerChange}
                     onPickEnd={onPickerEnd}
                     immediateChange={true}
@@ -230,21 +230,21 @@ const Component = forwardRef((props: {
                     <PickerViewColumn style='flex:0 0 45%'>
                         {days.map(item => {
                             return (
-                                <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff' }}>{item}</View>
+                                <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#000' }}>{item}</View>
                             );
                         })}
                     </PickerViewColumn>
                     <PickerViewColumn>
                         {hours.map(item => {
                             return (
-                                <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff' }}>{item < 10 ? `0${item}` : item}</View>
+                                <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#000' }}>{item < 10 ? `0${item}` : item}</View>
                             );
                         })}
                     </PickerViewColumn>
                     <PickerViewColumn>
                         {minutes.map(item => {
                             return (
-                                <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff' }}>{item < 10 ? `0${item}` : item}</View>
+                                <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#000' }}>{item < 10 ? `0${item}` : item}</View>
                             );
                         })}
                     </PickerViewColumn>

+ 6 - 6
src/components/input/PickerViews.scss

@@ -1,22 +1,22 @@
 /* #ifdef weapp */
 .picker-mask {
     max-width: auto;
-    background: linear-gradient(0deg, rgba(28, 28, 28, 1) 0%,
-            rgba(28, 28, 28, 0) 45%,
-            rgba(28, 28, 28, 0) 55%,
-            rgba(28, 28, 28, 1) 100%);
+    // background: linear-gradient(0deg, rgba(28, 28, 28, 1) 0%,
+    //         rgba(28, 28, 28, 0) 45%,
+    //         rgba(28, 28, 28, 0) 55%,
+    //         rgba(28, 28, 28, 1) 100%);
     background-size: 750px 340px !important;
     height: 340px;
     background-position: center center;
     background-repeat: no-repeat;
     z-index: 9;
-    color: #fff !important;
+    // color: #000 !important;
 }
 
 .picker{
     background-size: 750px 340px !important;
     height: 340px;
-    color: #fff !important;
+    // color: #000 !important;
 }
 
 /* #endif */

+ 4 - 5
src/components/input/PickerViews.tsx

@@ -56,21 +56,20 @@ const Component = forwardRef((props: {
         }
 
         <PickerView value={v}
-            // color='#fff'
-            itemStyle={{ color: '#fff' }}
-            style={{ color: '#fff',height:rpxToPx(340) }}
+            itemStyle={{ color: '#000' }}
+            style={{ color: '#000',height:rpxToPx(340) }}
             onChange={onPickerChange}
             indicatorStyle='height: 40px;'
             immediateChange={true}
             className="picker"
-            maskClass={props.hideTitle?"picker-mask-small":"picker-mask"}
+            // maskClass={props.hideTitle?"picker-mask-small":"picker-mask"}
         >
             {
                 props.items.map((item, index) => {
                     return <PickerViewColumn key={index}>
                         {item.map((obj, j) => {
                             return (
-                                <Text key={j} style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff' }}>{obj}</Text>
+                                <Text key={j} style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#000' }}>{obj}</Text>
                             );
                         })}
                     </PickerViewColumn>

+ 3 - 3
src/components/layout/Modal.scss

@@ -29,12 +29,12 @@
 @keyframes modalBgAnim {
 
     100% {
-        background-color: rgba($color: #000000, $alpha: 0.95);
+        background-color: rgba($color: #000000, $alpha: 0.15);
     }
 }
 
 .modal_dismiss {
-    background-color: rgba($color: #000000, $alpha: 0.95);
+    background-color: rgba($color: #000000, $alpha: 0.15);
     animation: modalBgHideAnim 0.2s linear forwards;
 }
 
@@ -66,7 +66,7 @@
 .modal_bottom_content {
     // padding-bottom: 120px;
     width: 750px;
-    background-color: #1c1c1c;
+    background-color: #ffffff;
     border-top-left-radius: 36px;
     border-top-right-radius: 36px;
     display: flex;

+ 7 - 7
src/features/trackTimeDuration/components/ConsolePicker.tsx

@@ -211,39 +211,39 @@ const Component = forwardRef((props: {
             <Text className='modal_title' style={{ color: color }}>{props.title ? props.title : '测试标题 '}</Text>
 
             <PickerView
-                itemStyle={{ color: '#fff', margin: 0, padding: 0 }}
+                itemStyle={{ color: '#000', margin: 0, padding: 0 }}
                 value={values}
                 className="picker"
-                maskClass="picker-mask"
-                style={{ color: '#fff' }}
+                // maskClass="picker-mask"
+                style={{ color: '#000000' }}
                 onChange={onPickerChange}
                 immediateChange={true}
                 indicatorStyle='height: 50px;color:red;'>
                 <PickerViewColumn style='flex:0 0 45%'>
                     {days.map((item, i) => {
                         return (
-                            <View key={i} style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff', height: 50 }}>{item}</View>
+                            <View key={i} style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#000', height: 50 }}>{item}</View>
                         );
                     })}
                 </PickerViewColumn>
                 <PickerViewColumn>
                     {hours.map((item, j) => {
                         return (
-                            <View key={j * 1000} style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff', height: 50 }}>{item < 10 ? `0${item}` : item}</View>
+                            <View key={j * 1000} style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#000', height: 50 }}>{item < 10 ? `0${item}` : item}</View>
                         );
                     })}
                 </PickerViewColumn>
                 <PickerViewColumn>
                     {minutes.map((item, k) => {
                         return (
-                            <View key={k * 10000} style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff', height: 50 }}>{item < 10 ? `0${item}` : item}</View>
+                            <View key={k * 10000} style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#000', height: 50 }}>{item < 10 ? `0${item}` : item}</View>
                         );
                     })}
                 </PickerViewColumn>
             </PickerView>
 
             {
-                !props.hidenEndTime && <Text className="pickerEndTime" style={{ color: props.isTimeout ? 'red' : '#ffffff' }}>{pickerTimeText()}</Text>
+                !props.hidenEndTime && <Text className="pickerEndTime" style={{ color: props.isTimeout ? 'red' : '#000000' }}>{pickerTimeText()}</Text>
             }
 
             <View className='modal_operate'>

+ 3 - 0
src/features/trackTimeDuration/components/MainFastEatCard.tsx

@@ -602,6 +602,9 @@ export default function MainFastEatCard(props: { count: any }) {
                 switch (res) {
                     case 0:
                         break;
+                    case 1:
+                        jumpPage('/_eat/pages/meal_list')
+                        break;
                 }
             }
         });

+ 67 - 0
src/services/health.tsx

@@ -0,0 +1,67 @@
+import { API_HEALTH_LABELS, API_HEALTH_SCHEDULES } from "./http/api";
+import { request } from "./http/request";
+
+export const getLabels = (params) => {
+    return new Promise((resolve, reject) => {
+        request({
+            url: API_HEALTH_LABELS, method: 'GET', data: {...params}
+        }).then(res => {
+            resolve(res);
+            // dispatch(loginSuccess(res));
+        }).catch(e => {
+            reject(e)
+        })
+    })
+}
+
+export const getSchedules = (params) => {
+    return new Promise((resolve, reject) => {
+        request({
+            url: API_HEALTH_SCHEDULES, method: 'GET', data: {...params}
+        }).then(res => {
+            resolve(res);
+            // dispatch(loginSuccess(res));
+        }).catch(e => {
+            reject(e)
+        })
+    })
+}
+
+export const createSchedule = (params) => {
+    return new Promise((resolve, reject) => {
+        request({
+            url: API_HEALTH_SCHEDULES, method: 'POST', data: {...params}
+        }).then(res => {
+            resolve(res);
+            // dispatch(loginSuccess(res));
+        }).catch(e => {
+            reject(e)
+        })
+    })
+}
+
+export const updateSchedule = () => {
+    return new Promise((resolve, reject) => {
+        request({
+            url: API_HEALTH_SCHEDULES, method: 'PUT', data: {}
+        }).then(res => {
+            resolve(res);
+            // dispatch(loginSuccess(res));
+        }).catch(e => {
+            reject(e)
+        })
+    })
+}
+
+export const delSchedule = () => {
+    return new Promise((resolve, reject) => {
+        request({
+            url: API_HEALTH_SCHEDULES, method: 'PUT', data: {}
+        }).then(res => {
+            resolve(res);
+            // dispatch(loginSuccess(res));
+        }).catch(e => {
+            reject(e)
+        })
+    })
+}

+ 8 - 3
src/services/http/api.js

@@ -53,8 +53,7 @@ export const API_CLOCK_RECORD_UPDATE = `${baseUrl}/api/clock/records`
 export const API_CLOCK_STREAKS = `${baseUrl}/api/clock/streaks`
 export const API_FAST_WINDOW = `${baseUrl}/api/fast/fast-eat-windows`
 export const API_SLEEP_WINDOW = `${baseUrl}/api/fast/sleep-active-windows`
-export const API_SET_SCHEDULE = `${baseUrl}/api/fast/schedules`
-export const API_EAT_MEALS = `${baseUrl}/api/eat/meals`
+
 
 
 
@@ -92,4 +91,10 @@ export const API_PAY_UPLOAD = `${baseUrl}/api/payment/member/rc-receipts`
 export const API_USER_ACCESS = `${baseUrl}/api/user/access`
 export const API_PRODUCTS = `${baseUrl}/api/payment/member/products`
 export const API_CREATE_ORDER = `${baseUrl}/api/payment/member/orders`
-export const API_ORDER_CHECK = `${baseUrl}/api/payment/member/orders/`
+export const API_ORDER_CHECK = `${baseUrl}/api/payment/member/orders/`
+
+//health
+export const API_SET_SCHEDULE = `${baseUrl}/api/fast/schedules`
+export const API_EAT_MEALS = `${baseUrl}/api/eat/meals`
+export const API_HEALTH_SCHEDULES = `${baseUrl}/api/health/schedules`
+export const API_HEALTH_LABELS = `${baseUrl}/api/health/labels`