소스 검색

1.5.9 release

leon 1 년 전
부모
커밋
9fb0b7281a

+ 1 - 0
src/_health/pages/add_moment.tsx

@@ -369,6 +369,7 @@ export default function AddMoment() {
         if (posting) return
         setPosting(true)
         updateMoment(params, router.params.id).then(res => {
+            Taro.eventCenter.trigger('refreshMoments', '')
             setPosting(false)
             if (process.env.TARO_ENV == 'weapp') {
                 Taro.navigateBack();

+ 5 - 1
src/_health/pages/timeline_detail.tsx

@@ -615,6 +615,7 @@ export default function TimelineDetail() {
             showCancel: true,
             confirm: () => {
                 delEvents(event_id).then(res => {
+                    Taro.eventCenter.trigger('refreshMoments', '')
                     Taro.navigateBack()
                     global.refreshWindow()
                     if (global.refreshHistory)
@@ -1200,7 +1201,10 @@ export default function TimelineDetail() {
         {
             fastSleepPopContent()
         }
-        <MomentDetailShare user={shareUser ? shareUser : detail.share_user} btnColor={getThemeColor(detail.join ? detail.join.window : detail.window)} />
+        <MomentDetailShare
+            cover={mediaCount() > 0 ? imgList()[0] : null}
+            user={shareUser ? shareUser : detail.share_user}
+            btnColor={getThemeColor(detail.join ? detail.join.window : detail.window)} />
 
     </View>
 }

+ 2 - 2
src/_moment/components/long_card.tsx

@@ -122,7 +122,7 @@ export default function LongCard(props: { join?: any, user?: any, hideJoin?: boo
                 }
                 <View style={{ flex: 1 }} />
                 {
-                    status == 'JOIN' && <View className="h26 bold" style={{ color: MainColorType.link }} onClick={join}>{t('health.join')}</View>
+                    status == 'JOIN' && <View className="h26 bold" style={{ color: MainColorType.link,padding:5,marginRight:-5 }} onClick={join}>{t('health.join')}</View>
                 }
                 {
                     status == 'SHARE' && <ShareBtn onClick={share} hideShare={props.isFeedItem}>
@@ -147,7 +147,7 @@ export default function LongCard(props: { join?: any, user?: any, hideJoin?: boo
             {
                 props.join && props.join.user_count > 0 && users()
             }
-            <View className="h26 bold" style={{ color: MainColorType.link }} onClick={join}>{t('health.join')}</View>
+            <View className="h26 bold" style={{ color: MainColorType.link,padding:15,marginRight:-15 }} onClick={join}>{t('health.join')}</View>
         </View>
 
     if (status == 'SHARE') {

+ 1 - 1
src/_moment/components/recent_item.tsx

@@ -39,7 +39,7 @@ export default function RecentItem(props: { data: any, index: number }) {
             jumpPage('/_health/pages/move_detail?id=' + link.move.id)
             return;
         }
-        jumpPage(`/_health/pages/timeline_detail?source=home&window_id=${link.window_id}`)
+        jumpPage(`/_health/pages/timeline_detail?source=home&window_id=${link.window_id}&event_id=${link.event_id}`)
     }
 
     const hasImg = moment && moment.media.length > 0

+ 5 - 2
src/_moment/pages/long_detail.tsx

@@ -51,8 +51,11 @@ export default function LongDetail() {
     function getDetail() {
         joinDetail(router.params.join_id).then(res => {
             setDetail(res)
-            var left = 10 - (res as any).join_users.length
-            setList(Array(left).fill('0'))
+            if ((res as any).join_users) {
+                var left = 10 - (res as any).join_users.length
+                setList(Array(left).fill('0'))
+            }
+
         })
     }
 

+ 17 - 0
src/_record/pages/time_record.config.ts

@@ -0,0 +1,17 @@
+export default definePageConfig({
+    // // "lazyCodeLoading": "requiredComponents",
+    // // "componentFramework": "glass-easel",
+    // // "renderer": "skyline",
+    // // "rendererOptions": {
+    // //     "skyline": {
+    // //         "disableABTest": true,
+    // //         "defaultDisplayBlock": true
+    // //     }
+    // // },
+    // "usingComponents": {
+    //     "recycle-view": "../../components/miniprogram-recycle-view/recycle-view",
+    //     "recycle-item": "../../components/miniprogram-recycle-view/recycle-item"
+    // },
+    // "disableScroll": true,
+    "navigationStyle": "custom",
+})

+ 10 - 0
src/_record/pages/time_record.scss

@@ -0,0 +1,10 @@
+page {
+    background: linear-gradient(to bottom, #F0CABF, #E1CDEE)
+}
+
+.navi_bar {
+    position: fixed;
+    left: 0;
+    right: 0;
+    top: 0;
+}

+ 95 - 0
src/_record/pages/time_record.tsx

@@ -0,0 +1,95 @@
+import { View, Image } from "@tarojs/components";
+import './time_record.scss'
+import Taro from "@tarojs/taro";
+import { rpxToPx } from "@/utils/tools";
+import Rings, { RingCommon, BgRing, TargetRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
+import { MainColorType } from "@/context/themes/color";
+
+export default function TimeRecord() {
+    const systemInfo: any = Taro.getWindowInfo ? Taro.getWindowInfo() : Taro.getSystemInfoSync();
+    const navigationBarHeight = systemInfo.statusBarHeight + 44;
+
+    const common: RingCommon = {
+        useCase: 'ChooseScenario',
+        radius: 27,
+        lineWidth: 12,
+        isFast: true,
+        status: 'WAIT_FOR_START'
+    }
+
+    const bgRing: BgRing = {
+        color: MainColorType.ringBg
+    }
+
+    function targetRing() {
+        return {
+            color: 'pink',
+            startArc: 0,
+            durationArc: 3 / 4 * Math.PI
+        }
+    }
+
+    function realRing() {
+        return {
+            color: 'red',
+            startArc: 0,
+            durationArc: 2 / 4 * Math.PI
+        }
+    }
+
+    function currentDot() {
+
+
+        return {
+            color: MainColorType.eat,
+            lineWidth: 2,
+            borderColor: '#F5F5F5',
+            offset: 0
+        }
+
+    }
+
+    function ring() {
+
+        return <Rings common={common}
+            bgRing={bgRing}
+            targetRing={targetRing()}
+            realRing={realRing()}
+            canvasId={'smal11lsss'}
+            currentDot={currentDot()}
+            scale={1.0}
+        />
+    }
+
+    return <View>
+        <View className="navi_bar" style={{ height: navigationBarHeight }}>
+            <View style={{
+                position: 'absolute',
+                left: 0,
+                right: 0,
+                bottom: 0,
+                height: 44,
+                display: 'flex',
+                alignItems: 'center',
+                justifyContent: 'center'
+            }}>
+                <Image src={require('@assets/_health/navi_back.png')} style={{
+                    position: 'absolute',
+                    width: rpxToPx(92),
+                    height: rpxToPx(64),
+                    left: 0,
+                    top: 22 - rpxToPx(32)
+                }}
+                    onClick={() => {
+                        Taro.navigateBack()
+                    }}
+                />
+                <View className="h36 bold">upcoming fast</View>
+            </View>
+        </View>
+        <View style={{ height: navigationBarHeight }} />
+        {
+            ring()
+        }
+    </View>
+}

+ 9 - 1
src/app.config.ts

@@ -2,6 +2,7 @@ import { kIsIOS } from "./utils/tools";
 
 const appConfig = defineAppConfig({
   pages: [
+
     'pages/clock/Clock',
     'pages/common/H5',
     'pages/account/Profile',
@@ -11,7 +12,8 @@ const appConfig = defineAppConfig({
     'pages/account/Journal',
     'pages/account/JournalDetail',
     'pages/discover/discover',
-    'pages/moment/moment'
+    'pages/moment/moment',
+    'pages/clock/demo',
   ],
   entryPagePath: 'pages/clock/Clock',
   // subPackages: [
@@ -84,6 +86,12 @@ const appConfig = defineAppConfig({
       pages: [
         'pages/map'
       ]
+    },
+    {
+      root: '_record',
+      pages: [
+        'pages/time_record'
+      ]
     }
   ],
   usingComponents: {

+ 1 - 0
src/features/health/MainConsole.tsx

@@ -581,6 +581,7 @@ export default function MainConsole(props: { type: WindowType }) {
                         confirm: () => {
                             delRecord({ ids: [obj.window_id] }).then(res => {
                                 global.refreshWindow()
+                                Taro.eventCenter.trigger('refreshMoments', '')
 
                                 if ((res as any).status_change) {
                                     if ((res as any).status_change.previous != (res as any).status_change.current) {

+ 2 - 0
src/pages/clock/Clock.tsx

@@ -18,6 +18,7 @@ import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 import showAlert from "@/components/basic/Alert";
 import { setTitle } from "@/store/health";
 import { globalSetting } from "@/services/common";
+import ClockIndex from "./ClockIndex";
 
 let useNavigation;
 
@@ -290,6 +291,7 @@ export default function Clock() {
 
 
         </View>
+        {/* <ClockIndex /> */}
         <ClockNew onScroll={onScroll}>
             {
                 showCalendar && <Streak testInfo={null}

+ 10 - 0
src/pages/clock/ClockIndex.tsx

@@ -0,0 +1,10 @@
+import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
+import { View } from "@tarojs/components";
+
+export default function ClockIndex() {
+    return <View 
+    onClick={()=>{
+        jumpPage('/_record/pages/time_record')
+    }}
+    style={{height:100,width:100,backgroundColor:'pink'}}>demo</View>
+}

+ 3 - 0
src/pages/clock/ClockNew.tsx

@@ -438,6 +438,9 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
                     progress={40}
                     color="#3498db"
                     backgroundColor="#ecf0f1" /> */}
+                {/* <View onClick={()=>{
+                    jumpPage('./demo')
+                }}>Test</View> */}
 
                 <MainHistory ref={historyRef2} updateDate={(e) => {
                     setShowDate(e.show)

+ 36 - 0
src/pages/clock/demo.scss

@@ -0,0 +1,36 @@
+.demo_bg {
+    background: linear-gradient(to bottom, pink, blue);
+}
+
+.picker1 {
+    color: #000 !important;
+    background-color: transparent !important;
+    background-size: 750px 340px !important;
+    height: 340px;
+}
+
+.picker-mask1 {
+    // max-width: auto;
+    // background-size: 750px 340px !important;
+    background: transparent !important;
+    background-color: transparent !important;
+    // background: linear-gradient(0deg, red 0%,
+    //     red 45%,
+    //     red 55%,
+    //     red 100%);
+
+    // height: 340px;
+    // background-position: center center;
+    // background-repeat: no-repeat;
+    // z-index: 9;
+    // color: #000 !important;
+}
+
+.filter_bgaa {
+    // background-color: 'rgba(255, 255, 255, 1)'; // 半透明白色背景
+    backdrop-filter: 'blur(10px)'; // 毛玻璃效果
+    z-index: 1; // 确保在上层
+    background-color: rgba(255, 255, 255, 0.5);
+    width: 300px;
+    height: 300px;
+}

+ 33 - 0
src/pages/clock/demo.tsx

@@ -0,0 +1,33 @@
+import { View, Text, PickerView, PickerViewColumn } from "@tarojs/components";
+import './demo.scss'
+
+export default function Demo() {
+    const days = ['1', '2', '3', '4', '5']
+    return <View className="demo_bg" style={{ height: '100vh' }}>
+        <Text>hello world</Text>
+        <PickerView
+            itemStyle={{ color: '#000', margin: 0, padding: 0 }}
+            // value={values}
+            className="picker1"
+            // maskStyle="background-color:#ffffff00"
+            maskClass="picker-mask1"
+            // style={{ color: '#000',backgroundColor:'blue' }}
+            // onChange={onPickerChange}
+            // onPickEnd={onPickerEnd}
+            immediateChange={true}
+            indicatorStyle='height: 50px;color:red;'>
+            <PickerViewColumn style='flex:0 0 100%'>
+                {days.map(item => {
+                    return (
+                        <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#000' }}>{item}</View>
+                    );
+                })}
+            </PickerViewColumn>
+        </PickerView>
+        <View className="filter_bgaa">
+            <View style={{ color: '#000', fontSize: '24px' }}>
+                这是毛玻璃效果
+            </View>
+        </View>
+    </View>
+}

+ 124 - 19
src/pages/moment/moment_detail_share.tsx

@@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
 import { View, Canvas } from "@tarojs/components";
 import Taro, { useDidShow } from "@tarojs/taro";
 
-export default function MomentDetailShare(props: { user: any,canvas_id?:string, cover?: string, btnColor?: string }) {
+export default function MomentDetailShare(props: { user: any, canvas_id?: string, cover?: string, btnColor?: string }) {
     const user = props.user;
 
     const info = Taro.getWindowInfo ? Taro.getWindowInfo() : Taro.getSystemInfoSync()
@@ -18,7 +18,6 @@ export default function MomentDetailShare(props: { user: any,canvas_id?:string,
 
 
     async function downCover() {
-        console.log('a')
         var urls: any = []
         if (props.cover) {
             urls = [props.cover, user.avatar]
@@ -40,7 +39,25 @@ export default function MomentDetailShare(props: { user: any,canvas_id?:string,
                 url,
                 success: (res) => {
                     if (res.statusCode === 200) {
-                        resolve(res.tempFilePath);
+                        console.log(res)
+                        Taro.getImageInfo({
+                            src: res.tempFilePath,
+                            success(result) {
+                                resolve({
+                                    path: res.tempFilePath,
+                                    width: result.width,
+                                    height: result.height
+                                })
+                            },
+                            fail(e) {
+                                resolve({
+                                    path: res.tempFilePath,
+                                    width: 200,
+                                    height: 200
+                                })
+                            },
+                        })
+                        // resolve(res.tempFilePath);
                     } else {
                         reject(new Error('图片下载失败'));
                     }
@@ -52,7 +69,7 @@ export default function MomentDetailShare(props: { user: any,canvas_id?:string,
         });
     }
 
-    function beginDraw(imagePaths) {
+    function beginDraw(images) {
 
         const query = Taro.createSelectorQuery();
         query.select(`#${canvasId()}`).fields({ node: true, size: true });
@@ -64,34 +81,94 @@ export default function MomentDetailShare(props: { user: any,canvas_id?:string,
             global.canvas2 = _canvas
 
             if (props.cover) {
-                drawDetail(ctx, imagePaths, _canvas)
+                drawDetail(ctx, images, _canvas)
             }
             else {
-                drawDetail2(ctx, imagePaths, _canvas)
+                drawDetail2(ctx, images, _canvas)
             }
 
         });
     }
 
-    function drawDetail(ctx, imagePaths, canvas) {
+    function drawDetail(ctx, images, canvas) {
         const img = canvas.createImage(); // 创建图像对象
-        img.src = imagePaths[0]
+        img.src = images[0].path
         img.onload = () => {
-            ctx.drawImage(img, 0, 0, 420 * dpr, 336 * dpr);
+            const imgWidth = images[0].width;
+            const imgHeight = images[0].height;
+            var offsetX, offsetY, newWidth, newHeight;
+            if (imgWidth / imgHeight > 430 / 336) {
+                newWidth = imgHeight * 430 / 336;
+                newHeight = imgHeight;
+                offsetX = (imgWidth - newWidth) / 2.0
+                offsetY = 0
+            }
+            else {
+                newWidth = imgWidth;
+                newHeight = imgWidth * 336 / 430;
+                offsetX = 0
+                offsetY = (imgHeight - newHeight) / 2.0
+            }
+
+            ctx.drawImage(img, offsetX, offsetY, newWidth, newHeight, 0, 0, 420 * dpr, 336 * dpr);
             ctx.stroke();
+
+            ctx.fillStyle = 'rgba(0,0,0,0.5)'
+            ctx.fillRect(0, 0, 420 * dpr, 336 * dpr);
             const img1 = canvas.createImage(); // 创建图像对象
-            img1.src = imagePaths[1]
+            img1.src = images[1].path
             img1.onload = () => {
+                const x = 64 * dpr; // 矩形左上角 x 坐标
+                const y = 212 * dpr; // 矩形左上角 y 坐标
+                const width = 292 * dpr; // 矩形宽度
+                const height = 72 * dpr; // 矩形高度
+                const radius = 18 * dpr; // 圆角半径
+
+                // 绘制带圆角的矩形
+
+                ctx.beginPath();
+                ctx.moveTo(x + radius, y); // 移动到左上角的圆角位置
+                ctx.arcTo(x + width, y, x + width, y + height, radius); // 右上角
+                ctx.arcTo(x + width, y + height, x, y + height, radius); // 右下角
+                ctx.arcTo(x, y + height, x, y, radius); // 左下角
+                ctx.arcTo(x, y, x + width, y, radius); // 左上角
+                ctx.closePath();
+                ctx.fillStyle = props.btnColor ? props.btnColor : '#ff0000'; // 设置填充颜色为红色
+                ctx.fill(); // 填充矩形
+
+                ctx.font = `bold ${26 * dpr}px sans-serif`
+                ctx.fillStyle = '#ffffff'
+                ctx.textAlign = 'center'
+                ctx.fillText('立即跟卡', x + width / 2.0, y + height / 2.0 + 10 * dpr);
+
+
                 ctx.font = `bold ${24 * dpr}px sans-serif`
-                ctx.fillStyle = '#E0B152'
+                ctx.fillStyle = '#ffffff'
                 ctx.textAlign = 'center'
                 var name = user.nickname.length > 8 ? user.nickname.substring(0, 8) + '...' : user.nickname
-                ctx.fillText(name, 210 * dpr, 182 * dpr);
+                ctx.fillText(name, 210 * dpr, 178 * dpr);
+
+
+                const imgWidth = images[1].width;
+                const imgHeight = images[1].height;
+                var offsetX, offsetY, newWidth, newHeight;
+                if (imgWidth > imgHeight) {
+                    newWidth = imgHeight;
+                    newHeight = imgHeight;
+                    offsetX = (imgWidth - imgHeight) / 2.0
+                    offsetY = 0
+                }
+                else {
+                    newWidth = imgWidth;
+                    newHeight = imgWidth;
+                    offsetX = 0
+                    offsetY = (imgHeight - imgWidth) / 2.0
+                }
 
                 ctx.beginPath()
-                ctx.arc(210 * dpr, 82 * dpr, 70 * dpr, 0, Math.PI * 2)
+                ctx.arc(210 * dpr, 90 * dpr, 50 * dpr, 0, Math.PI * 2)
                 ctx.clip()
-                ctx.drawImage(img1, 140 * dpr, 12 * dpr, 140 * dpr, 140 * dpr);
+                ctx.drawImage(img1, offsetX, offsetY, newWidth, newHeight, 160 * dpr, 40 * dpr, 100 * dpr, 100 * dpr);
                 ctx.restore()
                 ctx.stroke();
 
@@ -111,11 +188,11 @@ export default function MomentDetailShare(props: { user: any,canvas_id?:string,
 
     }
 
-    function drawDetail2(ctx, imagePaths, canvas) {
+    function drawDetail2(ctx, images, canvas) {
         ctx.fillStyle = '#f5f5f5'
         ctx.fillRect(0, 0, 420 * dpr, 336 * dpr);
         const img1 = canvas.createImage(); // 创建图像对象
-        img1.src = imagePaths[0]
+        img1.src = images[0].path
         img1.onload = () => {
             const x = 64 * dpr; // 矩形左上角 x 坐标
             const y = 212 * dpr; // 矩形左上角 y 坐标
@@ -147,10 +224,38 @@ export default function MomentDetailShare(props: { user: any,canvas_id?:string,
             var name = user.nickname.length > 8 ? user.nickname.substring(0, 8) + '...' : user.nickname
             ctx.fillText(name, 210 * dpr, 178 * dpr);
 
+
+            const imgWidth = images[0].width;
+            const imgHeight = images[0].height;
+            var offsetX, offsetY, newWidth, newHeight;
+            if (imgWidth > imgHeight) {
+                newWidth = imgHeight;
+                newHeight = imgHeight;
+                offsetX = (imgWidth - imgHeight) / 2.0
+                offsetY = 0
+            }
+            else {
+                newWidth = imgWidth;
+                newHeight = imgWidth;
+                offsetX = 0
+                offsetY = (imgHeight - imgWidth) / 2.0
+            }
+            // const avatarWidth = 100 * dpr;
+            // const avatarHeight = 100 * dpr;
+            // // 计算缩放比例
+            // const scale = Math.max(avatarWidth / imgWidth, avatarHeight / imgHeight);
+            // const newWidth = imgWidth * scale;
+            // const newHeight = imgHeight * scale;
+
+            // // 计算绘制的起始坐标,确保居中裁剪
+            // const offsetX = (newWidth - avatarWidth) / 2;
+            // const offsetY = (newHeight - avatarHeight) / 2;
+            // debugger
+
             ctx.beginPath()
             ctx.arc(210 * dpr, 90 * dpr, 50 * dpr, 0, Math.PI * 2)
             ctx.clip()
-            ctx.drawImage(img1, 160 * dpr, 40 * dpr, 100 * dpr, 100 * dpr);
+            ctx.drawImage(img1, offsetX, offsetY, newWidth, newHeight, 160 * dpr, 40 * dpr, 100 * dpr, 100 * dpr);
             ctx.restore()
             ctx.stroke();
 
@@ -169,8 +274,8 @@ export default function MomentDetailShare(props: { user: any,canvas_id?:string,
 
     }
 
-    function canvasId(){
-        return props.canvas_id??'momentdetail_share'
+    function canvasId() {
+        return props.canvas_id ?? 'momentdetail_share'
     }
 
     return <View style={{ position: 'absolute', left: 0, top: -500, width: 420, height: 336, zIndex: 10000 }}>

+ 3 - 1
src/pages/moment/moment_main.tsx

@@ -394,6 +394,7 @@ export default function MomentMain() {
     }
 
     function shareGuideContent() {
+        console.log(shareInfo)
         return <Block><View className="share_guide_bg" style={{ top: 0 }} onClick={(e) => {
             if (process.env.TARO_ENV == 'weapp') {
                 e.stopPropagation()
@@ -515,7 +516,8 @@ export default function MomentMain() {
             </ScrollView>
             <Block>
                 {
-                    showShareGuide && <MomentDetailShare user={shareInfo.join.user} btnColor={getThemeColor(shareInfo.join.window)} />
+                    showShareGuide && <MomentDetailShare user={shareInfo.join.user} btnColor={getThemeColor(shareInfo.join.window)}
+                        cover={shareInfo.moment && shareInfo.moment.media && shareInfo.moment.media.length > 0 ? shareInfo.moment.media[0].url : null} />
                 }
             </Block>
             <Block>

+ 1 - 1
src/services/http/api.js

@@ -3,7 +3,7 @@ const online = process.env.TARO_ENV == 'weapp' ? true : false;
 import { WX_VERSION as _WX_VERSION, APP_VERSION as _APP_VERSION, ANDROID_VERSION as _ANDROID_VERSION } from "../../../config/env";
 
 // export const baseUrl = online ? 'https://api.fast.liveplus.fun' : 'https://api.fast.dev.liveplus.fun';
-export const baseUrl = online ? process.env.TARO_ENV == 'rn' ? 'https://api.app.fast.liveplus.fun' : 'https://api.pre.fast.liveplus.fun' : 'https://api.fast.dev.liveplus.fun';//'https://api.pre.fast.liveplus.fun'//'https://api.fast.dev.liveplus.fun';
+export const baseUrl = online ? process.env.TARO_ENV == 'rn' ? 'https://api.app.fast.liveplus.fun' : 'https://api.fast.liveplus.fun' : 'https://api.fast.dev.liveplus.fun';//'https://api.pre.fast.liveplus.fun'//'https://api.fast.dev.liveplus.fun';
 
 export const APP_VERSION = _APP_VERSION
 export const WX_VERSION = _WX_VERSION