record_log.tsx 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. import { View, Image, PageMeta, NavigationBar, Input, Textarea, ScrollView, Snapshot, PickerView, PickerViewColumn, Text } from "@tarojs/components";
  2. import './record_log.scss'
  3. import { useEffect, useState } from "react";
  4. import Taro, { useRouter, useShareAppMessage } from "@tarojs/taro";
  5. import { rpxToPx } from "@/utils/tools";
  6. import { IconAdd, IconArrow, IconCheck, IconClose } from "@/components/basic/Icons";
  7. import { MainColorType } from "@/context/themes/color";
  8. import { useTranslation } from "react-i18next";
  9. import showAlert from "@/components/basic/Alert";
  10. import showActionSheet from "@/components/basic/ActionSheet";
  11. import { BASE_IMG_URL, baseUrl } from "@/services/http/api";
  12. import { checkAuthorized } from "@/utils/check_authorized";
  13. import NewButton, { NewButtonType } from "@/_health/base/new_button";
  14. import dayjs from "dayjs";
  15. import { TimeFormatter } from "@/utils/time_format";
  16. import { useSelector } from "react-redux";
  17. import { addEvents, addUserTag, createMoment, eventDetail, updateMoment, userTags } from "@/services/health";
  18. import PostMomentTime from "@/_health/components/post_moment_time";
  19. import ShareBtn from "@/components/basic/ShareBtn";
  20. import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
  21. import ChooseActions from "@/pages/clock/components/choose_actions";
  22. import FollowInfo from "@/_moment/components/follow_info";
  23. import NewDateTimePicker from "@/_health/base/new_date_time_picker";
  24. import { IconCamera, IconClock } from "@/_record/components/record_icon";
  25. import PickerCard from "@/_record/components/picker_card";
  26. let useRoute;
  27. let useNavigation;
  28. let LinearGradient;
  29. if (process.env.TARO_ENV == 'rn') {
  30. useRoute = require("@react-navigation/native").useRoute
  31. useNavigation = require("@react-navigation/native").useNavigation
  32. LinearGradient = require('react-native-linear-gradient').default
  33. }
  34. let useActionSheet;
  35. if (process.env.TARO_ENV == 'rn') {
  36. useActionSheet = require('@expo/react-native-action-sheet').useActionSheet
  37. }
  38. export default function RecordLog(props: {
  39. scenario,
  40. showPublish: any,
  41. contentHeight: number, imgs?: any, only_text?: any, quick?: any, join_id?: any,
  42. id?: any,
  43. edit?: any,
  44. check_in?: any
  45. }) {
  46. const systemInfo: any = Taro.getWindowInfo ? Taro.getWindowInfo() : Taro.getSystemInfoSync();
  47. const navigationBarHeight = systemInfo.statusBarHeight + 44;
  48. const screenHeight = systemInfo.screenHeight
  49. const scale = '?x-oss-process=image/format,jpg/resize,w_400'
  50. const long = useSelector((state: any) => state.long);
  51. const health = useSelector((state: any) => state.health);
  52. const record = useSelector((state: any) => state.record);
  53. const user = useSelector((state: any) => state.user);
  54. const [title, setTitle] = useState('')
  55. const [chooseTitle, setChooseTitle] = useState('')
  56. const [desc, setDesc] = useState('')
  57. const [step, setStep] = useState(0)
  58. const { t } = useTranslation()
  59. const [time, setTime] = useState(dayjs().format('HH:mm'))
  60. const [selDate, setSelDate] = useState(dayjs().format('YYYY-MM-DD'))
  61. const [enterTimestmap] = useState(new Date().getTime())
  62. const [posting, setPosting] = useState(false)
  63. const [showTimePicker, setShowTimePicker] = useState(false)
  64. const [result, setResult] = useState<any>(null)
  65. const [showResult, setShowResult] = useState(false)
  66. const [tags, setTags] = useState<any>([])
  67. const [selPostCount, setPostCount] = useState(1)
  68. const [showChoose, setShowChoose] = useState(false)
  69. const [selTag, setSelTag] = useState<any>(null)
  70. const [loading, setLoading] = useState(false)
  71. let showActionSheetWithOptions;
  72. if (process.env.TARO_ENV == 'rn') {
  73. showActionSheetWithOptions = useActionSheet()
  74. }
  75. let router
  76. let navigation;
  77. if (useNavigation) {
  78. navigation = useNavigation()
  79. }
  80. if (process.env.TARO_ENV == 'rn') {
  81. router = useRoute()
  82. }
  83. else {
  84. router = useRouter()
  85. }
  86. const { scenario, imgs, only_text, quick, join_id } = props
  87. const [pics, setPics] = useState<any>(imgs ? JSON.parse(imgs) : [])
  88. const [focus, setFocus] = useState(only_text ? true : false)
  89. const [inputFocus, setInputFocus] = useState(false)
  90. if (process.env.TARO_ENV == 'weapp') {
  91. useShareAppMessage((e) => {
  92. var path;
  93. if (result && result.event_id) {
  94. var sharePath = `/_health/pages/timeline_detail?type=recent&fast_type=IF&event_id=${result.event_id}&uid=${user.id}&isfastsleep=${0}&disable_edit=1&enter_type=share`
  95. if (user.isLogin) {
  96. sharePath += `&share_uid=${user.id}`
  97. }
  98. path = sharePath
  99. }
  100. else {
  101. path = 'pages/clock/Clock'
  102. }
  103. return {
  104. title: '分享标题',
  105. path: path,
  106. // imageUrl: shareUrl
  107. }
  108. })
  109. }
  110. useEffect(() => {
  111. global.set_time = new Date().getTime()
  112. getTags()
  113. if (props.check_in == 1) {
  114. setStep(0)
  115. }
  116. // if (router.params.quick) {
  117. // quickSave()
  118. // }
  119. if (props.edit) {
  120. eventDetail(props.id).then(res => {
  121. setTitle((res as any).title)
  122. setChooseTitle((res as any).title)
  123. if ((res as any).moment) {
  124. setDesc((res as any).moment.description)
  125. if ((res as any).moment.media && (res as any).moment.media.length > 0) {
  126. setPics((res as any).moment.media)
  127. }
  128. }
  129. if ((res as any).time) {
  130. setSelDate(dayjs((res as any).time.start_timestamp).format('YYYY-MM-DD'))
  131. setTime(dayjs((res as any).time.start_timestamp).format('HH:mm'))
  132. }
  133. })
  134. }
  135. }, [])
  136. useEffect(() => {
  137. if (step == 1) {
  138. setTimeout(() => {
  139. setInputFocus(true)
  140. }, 300)
  141. }
  142. }, [step])
  143. function getTags() {
  144. userTags({ scenario: scenario }).then(res => {
  145. if (chooseTitle == '' && !props.edit) {
  146. var current = dayjs().format('HH:mm');
  147. var isFind = false;
  148. (res as any).tags.map(item => {
  149. if (item.time_from && item.time_to) {
  150. if (isInTimeRange(current, item.time_from, item.time_to)) {
  151. isFind = true;
  152. setTitle(item.title)
  153. setChooseTitle(item.title)
  154. setPostCount(item.log_count + 1)
  155. }
  156. }
  157. })
  158. if (!isFind) {
  159. setTitle((res as any).tags[0].title)
  160. setChooseTitle((res as any).tags[0].title)
  161. setPostCount((res as any).tags[0].log_count + 1)
  162. }
  163. }
  164. setTags((res as any).tags)
  165. })
  166. }
  167. function isInTimeRange(currentTime, startTime, endTime) {
  168. // 将时间字符串转换为 Date 对象
  169. const current = new Date(`1970-01-01T${currentTime}:00`);
  170. const start = new Date(`1970-01-01T${startTime}:00`);
  171. const end = new Date(`1970-01-01T${endTime}:00`);
  172. // 如果结束时间小于开始时间,说明时间段跨越了午夜
  173. if (end < start) {
  174. end.setDate(end.getDate() + 1); // 将结束时间加一天
  175. if (current < start) {
  176. current.setDate(current.getDate() + 1); // 如果当前时间在午夜之前,加一天
  177. }
  178. }
  179. // 判断当前时间是否在时间段内
  180. return current >= start && current < end;
  181. }
  182. function addTag() {
  183. addUserTag({ scenario: scenario, title: title }).then(res => {
  184. getTags()
  185. })
  186. }
  187. function tapPic() {
  188. //, t('health.delete')
  189. var list = process.env.TARO_ENV == 'weapp' ? [t('health.add_photos'), t('health.camera2'), t('health.import_chat')] :
  190. [t('health.add_photos'), t('health.camera2')]
  191. showActionSheet({
  192. title: '',
  193. showActionSheetWithOptions: showActionSheetWithOptions,
  194. itemList: list,
  195. success: function (res) {
  196. switch (res) {
  197. case 0:
  198. addImage(false)
  199. break;
  200. case 1:
  201. addImage(true)
  202. break;
  203. case 2:
  204. Taro.chooseMessageFile({
  205. count: 9 - pics.length,
  206. type: 'image',
  207. success: async function (res) {
  208. const results = await Promise.all(res.tempFiles.map(getImageInfo));
  209. chooseSuccess(results, true)
  210. },
  211. fail(res) {
  212. },
  213. })
  214. break;
  215. case 3:
  216. // setImgUrl('')
  217. break;
  218. }
  219. }
  220. })
  221. }
  222. function addImage(isCamera) {
  223. var source: any = isCamera ? ['camera'] : ['album']
  224. Taro.chooseImage({
  225. count: 9 - pics.length,
  226. sizeType: ['compressed'],
  227. // mediaType: ['image'],
  228. sourceType: source,
  229. success: async function (res) {
  230. const results = await Promise.all(res.tempFiles.map(getImageInfo));
  231. chooseSuccess(results, true)
  232. // checkAuthorized()
  233. },
  234. fail: function (res) {
  235. }
  236. })
  237. }
  238. async function chooseSuccess(res, isAlbum) {
  239. // const filePaths = res.map(file => file.path
  240. // // process.env.TARO_ENV === 'rn' || isFilePath ? file.path : file.tempFilePath
  241. // )
  242. Taro.showLoading({
  243. title: t('health.uploading')
  244. })
  245. try {
  246. const uploadedUrls = await Promise.all(res.map(path => uploadFile2(path, isAlbum ? 'album' : 'camera')))
  247. setPics([...pics, ...uploadedUrls])
  248. Taro.hideLoading()
  249. } catch (error) {
  250. console.error('Error uploading files:', error)
  251. Taro.hideLoading()
  252. }
  253. }
  254. function uploadFile2(obj: any, source: string): Promise<string> {
  255. return new Promise((resolve, reject) => {
  256. var path = obj.path
  257. const dot = path.lastIndexOf('.')
  258. const fileExt = dot > 0 ? path.substring(dot) : ''
  259. Taro.request({
  260. method: 'GET',
  261. timeout: 30000,
  262. url: `${baseUrl}/api/thirdparty/aliyun/oss-form-upload`,
  263. header: {
  264. 'Authorization': 'bearer ' + global.token
  265. },
  266. data: {
  267. type: 'FOOD_JOURNAL',
  268. file_ext: fileExt
  269. },
  270. success: (rsp) => {
  271. if (rsp.statusCode !== 200) {
  272. reject(new Error(t('health.networkError')))
  273. return
  274. }
  275. Taro.uploadFile({
  276. timeout: 30000,
  277. url: rsp.data.upload_url,
  278. filePath: path,
  279. name: 'file',
  280. formData: rsp.data.fields,
  281. success: () => {
  282. var temp = JSON.parse(JSON.stringify(obj))
  283. temp.url = rsp.data.view_url
  284. // resolve(rsp.data.view_url)
  285. resolve(temp)
  286. },
  287. fail: (error) => {
  288. reject(error)
  289. }
  290. })
  291. },
  292. fail: reject
  293. })
  294. })
  295. }
  296. const getImageInfo = (src) => {
  297. const { tempFilePath, path } = src
  298. return new Promise((resolve) => {
  299. Taro.getImageInfo({
  300. src: tempFilePath ? tempFilePath : path,
  301. success: (result) => resolve({
  302. height: result.height,
  303. width: result.width,
  304. orientation: result.orientation,
  305. path: result.path,
  306. type: result.type
  307. }),
  308. fail: (error) => resolve({
  309. height: 1024,
  310. width: 1024,
  311. orientation: 'up',
  312. path: tempFilePath,
  313. type: 'unknown'
  314. }),
  315. });
  316. });
  317. };
  318. function quickSave() {
  319. }
  320. function save() {
  321. if (props.edit) {
  322. edit()
  323. return
  324. }
  325. var date = TimeFormatter.stringToDate(selDate, time)
  326. date.setMilliseconds(new Date(enterTimestmap).getMilliseconds())
  327. var params: any = {
  328. scenario: scenario, //ACTIVITY
  329. type: 'POINT',
  330. sub_type: scenario,
  331. title: chooseTitle,
  332. time: {
  333. start_timestamp: date.getTime()
  334. }
  335. }
  336. if (join_id) {
  337. params.join_key = join_id
  338. }
  339. var moment: any = {
  340. description: desc,
  341. }
  342. if (pics.length > 0) {
  343. var picList: any = []
  344. pics.map((item) => {
  345. picList.push({
  346. url: item.url,
  347. type: item.url.indexOf('mp4') != -1 ? 'video' : 'image',
  348. source: 'album',
  349. width: item.width,
  350. height: item.height,
  351. format: item.format
  352. })
  353. })
  354. moment.media = picList
  355. }
  356. params.moment = moment
  357. // if (event_id && event_id != 'undefined') {
  358. // params.event_id = event_id
  359. // }
  360. // if (is_temp) {
  361. // params.event = window == 'EAT' ? 'EAT_CUSTOM' : 'ACTIVE_CUSTOM'
  362. // }
  363. // params.op_page = window == 'EAT' ? 'HOME_EAT' : 'HOME_ACTIVE'
  364. params.extra = {
  365. set_time: global.set_time ? global.set_time : new Date().getTime(),
  366. confirm_time: new Date().getTime()
  367. }
  368. if (posting) return
  369. setPosting(true)
  370. // Taro.showLoading({
  371. // title: t('health.uploading')
  372. // })
  373. addEvents(params).then(res => {
  374. setShowResult(true)
  375. setResult(res)
  376. setPosting(false)
  377. // Taro.hideLoading()
  378. Taro.reLaunch({
  379. url: '/pages/moment/moment'
  380. })
  381. }).catch(e => {
  382. setPosting(false)
  383. // Taro.hideLoading()
  384. })
  385. // createMoment(params).then(res => {
  386. // // setTimeout(() => {
  387. // setPosting(false)
  388. // Taro.eventCenter.trigger('refreshMoments', '')
  389. // // }, 1000)
  390. // if (process.env.TARO_ENV == 'weapp') {
  391. // // Taro.navigateBack();
  392. // Taro.redirectTo({
  393. // url: '/_health/pages/post_result?data=' + JSON.stringify(res)
  394. // })
  395. // // Taro.navigateTo({
  396. // // url:'/_health/pages/post_result?data=' + JSON.stringify(res)
  397. // // })
  398. // }
  399. // // global.refreshWindow()
  400. // // global.refreshHistory()
  401. // // if (global.postMomentSuccess) {
  402. // // global.postMomentSuccess()
  403. // // }
  404. // }).catch(e => {
  405. // setPosting(false)
  406. // })
  407. }
  408. function edit() {
  409. var date = TimeFormatter.stringToDate(selDate, time)
  410. date.setMilliseconds(new Date(enterTimestmap).getMilliseconds())
  411. var params: any = {
  412. id: router.params.id,
  413. scenario: scenario, //ACTIVITY
  414. type: 'POINT',
  415. sub_type: scenario,
  416. title: chooseTitle,
  417. time: {
  418. start_timestamp: date.getTime()
  419. }
  420. }
  421. if (join_id) {
  422. params.join_key = join_id
  423. }
  424. var moment: any = {
  425. description: desc,
  426. }
  427. if (pics.length > 0) {
  428. var picList: any = []
  429. pics.map((item) => {
  430. picList.push({
  431. url: item.url,
  432. type: item.url.indexOf('mp4') != -1 ? 'video' : 'image',
  433. source: 'album',
  434. width: item.width,
  435. height: item.height,
  436. format: item.format
  437. })
  438. })
  439. moment.media = picList
  440. }
  441. else {
  442. moment.media = []
  443. }
  444. params.moment = moment
  445. params.extra = {
  446. set_time: global.set_time ? global.set_time : new Date().getTime(),
  447. confirm_time: new Date().getTime()
  448. }
  449. if (posting) return
  450. setPosting(true)
  451. // Taro.showLoading({
  452. // title: t('health.uploading')
  453. // })
  454. addEvents(params).then(res => {
  455. setShowResult(true)
  456. setResult(res)
  457. setPosting(false)
  458. Taro.eventCenter.trigger('refresh_timeline', (res as any).feed_item)
  459. if (global.refreshHistory) {
  460. global.refreshHistory()
  461. }
  462. process.env.TARO_ENV == 'weapp' ? Taro.navigateBack() : navigation.goBack()
  463. // Taro.hideLoading()
  464. // Taro.reLaunch({
  465. // url: '/pages/moment/moment'
  466. // })
  467. }).catch(e => {
  468. setPosting(false)
  469. // Taro.hideLoading()
  470. })
  471. }
  472. function getDate() {
  473. var sel = dayjs(selDate)
  474. var now = dayjs().format('YYYY-MM-DD')
  475. const yesterday = dayjs().subtract(1, 'day');
  476. if (sel.format('YYYY-MM-DD') == now) {
  477. return ''
  478. }
  479. if (yesterday.format('YYYY-MM-DD') == sel.format('YYYY-MM-DD')) {
  480. return global.language == 'en' ? 'Yesterday ' : '昨天 '
  481. }
  482. else {
  483. return global.language == 'en' ? sel.format('MMM D ') : sel.format('MMMD日 ')
  484. }
  485. }
  486. function getBackground() {
  487. var time = record.time
  488. if (!time) return '#fff'
  489. const { background_colors } = time
  490. if (!background_colors) {
  491. return '#fff'
  492. }
  493. else if (background_colors.length == 1) {
  494. return background_colors[0]
  495. }
  496. return `linear-gradient(to bottom, ${background_colors[0]}, ${background_colors[1]})`
  497. }
  498. if (quick) {
  499. // return <QuickLog tag={chooseTitle} scenario={scenario} updateTag={() => {
  500. // }} />
  501. }
  502. return <ScrollView style={{ position: 'relative', zIndex: 1000, height: props.contentHeight }} scrollY>
  503. <View style={{ position: 'relative', overflow: showChoose ? 'hidden' : 'visible' }}>
  504. {
  505. step == 0 && <View className="operate_bg">
  506. {
  507. tags.map((item, index) => {
  508. return <NewButton key={index} type={NewButtonType.custom}
  509. onClick={() => {
  510. // setChooseTitle(item.title)
  511. // setPostCount(item.log_count + 1)
  512. // setStep(2)
  513. // setSelTag(item)
  514. props.showPublish()
  515. }}>
  516. <View key={index} className="operate_item h34"
  517. style={{ backgroundColor: MainColorType.white_25 }}
  518. >
  519. <View className="first_letter h36">{item.title.substring(0, 1).toUpperCase()}</View>
  520. {item.title}
  521. <View style={{ flex: 1 }} />
  522. <IconAdd color={MainColorType.g02} width={rpxToPx(36)} />
  523. </View>
  524. </NewButton>
  525. })
  526. }
  527. <View className="operate_item h34"
  528. style={{ backgroundColor: MainColorType.white_25, marginBottom: rpxToPx(100) }}
  529. onClick={() => {
  530. setTitle('')
  531. setChooseTitle('')
  532. setPostCount(1)
  533. setStep(1)
  534. }}><View className="first_letter h36">
  535. <Image src={BASE_IMG_URL + 'edit.svg'} style={{ width: rpxToPx(36), height: rpxToPx(36) }} />
  536. </View>{t('health.custom')}</View>
  537. </View>
  538. }
  539. {
  540. step == 1 && <View className="cardShowAni" style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', marginTop: rpxToPx(300) }}>
  541. <View className="input_form">
  542. <Input className="input_content h36" placeholder={t('health.custom_name')} value={title}
  543. placeholderClass="input_content_placeholder"
  544. focus={inputFocus}
  545. autoFocus={inputFocus}
  546. maxlength={30}
  547. onBlur={() => {
  548. setInputFocus(false)
  549. }}
  550. onInput={(e: any) => {
  551. setTitle(e.target.value)
  552. setChooseTitle(e.target.value)
  553. }} />
  554. <View className="form_btns">
  555. <View className="form_cancel">
  556. <NewButton btnStyle={{ flex: 1 }} type={NewButtonType.img}
  557. onClick={() => {
  558. setStep(0)
  559. }}
  560. >
  561. <View className="h30 bold">{t('health.cancel')}</View>
  562. </NewButton>
  563. </View>
  564. <View className="form_cancel">
  565. <NewButton btnStyle={{ flex: 1 }} type={NewButtonType.img}
  566. onClick={() => {
  567. if (title.length == 0) return
  568. setChooseTitle(title)
  569. setPostCount(1)
  570. setStep(2)
  571. addTag()
  572. }}
  573. >
  574. <View className={title.length == 0 ? 'form_cancel form_confirm h30 bold' : 'form_cancel h30 bold'}
  575. >{t('health.confirm')}</View>
  576. </NewButton>
  577. </View>
  578. </View>
  579. </View>
  580. </View>
  581. }
  582. {
  583. step == 2 && <View className="cardShowAni" style={{ paddingTop: rpxToPx(26) }}>
  584. <View className="content_card">
  585. <View style={{ display: 'flex', flexDirection: 'row' }} >
  586. <NewButton type={NewButtonType.custom}
  587. onClick={() => {
  588. setStep(0)
  589. setFocus(false)
  590. }}>
  591. <View className="sel_tag">
  592. <View className="h34 bold">{chooseTitle}</View>
  593. <View style={{ width: rpxToPx(6) }} />
  594. <IconArrow width={rpxToPx(34)} color='#000' />
  595. </View>
  596. </NewButton>
  597. </View>
  598. <Textarea placeholder={t('health.add_text')} className="textarea2 h44"
  599. placeholder-style="color:rgba(0,0,0,0.2)"
  600. value={desc}
  601. focus={focus}
  602. onBlur={() => {
  603. setFocus(false)
  604. }}
  605. onInput={e => {
  606. setDesc(e.detail.value)
  607. }} />
  608. <View className="form2">
  609. {
  610. pics.map((item, index) => {
  611. return <View className="cover1" key={index}>
  612. <Image src={item.url + scale} mode="aspectFill" className="cover2" key={index} onClick={() => {
  613. Taro.previewImage({
  614. current: pics[index].url,
  615. urls: pics.map(file => file.url)
  616. })
  617. }} />
  618. <View className="cover_del" onClick={() => {
  619. showAlert({
  620. title: t('health.del_title'),
  621. content: '',
  622. cancelText: t('health.del_cancel'),
  623. confirmText: t('health.del_confirm'),
  624. showCancel: true,
  625. confirm: () => {
  626. var array = JSON.parse(JSON.stringify(pics))
  627. array.splice(index, 1)
  628. setPics(array)
  629. }
  630. })
  631. }}>
  632. <View className="cover_del_btn">
  633. <IconClose width={10} height={10} color="#fff" />
  634. </View>
  635. </View>
  636. </View>
  637. })
  638. }
  639. {
  640. pics.length < 9 && <NewButton
  641. type={NewButtonType.custom}
  642. onClick={tapPic}>
  643. <View className="cover1" style={{}}><IconCamera color="#000" width={rpxToPx(48)} /></View>
  644. </NewButton>
  645. }
  646. </View>
  647. </View>
  648. <View className="time_view" onClick={() => {
  649. setShowTimePicker(true)
  650. }}>
  651. <IconClock width={rpxToPx(36)} color={MainColorType.black_25} />
  652. <View className="h30" style={{ opacity: 0.25, marginLeft: rpxToPx(12) }}>{t('health.time')}</View>
  653. <View style={{ flex: 1 }} />
  654. <View className="h30" style={{ opacity: 0.25 }}>{getDate() + time}</View>
  655. <IconArrow width={rpxToPx(34)} color={MainColorType.black_25} />
  656. <View className="border_footer_line" style={{ left: rpxToPx(48) }} />
  657. </View>
  658. {
  659. join_id && <FollowInfo user={long.follow} />
  660. }
  661. <View style={{ width: 300 }}>
  662. </View>
  663. </View>
  664. }
  665. {
  666. step == 2 && <View className="main_footer" style={{ backgroundColor: 'transparent' }}>
  667. <NewButton
  668. type={NewButtonType.fill}
  669. color={MainColorType.orange}
  670. width={rpxToPx(646)}
  671. height={rpxToPx(108)}
  672. title={t('health.share_to_moment')}
  673. onClick={save}
  674. />
  675. </View>
  676. }
  677. {
  678. showTimePicker && <PickerCard onClose={() => { setShowTimePicker(false) }}
  679. value={new Date(selDate + 'T' + time + ':00').getTime()}
  680. title={global.language == 'en' ? 'Choose Time' : "选择时间"}
  681. type="datetime"
  682. onConfirm={(e) => {
  683. setSelDate(dayjs(e).format('YYYY-MM-DD'))
  684. setTime(dayjs(e).format('HH:mm'))
  685. setShowTimePicker(false)
  686. }}
  687. />
  688. }
  689. </View >
  690. </ScrollView>
  691. }