import { defineComponent } from 'vue'
import { Popup } from 'vant'
import store from 'store'
import PopContent from './popcontent'
import state from '../state'

export default defineComponent({
  name: 'DetailTips',
  data() {
    return {
      show: false,
      activeImgNo: 0,
      step: -1,
      opened: false
    }
  },
  mounted() {
    // if (!(location.hostname.indexOf('online') > -1 || location.hostname.indexOf('localhost') > -1)) {
    //   store.remove('tips-status')
    // }
    if (store.get('tips-status') !== 'showed' && state.mode === 'contact') {
      this.step = 0
      this.show = true
      this.opened = true
    }
  },
  methods: {
    close() {
      this.show = false
      this.step = -1
      store.set('tips-status', 'showed')
    }
  },
  render() {
    return (
      <Popup
        show={this.show}
        style="width: 100%;background-color: transparent;"
        onClosed={() => this.opened = false}
      >
        {this.show && this.opened ? (
          <PopContent onClose={this.close}/>
        ) : null}
      </Popup>
    )
  }
})
