123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- import { Button, Popup } from 'vant';
- import { PropType, defineComponent, onMounted, ref, watch } from 'vue';
- import styles from './index.module.less';
- import { browser } from '@/helpers/utils';
- export default defineComponent({
- name: 'm-wx-tip',
- props: {
- // 是否显示微信弹窗
- show: {
- type: Boolean,
- default: true
- },
- title: {
- type: String,
- default: '温馨提示'
- },
- message: {
- type: String,
- default: '请使用微信打开'
- },
- messageAlign: {
- type: String as PropType<'center' | 'left' | 'right'>,
- default: 'center'
- },
- /** 是否展示取消按钮 */
- showCancelButton: {
- type: Boolean,
- default: false
- },
- /** 取消按钮文案 */
- cancelButtonText: {
- type: String,
- default: '取消'
- },
- /** 取消按钮颜色 */
- cancelButtonColor: {
- type: String,
- default: ''
- },
- /** 是否展示确认按钮 */
- showConfirmButton: {
- type: Boolean,
- default: true
- },
- /** 确认按钮文案 */
- confirmButtonText: {
- type: String,
- default: '确认'
- },
- /** 确认按钮颜色 */
- confirmButtonColor: {
- type: String,
- default: ''
- },
- /** 是否有关闭按钮 */
- showCloseButton: {
- type: Boolean,
- default: true
- }
- },
- emits: ['confirm', 'cancel', 'close'],
- setup(props, { emit }) {
- const showPopup = ref(false);
- onMounted(() => {
- if (props.show) {
- showPopup.value = true;
- }
- });
- watch(
- () => [props.show, props.message],
- () => {
- if (props.show) {
- showPopup.value = true;
- } else {
- showPopup.value = false;
- }
- }
- );
- return () => (
- <>
- <Popup
- v-model:show={showPopup.value}
- round
- style={{ width: '100%', maxWidth: '520px' }}
- closeOnClickOverlay={false}
- class={styles.wxPopupDialog} closeable={false}>
- <div class={styles.popupContainer}>
- {props.showCloseButton && (
- <i class={styles.iconClose} onClick={() => emit('close')}></i>
- )}
- <p class={styles.title1} v-html={props.title}></p>
- <p
- class={styles.popupTips}
- style={{ 'text-align': props.messageAlign }}
- v-html={props.message}></p>
- {(props.showConfirmButton || props.showConfirmButton) && (
- <div class={styles.btnGroup}>
- {props.showCancelButton && (
- <Button
- round
- class={[styles.button, styles.cancelBtn]}
- color={props.cancelButtonColor}
- onClick={() => emit('cancel')}>
- {props.cancelButtonText}
- </Button>
- )}
- {props.showConfirmButton && (
- <Button
- round
- class={[styles.button, styles.confirmBtn]}
- color={props.confirmButtonColor}
- onClick={() => emit('confirm')}>
- {props.confirmButtonText}
- </Button>
- )}
- </div>
- )}
- </div>
- </Popup>
- </>
- );
- }
- });
|