|
@@ -11,6 +11,7 @@ import { jumpPage } from '../trackTimeDuration/hooks/Common'
|
|
|
import { IconShare } from '@/components/basic/Icons'
|
|
import { IconShare } from '@/components/basic/Icons'
|
|
|
import { useTranslation } from 'react-i18next'
|
|
import { useTranslation } from 'react-i18next'
|
|
|
import { ColorType } from '@/context/themes/color'
|
|
import { ColorType } from '@/context/themes/color'
|
|
|
|
|
+import { clearFoodCache, getFoodCache, saveFoodCache } from './hooks/ExtraData'
|
|
|
let useNavigation;
|
|
let useNavigation;
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
@@ -67,6 +68,14 @@ export default function Component(props: { addItem: Function, firstItem: any })
|
|
|
jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
|
|
jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ var params = {
|
|
|
|
|
+ event:'add_a_picture',
|
|
|
|
|
+ value:isAlbum?'choose_from_album':'use_camera',
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ saveFoodCache('create',params)
|
|
|
|
|
+
|
|
|
clearFile()
|
|
clearFile()
|
|
|
Taro.chooseMedia({
|
|
Taro.chooseMedia({
|
|
|
count: 1,
|
|
count: 1,
|
|
@@ -74,6 +83,13 @@ export default function Component(props: { addItem: Function, firstItem: any })
|
|
|
mediaType: ['image'],
|
|
mediaType: ['image'],
|
|
|
sourceType: [isAlbum ? 'album' : 'camera'],
|
|
sourceType: [isAlbum ? 'album' : 'camera'],
|
|
|
success: function (res) {
|
|
success: function (res) {
|
|
|
|
|
+ var params = {
|
|
|
|
|
+ event:'add_a_picture',
|
|
|
|
|
+ value:isAlbum?'choose_from_album_confirm':'use_camera_confirm',
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ saveFoodCache('create',params)
|
|
|
|
|
+
|
|
|
var tempFilePath = res.tempFiles[0].tempFilePath
|
|
var tempFilePath = res.tempFiles[0].tempFilePath
|
|
|
// Taro.editImage({
|
|
// Taro.editImage({
|
|
|
// src:tempFilePath,
|
|
// src:tempFilePath,
|
|
@@ -92,6 +108,14 @@ export default function Component(props: { addItem: Function, firstItem: any })
|
|
|
uploadFile(savedFilePath, isAlbum ? 'album' : 'camera')
|
|
uploadFile(savedFilePath, isAlbum ? 'album' : 'camera')
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
+ },
|
|
|
|
|
+ fail:function(res){
|
|
|
|
|
+ var params = {
|
|
|
|
|
+ event:'add_a_picture',
|
|
|
|
|
+ value:isAlbum?'choose_from_album_cancel':'use_camera_cancel',
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ saveFoodCache('create',params)
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -113,28 +137,6 @@ export default function Component(props: { addItem: Function, firstItem: any })
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function getCache(key: string) {
|
|
|
|
|
- var value = Taro.getStorageSync(key)
|
|
|
|
|
- if (value) {
|
|
|
|
|
- return JSON.parse(value)
|
|
|
|
|
- }
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function saveCache(key: string) {
|
|
|
|
|
- var strList = Taro.getStorageSync('food_operate')
|
|
|
|
|
- var list: any = []
|
|
|
|
|
- if (strList) {
|
|
|
|
|
- list = JSON.parse(strList)
|
|
|
|
|
- }
|
|
|
|
|
- list.add({
|
|
|
|
|
- key,
|
|
|
|
|
- timestamp: new Date().getTime()
|
|
|
|
|
- })
|
|
|
|
|
- Taro.setStorageSync('food_operate', JSON.stringify(list)
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
function uploadFile(path, source) {
|
|
function uploadFile(path, source) {
|
|
|
Taro.showLoading({
|
|
Taro.showLoading({
|
|
|
title: '加载中'
|
|
title: '加载中'
|
|
@@ -197,7 +199,8 @@ export default function Component(props: { addItem: Function, firstItem: any })
|
|
|
timestamp: time,
|
|
timestamp: time,
|
|
|
date: strDate
|
|
date: strDate
|
|
|
},
|
|
},
|
|
|
- mindful_mode: modeOn ? 'AWARE' : 'NORMAL'
|
|
|
|
|
|
|
+ mindful_mode: modeOn ? 'AWARE' : 'NORMAL',
|
|
|
|
|
+ // extra:getFoodCache('create')
|
|
|
|
|
|
|
|
}).then(res => {
|
|
}).then(res => {
|
|
|
props.addItem(res)
|
|
props.addItem(res)
|
|
@@ -206,6 +209,7 @@ export default function Component(props: { addItem: Function, firstItem: any })
|
|
|
Taro.removeStorageSync('pic')
|
|
Taro.removeStorageSync('pic')
|
|
|
Taro.hideLoading()
|
|
Taro.hideLoading()
|
|
|
setFirstData(res)
|
|
setFirstData(res)
|
|
|
|
|
+ clearFoodCache('create')
|
|
|
// if (modeOn) {
|
|
// if (modeOn) {
|
|
|
// setSwitchDisable(true)
|
|
// setSwitchDisable(true)
|
|
|
// }
|
|
// }
|
|
@@ -217,6 +221,19 @@ export default function Component(props: { addItem: Function, firstItem: any })
|
|
|
function modeChange(e) {
|
|
function modeChange(e) {
|
|
|
setModeOn(e.detail.value)
|
|
setModeOn(e.detail.value)
|
|
|
Taro.setStorageSync('food_switch', e.detail.value)
|
|
Taro.setStorageSync('food_switch', e.detail.value)
|
|
|
|
|
+ if (e.detail.value){
|
|
|
|
|
+ Taro.showToast({
|
|
|
|
|
+ icon:'success',
|
|
|
|
|
+ title:t('feature.food.mindful_switch_on')
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var params = {
|
|
|
|
|
+ event:'switch_toggle',
|
|
|
|
|
+ value:e.detail.value?'on':'off',
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ saveFoodCache('create',params)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function more() {
|
|
function more() {
|
|
@@ -227,6 +244,20 @@ export default function Component(props: { addItem: Function, firstItem: any })
|
|
|
jumpPage('/pages/common/H5?title=' + '' + '&url=' + resource[0].url)
|
|
jumpPage('/pages/common/H5?title=' + '' + '&url=' + resource[0].url)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function getLineBottom(){
|
|
|
|
|
+ if (user.isLogin){
|
|
|
|
|
+ return -rpxToPx(60)
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ if (modeOn){
|
|
|
|
|
+ return -rpxToPx(60)
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ return 0
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return <View style={{ marginBottom: rpxToPx(60) }}>
|
|
return <View style={{ marginBottom: rpxToPx(60) }}>
|
|
|
<View className='food_console_box'>
|
|
<View className='food_console_box'>
|
|
|
<View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
|
|
<View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
|
|
@@ -260,7 +291,7 @@ export default function Component(props: { addItem: Function, firstItem: any })
|
|
|
}
|
|
}
|
|
|
{modeOn && <Slider edit={true} />}
|
|
{modeOn && <Slider edit={true} />}
|
|
|
</View>
|
|
</View>
|
|
|
- <View className='center_line2' style={{bottom:-rpxToPx(60)}}/>
|
|
|
|
|
|
|
+ <View className='center_line2' style={{bottom:getLineBottom()}}/>
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|