leon před 1 rokem
rodič
revize
2d81c3bde5

+ 2 - 2
src/_health/components/add_label.tsx

@@ -62,7 +62,7 @@ export default function AddLabel(props: {
                 title: value,
                 time: isFullday ? null : strTime,
                 specific_time: !isFullday,
-                time_label: isFullday ? strTime : null
+                time_label: isFullday ? strLabel : null
             }]
         }
         else {
@@ -71,7 +71,7 @@ export default function AddLabel(props: {
                 title: value,
                 time: isFullday ? null : strTime,
                 specific_time: !isFullday,
-                time_label: isFullday ? strTime : null
+                time_label: isFullday ? strLabel : null
             }]
         }
         createSchedule({

+ 0 - 5
src/_health/components/move_item.tsx

@@ -1,5 +0,0 @@
-import { View } from "@tarojs/components";
-
-export default function MoveItem({data:any}){
-    return <View></View>
-}

+ 53 - 0
src/_health/components/schedule_move_list.scss

@@ -0,0 +1,53 @@
+.drag_item2{
+    // background-color: gray;
+    // border-radius: 20px;
+    // margin-left: 20px;
+    // margin-right: 20px;
+    width: 700px;
+}
+
+.last_item{
+    // background-color: ;
+    color: #fff;
+}
+
+.demo_item{
+    // width: 750px;
+    // background-color: #000;
+}
+
+.modal_order_item{
+    display: flex;
+    flex-direction: row;
+    width: '100%';
+    align-items: center;
+    justify-content: space-between;
+    // position: relative;
+    // background-color: pink;
+    // border-bottom: solid 2px #999999;
+    margin-left: 46px;
+    margin-right: 46px;
+    box-sizing: border-box;
+}
+
+.modal_sel_item2{
+    display: flex;
+    flex-direction: row;
+    width: '100%';
+    align-items: center;
+    justify-content: space-between;
+    // background-color: pink;
+    // border-bottom: solid 2px #999999;
+    // margin-left: 26px;
+    // margin-right: 26px;
+}
+
+.seperate{
+    display: flex;
+    height: 2px;
+    background-color: #fff;
+    opacity: 0.1;
+    -webkit-transform: scaleY(0.5);
+    transform: scaleY(0.5);
+    width: 100%;
+}

+ 214 - 0
src/_health/components/schedule_move_list.tsx

@@ -0,0 +1,214 @@
+import { MovableArea, MovableView, View, ScrollView, Text, Image } from '@tarojs/components'
+import './schedule_move_list.scss'
+import { useEffect, useRef, useState } from 'react';
+import { ColorType, MainColorType } from '@/context/themes/color';
+import Taro from '@tarojs/taro';
+import { IconDrag } from '@/components/basic/Icons';
+import { rpxToPx } from '@/utils/tools';
+import StatusIndicator, { StatusType } from '../base/status_indicator';
+
+export default function ScheduleMoveList(props: { array: any, itemHeight: number, color?: string, update: Function }) {
+    const [list, setList] = useState(props.array)
+    const [movaleViewY, setMovaleViewY] = useState(0)
+    const [dragElement, setDragElement] = useState(null)
+    const [lastTarget, setLastTarget] = useState(null)
+    const [startOffsetY, setStartOffsetY] = useState(0)
+    const [startPageY, setStartPageY] = useState(0)
+    const [dragIndex, setDragIndex] = useState(-1)
+    const [scrollThreshold, setScrollThreshold] = useState(0.5)
+    const upperThreshold = 100
+    const lowThreshold = 100
+    const [canScroll, setCanScroll] = useState(true)
+    const [changedIndex, setChangedIndex] = useState(-1)
+    const [hiddenContent, setHiddenContent] = useState(false)
+
+    const [scrollTop, setScrollTop] = useState(0)
+    const [contentY, setContentY] = useState(0)
+    const [contentHeight, setContentHeight] = useState(0)
+    const ref = useRef(null)
+
+    useEffect(() => {
+        if (process.env.TARO_ENV == 'weapp') {
+            const query = Taro.createSelectorQuery();
+            query.select('#myScrollView').boundingClientRect();
+            query.exec((res) => {
+                setContentY(res[0].top)
+                setContentHeight(res[0].height)
+            })
+        }
+        else {
+
+        }
+
+    }, [])
+
+    function longPress(e, index) {
+        setChangedIndex(index)
+        setStartOffsetY(e.target.offsetTop)
+        setStartPageY(e.touches[0].pageY)
+        setDragIndex(index)
+        setDragElement(list[index])
+        setMovaleViewY(e.target.offsetTop)
+        setCanScroll(false)
+        setHiddenContent(true)
+    }
+
+    function touchMove(e) {
+        if (dragElement) {
+            let clientY = e.touches[0].clientY;
+            pageScroll(clientY);
+            let pageY = e.touches[0].pageY;
+            let targetMoveDistance = pageY - startPageY
+            let movaleViewY2 = startOffsetY + targetMoveDistance
+
+            let targetIndex = computeFutureIndex(targetMoveDistance, dragIndex)
+            if (targetIndex !== false && targetIndex != changedIndex) {
+                debugger
+                var temps = swapListItems(list, targetIndex, changedIndex)
+                setList(temps)
+                setChangedIndex(targetIndex)
+
+            }
+
+            if (targetIndex === false && targetIndex != changedIndex) {
+                var temps = swapListItems(list, dragIndex, changedIndex)
+                setList(temps)
+                setChangedIndex(dragIndex)
+            }
+
+            setMovaleViewY(movaleViewY2)
+            setLastTarget(targetIndex as any)
+            setHiddenContent(true)
+        }
+    }
+
+    function pageScroll(clientY) {
+        return
+    }
+
+    function swapListItems<T>(list: T[], index1: number, index2: number): T[] {
+        const newList = [...list];
+        const temp = newList[index1];
+        newList[index1] = newList[index2];
+        newList[index2] = temp;
+
+        return newList;
+    }
+
+
+    function touchEnd(e) {
+        if (dragElement) {
+            setDragElement(null)
+            setLastTarget(null)
+            setDragIndex(-1)
+
+        }
+        setChangedIndex(-1)
+        setCanScroll(true)
+        setHiddenContent(false)
+        setMovaleViewY(-100)
+
+        props.update(list)
+    }
+
+    function computeFutureIndex(targetMoveDistance, dragElementIndex) {
+        let willInsertAfter = getSwapDirection(targetMoveDistance);
+        if (willInsertAfter !== false) {
+            /** 偏移索引 */
+            let offsetElementIndex = dragElementIndex + willInsertAfter;
+            /** 移动步数 */
+            let step = targetMoveDistance / props.itemHeight;
+            /** 步数补偿,当只有移动距离超过单项 _scrollThreshold 时才算有效 */
+            if (step <= -1) {
+                step += scrollThreshold;
+            } else if (step >= 1) {
+                step -= scrollThreshold;
+            }
+            /** 目标索引 */
+            let futureIndex = parseInt(step + '') + offsetElementIndex;
+
+            // 避免越界
+            if (futureIndex < 0) {
+                futureIndex = 0;
+            } else if (futureIndex > list.length - 1) {
+                futureIndex = list.length - 1;
+            }
+
+            return futureIndex;
+        } else {
+            return willInsertAfter;
+        }
+    }
+
+    function getSwapDirection(targetMoveDistance) {
+        if (Math.abs(targetMoveDistance) < props.itemHeight / 2) {
+            // 轻轻拂动,滑动距离小于1/2单项高度
+            return false;
+        } else if (targetMoveDistance >= props.itemHeight / 2) {
+            // console.log('[_getSwapDirection] 👇👇👇');
+            return 1;  // 下滑
+        } else if (targetMoveDistance <= props.itemHeight / -2) {
+            // console.log('[_getSwapDirection] 👆👆👆');
+            return -1;  // 上滑
+        }
+    }
+
+    return <View id="myScrollView" ref={ref} style={{ height: '100%', overflow: canScroll ? 'scroll' : 'hidden' }} catchMove>
+        <MovableArea style={{ height: list.length * props.itemHeight, width: rpxToPx(700) }}>
+            <View>
+                {
+                    list.map((item, index) => {
+                        return <View key={index} style={{ opacity: changedIndex == index && hiddenContent ? 0 : 1, height: props.itemHeight, width: rpxToPx(700) }}
+                            onLongPress={(e) => longPress(e, index)}
+                            onTouchMove={(e) => touchMove(e)}
+                            onTouchEnd={(e) => touchEnd(e)}
+                        >
+                            <View className='schedule_item' style={{ width: rpxToPx(700), height: rpxToPx(128), boxSizing: 'border-box' }}>
+                                <View style={{ display: 'flex', flexDirection: 'column', justifyContent: 'flex-start', flex: 1 }}>
+                                    <View className='item_left2'>
+                                        <StatusIndicator type={StatusType.normal} color={MainColorType.active} text={item.title} fontSize={rpxToPx(34)} />
+                                    </View>
+                                    <View className="h22" style={{ color: MainColorType.g02, marginLeft: rpxToPx(26), marginTop: rpxToPx(10) }}>{item.time_label}</View>
+                                </View>
+                                <Image src={require('@assets/_health/drag.png')} style={{
+                                    width: rpxToPx(34),
+                                    height: rpxToPx(34)
+                                }} />
+                                <View className='border_footer_line' style={{ left: rpxToPx(66), flexShrink: 0 }} />
+
+                            </View>
+                        </View>
+                    })
+                }
+
+                <MovableView style={{ height: changedIndex >= 0 ? props.itemHeight : 0, width: rpxToPx(700) }}
+                    direction='vertical'
+                    disabled
+                    animation={false}
+                    y={movaleViewY}
+                >
+                    <View className='drag_item2' style={{ backgroundColor: props.color }}>
+                        {
+                            dragIndex >= 0 && <View className='modal_sel_item2' style={{ height: props.itemHeight, border: 'none' }}>
+                                <View className='schedule_item' style={{ width: rpxToPx(700), height: rpxToPx(128), boxSizing: 'border-box' }}>
+                                    <View style={{ display: 'flex', flexDirection: 'column', justifyContent: 'flex-start', flex: 1 }}>
+                                        <View className='item_left2'>
+                                            <StatusIndicator type={StatusType.normal} color={MainColorType.active} text={list[changedIndex].title} fontSize={rpxToPx(34)} />
+                                        </View>
+                                        <View className="h22" style={{ color: MainColorType.g02, marginLeft: rpxToPx(26), marginTop: rpxToPx(10) }}>{list[changedIndex].time_label}</View>
+                                    </View>
+                                    <Image src={require('@assets/_health/drag.png')} style={{
+                                        width: rpxToPx(34),
+                                        height: rpxToPx(34)
+                                    }} />
+                                    <View className='border_footer_line' style={{ left: rpxToPx(66), flexShrink: 0 }} />
+
+                                </View>
+                            </View>
+                        }
+                    </View>
+                </MovableView>
+            </View>
+        </MovableArea>
+    </View>
+}

+ 1 - 1
src/_health/pages/guide_active.tsx

@@ -91,7 +91,7 @@ export default function GuideActive() {
     function add() {
         const scenario = getScenario(health.windows, 'ACTIVE')
         var items = list.filter(item => item.window == 'ACTIVE')
-        if (scenario.access.max <= items.length) {
+        if (scenario.access.max && scenario.access.max <= items.length) {
             showAlert({
                 title: '会员',
                 content: '会员desc',

+ 1 - 1
src/_health/pages/guide_eat.tsx

@@ -92,7 +92,7 @@ export default function GuideEat() {
     function add() {
         const scenario = getScenario(health.windows, 'EAT')
         var items = list.filter(item => item.window == 'EAT')
-        if (scenario.access.max <= items.length) {
+        if (scenario.access.max && scenario.access.max <= items.length) {
             showAlert({
                 title: '会员',
                 content: '会员desc',

+ 8 - 6
src/_health/pages/schedules.tsx

@@ -5,7 +5,7 @@ import { useEffect, useState } from "react";
 import { useSelector } from "react-redux";
 import './schedules.scss';
 import { rpxToPx } from "@/utils/tools";
-import { getThemeColor } from "@/features/health/hooks/health_hooks";
+import { getScenario, getThemeColor } from "@/features/health/hooks/health_hooks";
 import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 import Modal from "@/components/layout/Modal.weapp";
 import TimePicker from "@/features/common/TimePicker";
@@ -254,15 +254,17 @@ export default function Schedules() {
         var isMax = false
         if (isEat) {
             setIsEat(true)
+            var scenario = getScenario(health.windows, 'EAT')
             const countFastWindows = list.filter(item => item.window === 'EAT').length;
-            if (countFastWindows >= 4) {
+            if (scenario.access.max && countFastWindows >= scenario.access.max) {
                 isMax = true
             }
         }
         else {
             setIsEat(false)
+            var scenario = getScenario(health.windows, 'ACTIVE')
             const countFastWindows = list.filter(item => item.window === 'ACTIVE').length;
-            if (countFastWindows >= 4) {
+            if (scenario.access.max && countFastWindows >= scenario.access.max) {
                 isMax = true
             }
         }
@@ -341,7 +343,7 @@ export default function Schedules() {
         var temps = list.filter(item => {
             return !item.specific_time
         })
-        var needOrder =false
+        var needOrder = false
         if (temps.length > 1) {
             needOrder = true
             items.push('排序')
@@ -360,8 +362,8 @@ export default function Schedules() {
                     jumpPage(url)
                 }
                 else if (res == 2) {
-                    if (needOrder){
-                        jumpPage('./schedules_order?list='+JSON.stringify(temps))
+                    if (needOrder) {
+                        jumpPage('./schedules_order?list=' + JSON.stringify(temps))
                         return
                     }
                     jumpPage('/_health/pages/guide_begin')

+ 8 - 0
src/_health/pages/schedules_order.config.ts

@@ -0,0 +1,8 @@
+export default definePageConfig({
+    usingComponents:{
+      // 'ec-canvas': '../../lib/ec-canvas/ec-canvas',
+      // 'demo':'../../components/demo'
+    },
+    "navigationBarTitleText":"",
+    "navigationBarBackgroundColor":"#f5f5f5"
+  })

+ 6 - 2
src/_health/pages/schedules_order.tsx

@@ -14,6 +14,7 @@ import StatusIndicator, { StatusType } from "../base/status_indicator";
 import Card from "../components/card";
 import { orderSchedules } from "@/services/health";
 import Taro from "@tarojs/taro";
+import ScheduleMoveList from "../components/schedule_move_list";
 
 let useRoute;
 let useNavigation;
@@ -91,9 +92,12 @@ export default function SchedulesOrder() {
     return <View >
         <NewHeader title="日程设置" type={NewHeaderType.left} />
         <Card>
-            <MoveList itemHeight={rpxToPx(128)} components={items()} array={list} color="#fff" update={array => {
+            {/* <MoveList itemHeight={rpxToPx(128)} components={items()} array={list} color="#fff" update={array => {
                 setList(array)
-            }} />
+            }} /> */}
+            <ScheduleMoveList itemHeight={rpxToPx(128)} array={list} color="red" update={array => {
+                setList(array)
+            }}/>
         </Card>
         <View className="main_footer">
             <NewButton

binární
src/assets/_health/drag.png


+ 9 - 0
src/features/health/HistoryItem.tsx

@@ -302,6 +302,15 @@ export default function HistoryItem(props: {
                             content.type == 'PIC_TEXT' && <Image
                                 style={{ width: rpxToPx(178), height: rpxToPx(178), marginRight: rpxToPx(7), flexShrink: 0 }}
                                 src={content.data[0].url}
+                                onClick={(e)=>{
+                                    if (process.env.TARO_ENV=='weapp'){
+                                        e.stopPropagation()
+                                    }
+                                    Taro.previewImage({
+                                        current:content.data[0].url,
+                                        urls:[content.data[0].url]
+                                    })
+                                }}
                                 mode="aspectFill" />
                         }
                         {

+ 3 - 0
src/pages/store/product_list.tsx

@@ -221,6 +221,9 @@ export default function ProductList() {
                 if (global.paySuccessRefresh) {
                     global.paySuccessRefresh()
                 }
+                if (global.refreshWindow){
+                    global.refreshWindow()
+                }
                 if (process.env.TARO_ENV == 'rn') {
                     navigation.pop(1)
                 }