Commit 5eac97ee authored by sliao's avatar sliao

fix

parent 96254d43
{
"schema": [
{
"attr": 1667,
"canTrigger": true,
"code": "switch_led",
"defaultRecommend": true,
"editPermission": true,
"executable": true,
"extContent": "",
"iconname": "icon-dp_power",
"id": 20,
"mode": "rw",
"name": "灯开关",
"property": {
"type": "bool"
},
"type": "obj"
},
{
"attr": 1664,
"canTrigger": true,
"code": "work_mode",
"defaultRecommend": true,
"editPermission": true,
"executable": true,
"extContent": "",
"iconname": "icon-dp_mode",
"id": 21,
"mode": "rw",
"name": "灯模式",
"property": {
"range": [
"white",
"colour",
"scene",
"music"
],
"type": "enum"
},
"type": "obj"
},
{
"attr": 1664,
"canTrigger": true,
"code": "bright_value",
"defaultRecommend": true,
"editPermission": true,
"executable": true,
"extContent": "",
"iconname": "icon-liangdu1",
"id": 22,
"mode": "rw",
"name": "亮度值",
"property": {
"min": 10,
"max": 1000,
"scale": 0,
"step": 1,
"type": "value"
},
"type": "obj"
},
{
"attr": 1664,
"canTrigger": true,
"code": "temp_value",
"defaultRecommend": true,
"editPermission": true,
"executable": true,
"extContent": "",
"iconname": "icon-dp_half",
"id": 23,
"mode": "rw",
"name": "冷暖值",
"property": {
"min": 0,
"max": 1000,
"scale": 0,
"step": 1,
"type": "value"
},
"type": "obj"
},
{
"attr": 1664,
"canTrigger": true,
"code": "colour_data",
"defaultRecommend": true,
"editPermission": true,
"executable": true,
"extContent": "",
"iconname": "icon-yanse",
"id": 24,
"mode": "rw",
"name": "彩光",
"property": {
"type": "string",
"maxlen": 255
},
"type": "obj"
},
{
"attr": 1664,
"canTrigger": true,
"code": "scene_data",
"defaultRecommend": true,
"editPermission": true,
"executable": true,
"extContent": "",
"iconname": "icon-shoucang",
"id": 25,
"mode": "rw",
"name": "场景",
"property": {
"type": "string",
"maxlen": 255
},
"type": "obj"
},
{
"attr": 1664,
"canTrigger": true,
"code": "countdown",
"defaultRecommend": true,
"editPermission": true,
"executable": true,
"extContent": "",
"iconname": "icon-a_nav_timer",
"id": 26,
"mode": "rw",
"name": "灯倒计时",
"property": {
"unit": "s",
"min": 0,
"max": 86400,
"scale": 0,
"step": 1,
"type": "value"
},
"type": "obj"
},
{
"attr": 128,
"canTrigger": true,
"code": "music_data",
"defaultRecommend": false,
"editPermission": false,
"executable": true,
"extContent": "",
"iconname": "icon-deng",
"id": 27,
"mode": "wr",
"name": "音乐灯",
"property": {
"type": "string",
"maxlen": 255
},
"type": "obj"
},
{
"attr": 1664,
"canTrigger": true,
"code": "control_data",
"defaultRecommend": true,
"editPermission": true,
"executable": true,
"extContent": "",
"iconname": "icon-dp_box2",
"id": 28,
"mode": "wr",
"name": "调节",
"property": {
"type": "string",
"maxlen": 255
},
"type": "obj"
},
{
"attr": 128,
"canTrigger": true,
"code": "power_memory",
"defaultRecommend": false,
"editPermission": false,
"executable": true,
"extContent": "",
"iconname": "icon-Trigger",
"id": 33,
"mode": "rw",
"name": "断电记忆",
"type": "raw"
},
{
"attr": 128,
"canTrigger": true,
"code": "do_not_disturb",
"defaultRecommend": false,
"editPermission": false,
"executable": true,
"extContent": "",
"iconname": "icon-dp_mode",
"id": 34,
"mode": "rw",
"name": "勿扰模式",
"property": {
"type": "bool"
},
"type": "obj"
},
{
"attr": 128,
"canTrigger": true,
"code": "switch_gradient",
"defaultRecommend": false,
"editPermission": false,
"executable": true,
"extContent": "",
"iconname": "icon-dp_mode",
"id": 35,
"mode": "rw",
"name": "开关渐变",
"type": "raw"
},
{
"attr": 128,
"canTrigger": true,
"code": "mix_light_scene",
"defaultRecommend": false,
"editPermission": false,
"executable": true,
"extContent": "",
"iconname": "icon-dp_mode",
"id": 36,
"mode": "rw",
"name": "混光场景",
"type": "raw"
},
{
"attr": 640,
"canTrigger": true,
"code": "mix_rgbcw",
"defaultRecommend": true,
"editPermission": false,
"executable": true,
"extContent": "",
"iconname": "icon-deng",
"id": 51,
"mode": "rw",
"name": "混光",
"type": "raw"
},
{
"attr": 1664,
"canTrigger": true,
"code": "fan_switch",
"defaultRecommend": true,
"editPermission": true,
"executable": true,
"extContent": "",
"iconname": "icon-dp_power2",
"id": 60,
"mode": "rw",
"name": "风扇开关",
"property": {
"type": "bool"
},
"type": "obj"
},
{
"attr": 1664,
"canTrigger": true,
"code": "fan_mode",
"defaultRecommend": true,
"editPermission": true,
"executable": true,
"extContent": "",
"iconname": "icon-a_mode_fan",
"id": 61,
"mode": "rw",
"name": "风模式",
"property": {
"range": [
"fresh",
"nature"
],
"type": "enum"
},
"type": "obj"
},
{
"attr": 1664,
"canTrigger": true,
"code": "fan_speed",
"defaultRecommend": true,
"editPermission": true,
"executable": true,
"extContent": "",
"iconname": "icon-FanSpeed",
"id": 62,
"mode": "rw",
"name": "风速",
"property": {
"min": 1,
"max": 100,
"scale": 0,
"step": 1,
"type": "value"
},
"type": "obj"
},
{
"attr": 1664,
"canTrigger": true,
"code": "fan_direction",
"defaultRecommend": true,
"editPermission": true,
"executable": true,
"extContent": "",
"iconname": "icon-dp_mode",
"id": 63,
"mode": "rw",
"name": "风向",
"property": {
"range": [
"forward",
"reverse"
],
"type": "enum"
},
"type": "obj"
},
{
"attr": 1664,
"canTrigger": true,
"code": "fan_countdown_left",
"defaultRecommend": true,
"editPermission": true,
"executable": true,
"extContent": "",
"iconname": "icon-dp_time3",
"id": 64,
"mode": "rw",
"name": "风扇倒计时",
"property": {
"unit": "min",
"min": 0,
"max": 540,
"scale": 0,
"step": 1,
"type": "value"
},
"type": "obj"
},
{
"attr": 1152,
"canTrigger": true,
"code": "fan_beep",
"defaultRecommend": false,
"editPermission": true,
"executable": true,
"extContent": "",
"iconname": "icon-dp_voice",
"id": 66,
"mode": "rw",
"name": "蜂鸣器",
"property": {
"type": "bool"
},
"type": "obj"
},
{
"attr": 1152,
"canTrigger": true,
"code": "fault",
"defaultRecommend": false,
"editPermission": true,
"executable": true,
"extContent": "",
"iconname": "icon-baojing",
"id": 67,
"mode": "ro",
"name": "故障告警",
"property": {
"label": [
"motor_fault"
],
"type": "bitmap",
"maxlen": 1
},
"type": "obj"
}
],
"panelConfig": {
"bic": [
{
"code": "timer",
"selected": false
},
{
"code": "jump_url",
"selected": false
}
]
},
"pv": "2.0",
"icon": "https://images.tuyacn.com/smart/icon/bay1667456326777tesu/df74fc5b76dbb325c175c5ffbe189828.png",
"isOnline": true,
"uuid": "vdevo166780480910513",
"bv": "2.0",
"ability": 0,
"devId": "vdevo166780480910513",
"productId": "hcwquhbmkmjatays",
"dps": {
"20": false,
"21": "white",
"22": 10,
"23": 0,
"24": "",
"25": "",
"26": 0,
"27": "",
"28": "",
"34": false,
"60": true,
"61": "fresh",
"62": 1,
"63": "forward",
"64": 0,
"66": false,
"67": 0
},
"ip": "36.27.64.253",
"activeTime": 1667804809,
"isShare": false,
"name": "fengshandeng-vdevo",
"i18nTime": 1667804685162,
"localKey": "edb05e1e62e54406",
"dpCodes": {
"switch_led": false,
"work_mode": "white",
"bright_value": 10,
"temp_value": 0,
"colour_data": "",
"scene_data": "",
"countdown": 0,
"music_data": "",
"control_data": "",
"do_not_disturb": false,
"fan_switch": true,
"fan_mode": "fresh",
"fan_speed": 1,
"fan_direction": "forward",
"fan_countdown_left": 0,
"fan_beep": false,
"fault": 0
},
"capability": 1025,
"category": "fsd",
"attribute": 274877906948,
"devAttribute": 0,
"devTimezoneId": "Asia/Shanghai",
"isCloudOnline": true,
"latitude": "",
"longitude": "",
"dpName": {},
"dpsTime": {
"20": 1667805655637,
"21": 1667804809165,
"22": 1667804809165,
"23": 1667804809165,
"24": 1667804809165,
"25": 1667804809165,
"26": 1667804809165,
"27": 1667804809165,
"28": 1667804809165,
"33": 1667804809165,
"34": 1667804809165,
"35": 1667804809165,
"36": 1667804809165,
"51": 1667804809165,
"60": 1667895485379,
"61": 1667804809165,
"62": 1667804809165,
"63": 1667804809165,
"64": 1667804809165,
"66": 1667804809165,
"67": 1667804809165
},
"isVirtualDevice": true,
"idCodes": {
"20": "switch_led",
"21": "work_mode",
"22": "bright_value",
"23": "temp_value",
"24": "colour_data",
"25": "scene_data",
"26": "countdown",
"27": "music_data",
"28": "control_data",
"33": "power_memory",
"34": "do_not_disturb",
"35": "switch_gradient",
"36": "mix_light_scene",
"51": "mix_rgbcw",
"60": "fan_switch",
"61": "fan_mode",
"62": "fan_speed",
"63": "fan_direction",
"64": "fan_countdown_left",
"66": "fan_beep",
"67": "fault"
},
"codeIds": {
"switch_led": 20,
"work_mode": 21,
"bright_value": 22,
"temp_value": 23,
"colour_data": 24,
"scene_data": 25,
"countdown": 26,
"music_data": 27,
"control_data": 28,
"power_memory": 33,
"do_not_disturb": 34,
"switch_gradient": 35,
"mix_light_scene": 36,
"mix_rgbcw": 51,
"fan_switch": 60,
"fan_mode": 61,
"fan_speed": 62,
"fan_direction": 63,
"fan_countdown_left": 64,
"fan_beep": 66,
"fault": 67
}
}
\ No newline at end of file
......@@ -5,7 +5,7 @@ import '@/i18n';
import composeLayout from './composeLayout';
import { SdmProvider } from '@ray-js/sdm-react';
import { devices } from '@/devices';
import { ProductName } from '@/constants';
// import { ProductName } from '@/constants';
const { initPanelEnvironment } = kit;
......@@ -14,7 +14,7 @@ interface Props {
}
initPanelEnvironment({ useDefaultOffline: true });
class App extends React.Component<Props> {
class App extends React.Component<Props>{
componentDidMount() {
console.info('app did mount ');
}
......@@ -25,7 +25,7 @@ class App extends React.Component<Props> {
render() {
return <SdmProvider value={devices[ProductName]} >{this.props.children}</SdmProvider>;
return <SdmProvider value={devices.fan} >{this.props.children}</SdmProvider>;
}
}
......
......@@ -9,23 +9,28 @@
// position: absolute;
// top: calc(50vh - 175px);
margin-top: 90px;
padding: 20px 0 40px;
padding: 0 0 40px;
color: #000000;
z-index: 9999;
}
.lightModalTop {
display: flex;
align-items: center;
padding: 0 20px;
// padding: 0 20px;
width: 100%;
justify-content: space-between;
font-size: 16px;
margin-bottom: 40px;
}
.lightCloseBg {
padding: 20px 20px 0;
}
.lightModalClose {
width: 24px;
height: 24px;
}
.lightMiddle {
// width: 100%;
height: 155px;
......@@ -86,6 +91,7 @@
top: 1px;
bottom: 1px;
z-index: 2;
border-radius: 0 0 0 16px;
}
.lightBtn {
width: 310px;
......
......@@ -23,7 +23,7 @@ export const LightPanel = React.memo<Props>(props => {
const brightCode = 'bright_value'
const temperatureCode = 'temp_value'
const switchCode = 'switch_led'
const switchCode = 'light'
let { isShow, setModal} = props;
const brightVal = useSdmProps(dpState => {
......@@ -33,8 +33,8 @@ export const LightPanel = React.memo<Props>(props => {
});
const temperatureVal = useSdmProps(dpState => {
const val = dpState[temperatureCode]
const percent = getValueInRange(val || 0, cctRange).percent
return percent
// const percent = getValueInRange(val || 0, cctRange).percent
return val
});
const switchVal = useSdmProps(dpState => dpState[switchCode]);
......@@ -44,12 +44,14 @@ export const LightPanel = React.memo<Props>(props => {
const brightAction = actions[brightCode] as DpCommonAction<number>
const temperatureAction = actions[temperatureCode] as DpCommonAction<number>
const [point, setPoint] = useState({pageX: getOrignPointX(), pageY: 234})
const [point, setPoint] = useState({pageX: getOrignPointX(), pageY: 250})
const [selectColor, setColor] = useState(pointToRGB(point.pageX))
function getOrignPointX() {
const percent = getValueInRange(temperatureVal || 10, cctRange).percent
return 28 + 319 * Number((percent / 100).toFixed())
const originX = 28 + 319 * (percent / 100)
console.log(temperatureVal, percent, originX);
return originX
}
//0-value是值 1-value是百分比 左边最小值是0,右边最大值range[1],起始位置rang[0]
function getValueInRange(value, range, type = 0) {
......@@ -61,20 +63,14 @@ export const LightPanel = React.memo<Props>(props => {
}
function touchStart(e) {
console.log(e, 'start touch');
handlePoint(e)
}
function handleTouch(e) {
// console.log(e, 'handle touch');
// const point = e.changedTouches.length && e.changedTouches[0]
// console.log(point, 'pppppppoint');
// handlePoint(e)
handlePoint(e)
}
function touchEnd(e) {
console.log(e, 'end touch');
handlePoint(e)
}
......@@ -145,7 +141,7 @@ export const LightPanel = React.memo<Props>(props => {
function progressMove(e) {
console.log(e, 'progressMove');
// handleProgress(e)
handleProgress(e)
}
function progressEnd(e) {
......@@ -172,12 +168,13 @@ export const LightPanel = React.memo<Props>(props => {
<View className={styles.modalback} style={{background:'rgba(0, 0, 0, 0.1)',backdropFilter:'blur(35px)', visibility: isShow ? 'visible':'hidden' }}>
<View className={styles.lightModal}>
<View className={styles.lightModalTop}>
<View>Light
</View>
<View className={styles.lightCloseBg}>Light</View>
<View className={styles.lightCloseBg}>
<Image className={styles.lightModalClose} src={iconClose} onClick={() => {
setModal(false)
}}></Image>
</View>
</View>
<View
className={styles.lightMiddle}
onTouchStart={touchStart}
......@@ -190,7 +187,7 @@ export const LightPanel = React.memo<Props>(props => {
onTouchEnd={progressEnd}>
<Image className={styles.progressSun} src={iconSun}></Image>
<View className={styles.progressTitle}>{brightVal}%</View>
<View className={styles.progressBar} style={{width: brightVal + '%'}}></View>
<View className={styles.progressBar} style={{width: (brightVal - 0.5) + '%', borderBottomRightRadius: brightVal == 100 ? '16px':'0'}}></View>
</View>
<View className={styles.lightBtn} style={{backgroundColor: switchVal ? '#6395F6':'rgba(0,0,0,0.5)'}} onClick={handleLightOn}>
<Image className={styles.lightBtnIcon} src={iconLightWhite}></Image>
......
......@@ -105,19 +105,24 @@
position: relative;
}
.modalBg {
position: absolute;
left: 0;
right: 0;
bottom: 101px;
// position: absolute;
// left: 0;
// right: 0;
margin-bottom: -164px;
display: flex;
flex-direction: column;
// align-items: flex-end;
background-color: white;
min-height: 127px;
flex-direction: column;
width: 90vw;
z-index: 999;
box-shadow: 0px 4px 24px rgba(0, 0, 0, 0.05);
box-shadow: 0px 4px 14px rgba(0, 0, 0, 0.05);
border-radius: 24px;
align-self: center;
}
.swiper {
width: 100%;
......@@ -128,6 +133,7 @@
width: 36px;
height: 16px;
margin-bottom: -1px;
z-index: 10000;
}
.sliderBg {
......
......@@ -16,7 +16,7 @@ import { Text, View, Swiper, SwiperItem} from '@ray-js/components';
// openTimerPage,
// } from '@ray-js/api';
// import { hooks } from '@ray-js/panel-sdk';
import { router, usePageEvent, setNavigationBarTitle } from '@ray-js/ray';
import { router, usePageEvent, setNavigationBarTitle} from '@ray-js/ray';
import React from 'react';
import { useSelector } from '@/redux';
import styles from './index.module.less';
......@@ -63,7 +63,9 @@ export function Home() {
const fanModeCode = 'mode'
const currentTempCode = 'temp_current'
const isOpen = useSdmProps((props) => props[fanSwitchCode])
const isOpen = useSdmProps((props) => {
return Boolean(props[fanSwitchCode])
})
const spinSpeed = useSdmProps((props) => Number(props[fanSpeedCode]))
const fanModeVal = useSdmProps((props) => props[fanModeCode])
......@@ -192,6 +194,19 @@ export function Home() {
)
}
const toggleModal = () => {
console.log('toggleModal');
// setModal(false)
setMenuIndex(null)
};
const modalSetting = {
show: true,
position: 'center',
overlay:true,
onClickOverlay: toggleModal,
overlayStyle: {backgroundColor: 'transparent'}
}
return (
<View className={styles.page}>
......@@ -208,16 +223,18 @@ export function Home() {
</View>
<View className={styles.sliderBg}>
<Slider
activeColor='linear-gradient(180deg, #87ABF2 11.62%, #4B7EE2 100%)'
activeColor='linear-gradient(-90deg, #87ABF2 11.62%, #4B7EE2 100%)'
blockColor='white'
blockSize={28}
min={0}
min={1}
max={100}
value={spinSpeed}
step={1}
disabled={!isOpen}
onChange={(e) => {
console.log('SliderChange', e)
speedAction.set(e.value)
}}
onChanging={(e) => {
speedAction.set(e.value)
}}
/>
......@@ -236,7 +253,8 @@ export function Home() {
>
{
menuIndex == 1 ?
<View className={styles.modalBg}>
<Modal show={true} position='center' overlay={true} onClickOverlay={toggleModal} overlayStyle={{backgroundColor: 'transparent'}}>
<View className={styles.modalBg} >
<Swiper dots={true} dotActiveColor='#6395F6' dotColor='rgba(99,149,246, 0.2)'>
<SwiperItem>
<View className={styles.swiperItem}>
......@@ -263,9 +281,13 @@ export function Home() {
</SwiperItem>
</Swiper>
</View>
: menuIndex == 3 ? <View className={styles.modalBg} style={{height: '213px', display: 'flex', flexDirection:'column', padding:'16px 16px 0', gap:'12px'}}>
</Modal>
: menuIndex == 3 ?
<Modal show={true} position='center' overlay={true} onClickOverlay={toggleModal} overlayStyle={{backgroundColor: 'transparent'}}>
<View className={styles.modalBg} style={{height: '213px', display: 'flex', flexDirection:'column', padding:'16px 16px 0', gap:'12px', marginBottom:'-102px'}}>
<FanVertical></FanVertical>
</View>
</Modal>
: null
}
<Image className={styles.middleware} src={middleware} style={{visibility: menuIndex == index ? 'visible':'hidden'}} />
......
......@@ -5,7 +5,8 @@ export const routes: Routes = [
route: '/',
path: '/pages/home/index',
name: 'Home',
},
id:'home'
}
// {
// route: '/common/page4/index',
// path: '/pages/common/page4/index',
......
......@@ -3,10 +3,10 @@ import { ProductName } from '@/constants';
type SmartDeviceSchema = typeof import('@/devices/schema').fanSchema;
type SmartDevices = {
[ProductName]?: import('@tuya-miniapp/sdm').SmartDeviceModel<SmartDeviceSchema>;
fan?: import('@tuya-miniapp/sdm').SmartDeviceModel<SmartDeviceSchema>;
};
declare module '@ray-js/sdm-react' {
// declare module '@ray-js/sdm-react' {
// export const SdmProvider: React.FC<{
// value: SmartDeviceModel<SmartDeviceSchema>;
// children: React.ReactNode;
......@@ -27,5 +27,5 @@ declare module '@ray-js/sdm-react' {
// selector: (device: SmartDeviceInstanceData) => Device,
// equalityFn?: (a: Device, b: Device) => boolean
// ): Device;
export function useActions(): SmartDevices[ProductName]['model']['actions'];
}
// export function useActions(): SmartDevices[ProductName]['model']['actions'];
// }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment