|
@@ -253,10 +253,12 @@ export default function Schedules() {
|
|
|
|
|
|
|
|
function add(isEat) {
|
|
function add(isEat) {
|
|
|
var isMax = false
|
|
var isMax = false
|
|
|
|
|
+ var max = 0
|
|
|
if (isEat) {
|
|
if (isEat) {
|
|
|
setIsEat(true)
|
|
setIsEat(true)
|
|
|
var scenario = getScenario(health.windows, 'EAT')
|
|
var scenario = getScenario(health.windows, 'EAT')
|
|
|
const countFastWindows = list.filter(item => item.window === 'EAT').length;
|
|
const countFastWindows = list.filter(item => item.window === 'EAT').length;
|
|
|
|
|
+ max = scenario.access.max
|
|
|
if (scenario.access.max && countFastWindows >= scenario.access.max) {
|
|
if (scenario.access.max && countFastWindows >= scenario.access.max) {
|
|
|
isMax = true
|
|
isMax = true
|
|
|
}
|
|
}
|
|
@@ -265,14 +267,18 @@ export default function Schedules() {
|
|
|
setIsEat(false)
|
|
setIsEat(false)
|
|
|
var scenario = getScenario(health.windows, 'ACTIVE')
|
|
var scenario = getScenario(health.windows, 'ACTIVE')
|
|
|
const countFastWindows = list.filter(item => item.window === 'ACTIVE').length;
|
|
const countFastWindows = list.filter(item => item.window === 'ACTIVE').length;
|
|
|
|
|
+ max = scenario.access.max
|
|
|
if (scenario.access.max && countFastWindows >= scenario.access.max) {
|
|
if (scenario.access.max && countFastWindows >= scenario.access.max) {
|
|
|
isMax = true
|
|
isMax = true
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (isMax) {
|
|
if (isMax) {
|
|
|
|
|
+ var type = isEat?t('health.member_meal'):t('health.member_activity')
|
|
|
showAlert({
|
|
showAlert({
|
|
|
- title: '会员',
|
|
|
|
|
- content: '会员desc',
|
|
|
|
|
|
|
+ title: t('health.become_member_title'),
|
|
|
|
|
+ content: t('health.become_member_desc',{count:max,type:type}),
|
|
|
|
|
+ cancelText:t('health.not_now'),
|
|
|
|
|
+ confirmText:t('health.choose_plan'),
|
|
|
showCancel: true,
|
|
showCancel: true,
|
|
|
confirm: () => {
|
|
confirm: () => {
|
|
|
jumpPage('/pages/store/product_list', 'ProductList', navigation)
|
|
jumpPage('/pages/store/product_list', 'ProductList', navigation)
|
|
@@ -283,6 +289,49 @@ export default function Schedules() {
|
|
|
setShowModal(true)
|
|
setShowModal(true)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function checkDel(obj){
|
|
|
|
|
+ const {window} = obj
|
|
|
|
|
+ if (window == 'EAT'){
|
|
|
|
|
+ var scenario = getScenario(health.windows, 'EAT')
|
|
|
|
|
+ const countFastWindows = list.filter(item => item.window === 'EAT').length;
|
|
|
|
|
+ var min = scenario.access.min
|
|
|
|
|
+ if (countFastWindows == min){
|
|
|
|
|
+ var type = ''
|
|
|
|
|
+ if (global.language == 'en'){
|
|
|
|
|
+ type = min == 1?'meal':'meals'
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ type = '餐次'
|
|
|
|
|
+ }
|
|
|
|
|
+ Taro.showToast({
|
|
|
|
|
+ title:t('health.keep_at_least',{number:min,type:type}),
|
|
|
|
|
+ icon:'none'
|
|
|
|
|
+ })
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ var scenario = getScenario(health.windows, 'ACTIVE')
|
|
|
|
|
+ const countFastWindows = list.filter(item => item.window === 'ACTIVE').length;
|
|
|
|
|
+ var min = scenario.access.min
|
|
|
|
|
+ if (countFastWindows == min){
|
|
|
|
|
+ var type = ''
|
|
|
|
|
+ if (global.language == 'en'){
|
|
|
|
|
+ type = min == 1?'activity':'activities'
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ type = '活动'
|
|
|
|
|
+ }
|
|
|
|
|
+ Taro.showToast({
|
|
|
|
|
+ title:t('health.keep_at_least',{number:min,type:type}),
|
|
|
|
|
+ icon:'none'
|
|
|
|
|
+ })
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function getAddColor() {
|
|
function getAddColor() {
|
|
|
if (selMode == 'FAST' || selMode == 'EAT') {
|
|
if (selMode == 'FAST' || selMode == 'EAT') {
|
|
|
return getThemeColor('EAT')
|
|
return getThemeColor('EAT')
|
|
@@ -348,44 +397,6 @@ export default function Schedules() {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- function more2() {
|
|
|
|
|
- var items: any = ['设置提醒', '个性化名称'];
|
|
|
|
|
- var temps = list.filter(item => {
|
|
|
|
|
- return !item.specific_time
|
|
|
|
|
- })
|
|
|
|
|
- var needOrder = false
|
|
|
|
|
- if (temps.length > 1) {
|
|
|
|
|
- needOrder = true
|
|
|
|
|
- items.push('排序')
|
|
|
|
|
- }
|
|
|
|
|
- if (errors.length == 0) {
|
|
|
|
|
- items.push(t('health.reset_schedule'))
|
|
|
|
|
- }
|
|
|
|
|
- showActionSheet({
|
|
|
|
|
- showActionSheetWithOptions: showActionSheetWithOptions,
|
|
|
|
|
- title: t('health.more_actions'),
|
|
|
|
|
- itemList: items,
|
|
|
|
|
- success: (res) => {
|
|
|
|
|
- if (res == 0 || res == 1) {
|
|
|
|
|
- var url = `./schedules_edit?type=${res == 0 ? 'reminder' : 'name'}&mode=${selMode}`
|
|
|
|
|
- jumpPage(url)
|
|
|
|
|
- }
|
|
|
|
|
- else if (res == 2) {
|
|
|
|
|
- if (needOrder) {
|
|
|
|
|
- jumpPage('./schedules_order?list=' + JSON.stringify(temps))
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- jumpPage('/_health/pages/guide_begin')
|
|
|
|
|
- }
|
|
|
|
|
- else if (res == 3) {
|
|
|
|
|
- jumpPage('/_health/pages/guide_begin')
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
function reset() {
|
|
function reset() {
|
|
|
jumpPage('/_health/pages/guide_begin')
|
|
jumpPage('/_health/pages/guide_begin')
|
|
|
}
|
|
}
|
|
@@ -436,14 +447,14 @@ export default function Schedules() {
|
|
|
<StatusIndicator type={StatusType.img}
|
|
<StatusIndicator type={StatusType.img}
|
|
|
fontColor="#000"
|
|
fontColor="#000"
|
|
|
fontSize={rpxToPx(24)}
|
|
fontSize={rpxToPx(24)}
|
|
|
- text='已自动保存' color={MainColorType.success}>
|
|
|
|
|
|
|
+ text={t('health.auto_save')} color={MainColorType.success}>
|
|
|
<IconSuccess color="#fff" width={rpxToPx(26)} />
|
|
<IconSuccess color="#fff" width={rpxToPx(26)} />
|
|
|
</StatusIndicator>
|
|
</StatusIndicator>
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
- {
|
|
|
|
|
|
|
+ {/* {
|
|
|
!health.finish_setup && selMode == '' && <View className='success_tip' style={{ backgroundColor: MainColorType.blue + '1A', color: MainColorType.blue }}>You haven't finished setting up your schedule yet!</View>
|
|
!health.finish_setup && selMode == '' && <View className='success_tip' style={{ backgroundColor: MainColorType.blue + '1A', color: MainColorType.blue }}>You haven't finished setting up your schedule yet!</View>
|
|
|
- }
|
|
|
|
|
|
|
+ } */}
|
|
|
{
|
|
{
|
|
|
list.map((obj, i) => {
|
|
list.map((obj, i) => {
|
|
|
return <ScheduleItem
|
|
return <ScheduleItem
|
|
@@ -456,7 +467,7 @@ export default function Schedules() {
|
|
|
showLine={i < list.length - 1}
|
|
showLine={i < list.length - 1}
|
|
|
errors={errors}
|
|
errors={errors}
|
|
|
selMode={selMode}
|
|
selMode={selMode}
|
|
|
- disable={!health.finish_setup}
|
|
|
|
|
|
|
+ // disable={!health.finish_setup}
|
|
|
labels={timeLabels}
|
|
labels={timeLabels}
|
|
|
tapSpecificTime={(detail) => {
|
|
tapSpecificTime={(detail) => {
|
|
|
obj.time = detail.time
|
|
obj.time = detail.time
|
|
@@ -486,11 +497,15 @@ export default function Schedules() {
|
|
|
onDelete={() => {
|
|
onDelete={() => {
|
|
|
if (errors.length > 0) {
|
|
if (errors.length > 0) {
|
|
|
Taro.showToast({
|
|
Taro.showToast({
|
|
|
- title: '请先解决冲突',
|
|
|
|
|
|
|
+ title: t('health.resolve_conflict'),
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!checkDel(obj)){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
delSchedule(obj.id).then(res => {
|
|
delSchedule(obj.id).then(res => {
|
|
|
var array = JSON.parse(JSON.stringify(list))
|
|
var array = JSON.parse(JSON.stringify(list))
|
|
|
array.splice(i, 1)
|
|
array.splice(i, 1)
|
|
@@ -550,7 +565,7 @@ export default function Schedules() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- errors.length == 0 && health.finish_setup && <View style={{
|
|
|
|
|
|
|
+ errors.length == 0 /*&& health.finish_setup*/ && <View style={{
|
|
|
backgroundColor: 'transparent',
|
|
backgroundColor: 'transparent',
|
|
|
position: 'relative',
|
|
position: 'relative',
|
|
|
display: 'flex',
|
|
display: 'flex',
|
|
@@ -607,7 +622,7 @@ export default function Schedules() {
|
|
|
{/* <ListFooter /> */}
|
|
{/* <ListFooter /> */}
|
|
|
|
|
|
|
|
<View style={{ flex: 1 }} />
|
|
<View style={{ flex: 1 }} />
|
|
|
- {
|
|
|
|
|
|
|
+ {/* {
|
|
|
selMode == '' && !health.finish_setup && <View className="main_footer">
|
|
selMode == '' && !health.finish_setup && <View className="main_footer">
|
|
|
<NewButton
|
|
<NewButton
|
|
|
type={NewButtonType.fill}
|
|
type={NewButtonType.fill}
|
|
@@ -621,7 +636,7 @@ export default function Schedules() {
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
</View>
|
|
</View>
|
|
|
- }
|
|
|
|
|
|
|
+ } */}
|
|
|
|
|
|
|
|
|
|
|
|
|
{/* <View className="edit_footer_btn" style={{ color: getThemeColor(health.mode), backgroundColor: getThemeColor(health.mode) + '33' }} onClick={tapEdit}>批量编辑</View> */}
|
|
{/* <View className="edit_footer_btn" style={{ color: getThemeColor(health.mode), backgroundColor: getThemeColor(health.mode) + '33' }} onClick={tapEdit}>批量编辑</View> */}
|
|
@@ -645,6 +660,7 @@ export default function Schedules() {
|
|
|
op_page={getOpPage()}
|
|
op_page={getOpPage()}
|
|
|
confirm={(res) => {
|
|
confirm={(res) => {
|
|
|
checkResultData(res)
|
|
checkResultData(res)
|
|
|
|
|
+ setShowModal(false)
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
}
|
|
}
|