123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- import { Checkbox, Icon, Popup } from "vant";
- import { defineComponent } from "vue";
- import styles from './index.module.less';
- import activeButtonIcon from '@common/images/icon_checkbox.png';
- import inactiveButtonIcon from '@common/images/icon_checkbox_default.png';
- export default defineComponent({
- name: 'protocol',
- props: {
- value: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- checked: false,
- popupStatus: false,
- protocolHTML: '',
- protocolPopup: null as any,
- }
- },
- mounted() {
- window.addEventListener('hashchange', this.onHash, false)
- },
- unmounted() {
- window.removeEventListener('hashchange', this.onHash, false)
- },
- methods: {
- onHash() {
- this.popupStatus = false;
- },
- onPopupClose() {
- // 判断是否有协议内容
- // if (!this.protocolHTML) {
- // return
- // }
- this.popupStatus = !this.popupStatus
- // 打开弹窗
- if (this.popupStatus) {
- const route = this.$route
- let times = 0;
- for (let i in route.query) {
- times += 1
- }
- const origin = window.location.href
- const url = times > 0 ? '&pto=' + (+new Date()) : '?pto=' + (+new Date())
- history.pushState("", "", `${origin}${url}`)
- } else {
- window.history.go(-1)
- }
- if (this.protocolPopup) {
- (this.protocolPopup as any).scrollTop = 0
- }
- }
- },
- render() {
- return (
- <div class={styles.colProtocol}>
- <Checkbox v-model={this.checked}
- // @ts-ignore
- vSlots={{
- icon: (props: any) => (
- <Icon class={styles.boxStyle} name={props.checked ? activeButtonIcon : inactiveButtonIcon} size="15" />
- )
- }}
- >
- 我已阅读并同意
- </Checkbox>
- <span onClick={this.onPopupClose} class={styles.protocolText}>《酷乐秀平台服务协议》</span>
- <Popup ref={this.protocolPopup} show={this.popupStatus} position="bottom" style={{ height: '100%' }}>
- <div class={styles.protocolContent}>
- <div class={styles.protocolTitle}>酷乐秀平台服务协议</div>
- <div class={styles.protocolContent}>
- 呆头呆脑的协议内容
- </div>
- </div>
- </Popup>
- </div>
- )
- }
- })
|