log_record.tsx 35 KB

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