12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import { Icon } from 'vant'
- import { defineComponent, onMounted, ref } from 'vue'
- import styles from './index.module.less'
- import icon3 from '../../images/icon3.png'
- export default defineComponent({
- name: 'tips',
- props: {
- /** 标题 */
- title: {
- type: String,
- default: '',
- },
- /** 内容 */
- content: {
- type: String,
- default: ''
- },
- /** 类型 */
- type: {
- type: String,
- default: ''
- },
- btnTxt: {
- type: String,
- default: '不再提醒'
- }
- },
- emits: ['close', 'confirm'],
- setup(props, { emit }) {
- const isStatus = ref(true)
- console.log(props.type, '1212')
- // 获取当前提示是否有缓存
- const getTypeIsCatch = () => {
- const localType = localStorage.getItem('teacher_home_local');
- const formatLocalType = localType ? JSON.parse(localType) : {}
- console.log(formatLocalType[props.type])
- if(formatLocalType[props.type]) {
- return true
- } else {
- return false
- }
- }
- // 设置已知道
- const setTypeIsCatch = () => {
- const localType = localStorage.getItem('teacher_home_local');
- const formatLocalType = localType ? JSON.parse(localType) : {}
- formatLocalType[props.type] = 1
- localStorage.setItem('teacher_home_local', JSON.stringify(formatLocalType))
- }
- onMounted(() => {
- isStatus.value = !getTypeIsCatch()
- })
- return () => (
- isStatus.value ? <div class={styles.tipSection}>
- <Icon class={styles.iconCross} onClick={() => {
- emit('close')
- isStatus.value = false
- }} name="cross" />
- <div class={styles.tipTitle}>
- <img src={icon3} />
- {props.title}
- </div>
- <div class={styles.tipContent}>
- {props.content}
- </div>
- <div class={styles.tipFooter} onClick={() => {
- emit("confirm")
- setTypeIsCatch()
- isStatus.value = false
- }}>{props.btnTxt}</div>
- </div> : ''
- )
- }
- })
|