|
@@ -49,7 +49,7 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
|
|
|
var data = calculateNumber(brightnessValue)
|
|
var data = calculateNumber(brightnessValue)
|
|
|
if (lastValue != data && data == 5) {
|
|
if (lastValue != data && data == 5) {
|
|
|
Taro.vibrateShort({
|
|
Taro.vibrateShort({
|
|
|
- type: 'heavy'
|
|
|
|
|
|
|
+ type: 'light'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
lastValue = data
|
|
lastValue = data
|
|
@@ -61,6 +61,9 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
|
|
|
const handleTouchEnd = () => {
|
|
const handleTouchEnd = () => {
|
|
|
|
|
|
|
|
setIsSliding(false);
|
|
setIsSliding(false);
|
|
|
|
|
+ Taro.vibrateShort({
|
|
|
|
|
+ type: 'heavy'
|
|
|
|
|
+ })
|
|
|
if (props.onChanged) {
|
|
if (props.onChanged) {
|
|
|
|
|
|
|
|
var obj = common.food_scales.filter((item: any) => {
|
|
var obj = common.food_scales.filter((item: any) => {
|
|
@@ -68,8 +71,8 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
Taro.showModal({
|
|
Taro.showModal({
|
|
|
- title: props.isPreMeal ? t('feature.food.pre_meal_confirm_title') : t('feature.food.post_meal_confirm_title'),
|
|
|
|
|
- content: value + '分 - ' + obj[0].description ?? '暂无描述',
|
|
|
|
|
|
|
+ title: props.isPreMeal ? t('feature.food.pre_meal_confirm_title', { score: value, desc: value < 5 ? '饿' : '饱' }) : t('feature.food.post_meal_confirm_title', { score: value, desc: value < 5 ? '饿' : '饱' }),
|
|
|
|
|
+ content: obj[0].description ? obj[0].description : '暂无描述',
|
|
|
success: function (res) {
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
if (res.confirm) {
|
|
|
props.onChanged && props.onChanged(value);
|
|
props.onChanged && props.onChanged(value);
|
|
@@ -90,32 +93,28 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
if (props.edit) {
|
|
if (props.edit) {
|
|
|
- if (startX != 0 && value != 0) {
|
|
|
|
|
- // 松手后,滑块动画移动到最左边
|
|
|
|
|
- Taro.vibrateShort({
|
|
|
|
|
- type: 'heavy'
|
|
|
|
|
- })
|
|
|
|
|
- // Taro.showToast({
|
|
|
|
|
- // icon: 'none',
|
|
|
|
|
- // title: '请先上传!'
|
|
|
|
|
- // })
|
|
|
|
|
- Taro.showModal({
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- content: t('feature.food.pre_meal_enforce_order_alert'),
|
|
|
|
|
- showCancel: false,
|
|
|
|
|
- confirmText: '好的',
|
|
|
|
|
- success: function (res) {
|
|
|
|
|
- if (res.confirm) {
|
|
|
|
|
- setShowArrow(true)
|
|
|
|
|
- setStartX(0);
|
|
|
|
|
- setBrightness(0)
|
|
|
|
|
- setValue(0)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 松手后,滑块动画移动到最左边
|
|
|
|
|
+
|
|
|
|
|
+ // Taro.showToast({
|
|
|
|
|
+ // icon: 'none',
|
|
|
|
|
+ // title: '请先上传!'
|
|
|
|
|
+ // })
|
|
|
|
|
+ Taro.showModal({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ content: t('feature.food.pre_meal_enforce_order_alert'),
|
|
|
|
|
+ showCancel: false,
|
|
|
|
|
+ confirmText: '好的',
|
|
|
|
|
+ success: function (res) {
|
|
|
|
|
+ if (res.confirm) {
|
|
|
|
|
+ setShowArrow(true)
|
|
|
|
|
+ setStartX(0);
|
|
|
|
|
+ setBrightness(0)
|
|
|
|
|
+ setValue(0)
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
- // const animationId = requestAnimationFrame(moveToStart);
|
|
|
|
|
- // return () => cancelAnimationFrame(animationId);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ // const animationId = requestAnimationFrame(moveToStart);
|
|
|
|
|
+ // return () => cancelAnimationFrame(animationId);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -187,7 +186,7 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
|
|
|
onTouchStart={handleTouchStart}
|
|
onTouchStart={handleTouchStart}
|
|
|
onTouchMove={handleTouchMove}
|
|
onTouchMove={handleTouchMove}
|
|
|
onTouchEnd={handleTouchEnd}>
|
|
onTouchEnd={handleTouchEnd}>
|
|
|
- <View className='slider-tip-bg' style={{ width: (100 - brightness) * 0.01 * rpxToPx(sliderWidth - 120) + rpxToPx(28) }}>
|
|
|
|
|
|
|
+ <View className='slider-tip-bg' style={{ width: (100 - brightness) * 0.01 * rpxToPx(sliderWidth) - brightness * 0.01 * rpxToPx(120) + brightness * 0.01 * rpxToPx(28) }}>
|
|
|
<Text className={value < 5 ? 'slider-tip-title' : 'slider-tip-title-post'}>{value < 5 ?
|
|
<Text className={value < 5 ? 'slider-tip-title' : 'slider-tip-title-post'}>{value < 5 ?
|
|
|
t('feature.food.slider_tip_pre_meal_title') :
|
|
t('feature.food.slider_tip_pre_meal_title') :
|
|
|
t('feature.food.slider_tip_post_meal_title')}</Text>
|
|
t('feature.food.slider_tip_post_meal_title')}</Text>
|
|
@@ -196,8 +195,10 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
|
|
|
t('feature.food.slider_tip_post_meal_desc')}</Text>
|
|
t('feature.food.slider_tip_post_meal_desc')}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<View className='slider-item-content'>
|
|
<View className='slider-item-content'>
|
|
|
- <View className='slider-item-bg' style={{ width: brightness * 0.01 * rpxToPx(sliderWidth - 126) + rpxToPx(112),
|
|
|
|
|
- backgroundColor: value==5?'#fff':value<5?ColorType.fast:ColorType.food}}>
|
|
|
|
|
|
|
+ <View className='slider-item-bg' style={{
|
|
|
|
|
+ width: brightness * 0.01 * rpxToPx(sliderWidth - 126) + rpxToPx(112),
|
|
|
|
|
+ backgroundColor: value == 5 ? '#fff' : value < 5 ? ColorType.fast : ColorType.food
|
|
|
|
|
+ }}>
|
|
|
{/* <View className='slider-item' style={{
|
|
{/* <View className='slider-item' style={{
|
|
|
width: brightness * 0.01 * rpxToPx(sliderWidth - 126) + rpxToPx(112) + 1,
|
|
width: brightness * 0.01 * rpxToPx(sliderWidth - 126) + rpxToPx(112) + 1,
|
|
|
backgroundColor: brightness <= 50 ? ColorType.fast : ColorType.food,
|
|
backgroundColor: brightness <= 50 ? ColorType.fast : ColorType.food,
|
|
@@ -222,7 +223,7 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
|
|
|
isSliding && <View className='tooltip_bg'>
|
|
isSliding && <View className='tooltip_bg'>
|
|
|
<View style={{ flex: 1 }} />
|
|
<View style={{ flex: 1 }} />
|
|
|
<View className='tooltip_content'>
|
|
<View className='tooltip_content'>
|
|
|
- <Text className='tooltip_title'>{getTitle()}</Text>
|
|
|
|
|
|
|
+ <Text className='tooltip_title' style={{ color: value == 5 ? '#fff' : value < 5 ? ColorType.fast : ColorType.food }}>{props.isPostMeal ? '餐后' : '餐前'}{getTitle()}</Text>
|
|
|
<Text className='tooltip_desc'>{getDesc()}</Text>
|
|
<Text className='tooltip_desc'>{getDesc()}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<View className='tooltip_arrow' style={{ marginLeft: brightness * 0.01 * rpxToPx(sliderWidth - 120) + rpxToPx((120 - 50) / 2) }} />
|
|
<View className='tooltip_arrow' style={{ marginLeft: brightness * 0.01 * rpxToPx(sliderWidth - 120) + rpxToPx((120 - 50) / 2) }} />
|