| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import { View, Text } from "@tarojs/components";
- import React from "react";
- import './RecordItem.scss'
- import Taro from "@tarojs/taro";
- import { TimeFormatter } from "@/utils/time_format";
- import { useTranslation } from "react-i18next";
- import { vibrate } from "@/utils/tools";
- export default function Component(props: { children: React.ReactNode, onClick?: Function, delete?: Function, canDel?: boolean }) {
- const { t } = useTranslation()
- function click(e) {
- if (props.onClick) {
- if (process.env.TARO_ENV == 'weapp') {
- e.stopPropagation()
- }
- props.onClick();
- }
- else {
- vibrate()
- }
- }
- function longPress() {
- if (!props.delete) {
- return;
- }
- Taro.showActionSheet({
- itemList: [t('feature.common.action_sheet.delete')],
- })
- .then(res => {
- switch (res.tapIndex) {
- case 0:
- Taro.showModal({
- title: t('feature.common.modal.delete_item_title'),
- content: t('feature.common.modal.delete_item_content'),
- success: function (res) {
- if (res.confirm) {
- props.delete!();
- }
- }
- })
- break;
- case 1:
- break;
- }
- })
- .catch(err => {
- console.log(err.errMsg)
- })
- }
- //gesture onClick onLongPress 有效
- return <View className="recordItem" onLongPress={longPress} onClick={click}>
- {props.children}
- </View>
- }
|