You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
3.4 KiB
TypeScript
140 lines
3.4 KiB
TypeScript
import classnames from "classnames";
|
|
import { Component } from "react";
|
|
|
|
import { Block, View, Button, PageMeta } from "@tarojs/components";
|
|
|
|
import { Popup } from "@antmjs/vantui";
|
|
|
|
import "./popup.less";
|
|
|
|
/*** props
|
|
* isLarge 是否大尺寸
|
|
* isShow 是否显示
|
|
* isClose 右上角关闭图标
|
|
* title 弹窗标题
|
|
* content 弹窗内容
|
|
* cancelButtonText 取消按钮
|
|
* confirmButtonText 确定按钮
|
|
* textAlgin 文本对齐 left right center
|
|
* @close 关闭回调
|
|
* @confirm 确定回调
|
|
* ***/
|
|
export default class PopupConfirm extends Component<any, any> {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
name: "确认组件",
|
|
// isShowconfirmPopup: true,
|
|
};
|
|
}
|
|
|
|
async onLoad() {}
|
|
componentDidMount() {}
|
|
|
|
componentWillUnmount() {}
|
|
|
|
componentDidShow() {
|
|
// 是否已授权隐私
|
|
// if (Taro.getStorageSync("isconfirmPopup") !== "true") {
|
|
// // this.setState({
|
|
// // showconfirmPopup: true,
|
|
// // });
|
|
// this.props.closeconfirm();
|
|
// }
|
|
}
|
|
|
|
componentDidHide() {}
|
|
|
|
async initData() {}
|
|
// 关闭
|
|
onClose = () => {
|
|
this.props.close();
|
|
};
|
|
// 取消
|
|
onCancel = () => {
|
|
// 旧代码共用了取消和关闭回调,临时适配兼容:有取消用取消,没取消用关闭
|
|
if (this.props.cancel) {
|
|
this.props.cancel();
|
|
} else {
|
|
this.onClose();
|
|
}
|
|
};
|
|
// 确认
|
|
onConfirm = () => {
|
|
this.props.confirm();
|
|
};
|
|
|
|
onClickStop = (e) => {
|
|
e.stopPropagation();
|
|
};
|
|
|
|
render() {
|
|
let {
|
|
title,
|
|
content,
|
|
cancelButtonText,
|
|
confirmButtonText,
|
|
textAlgin,
|
|
isShow,
|
|
isClose,
|
|
isLarge,
|
|
} = this.props;
|
|
return (
|
|
<Block>
|
|
<PageMeta pageStyle={isShow ? "overflow: hidden;" : ""} />
|
|
<Popup
|
|
show={isShow}
|
|
closeOnClickOverlay={false}
|
|
round
|
|
overlayStyle="width: 100vw;padding: 0;"
|
|
// onClose={this.onClose}
|
|
onClick={this.onClickStop}
|
|
>
|
|
{isClose && (
|
|
<View
|
|
className="at-icon at-icon-close common-close"
|
|
onClick={this.onClose}
|
|
></View>
|
|
)}
|
|
|
|
<View
|
|
className={classnames("common-box", {
|
|
"common-large": isLarge,
|
|
})}
|
|
catchMove
|
|
>
|
|
{title && (
|
|
<View
|
|
className={classnames("common-popup-title", {
|
|
"margin-samll": isLarge,
|
|
})}
|
|
>
|
|
{title}
|
|
</View>
|
|
)}
|
|
<View className="common-popup-content-box">
|
|
<View
|
|
className={classnames("common-popup-content", {
|
|
"text-left": textAlgin === "left",
|
|
"text-right": textAlgin === "right",
|
|
"text-center": textAlgin === "center",
|
|
})}
|
|
>
|
|
{content}
|
|
</View>
|
|
</View>
|
|
<View className="common-popup-btns">
|
|
<Button className="common-popup-btn2" onClick={this.onCancel}>
|
|
{cancelButtonText}
|
|
</Button>
|
|
<Button className="common-popup-btn2" onClick={this.onConfirm}>
|
|
{confirmButtonText}
|
|
</Button>
|
|
</View>
|
|
</View>
|
|
</Popup>
|
|
</Block>
|
|
);
|
|
}
|
|
}
|