index.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { Checkbox, Icon, Popup } from "vant";
  2. import { defineComponent } from "vue";
  3. import styles from './index.module.less';
  4. import activeButtonIcon from '@common/images/icon_checkbox.png';
  5. import inactiveButtonIcon from '@common/images/icon_checkbox_default.png';
  6. export default defineComponent({
  7. name: 'protocol',
  8. props: {
  9. value: {
  10. type: Boolean,
  11. default: false
  12. }
  13. },
  14. data() {
  15. return {
  16. checked: false,
  17. popupStatus: false,
  18. protocolHTML: '',
  19. protocolPopup: null as any,
  20. }
  21. },
  22. mounted() {
  23. window.addEventListener('hashchange', this.onHash, false)
  24. },
  25. unmounted() {
  26. window.removeEventListener('hashchange', this.onHash, false)
  27. },
  28. methods: {
  29. onHash() {
  30. this.popupStatus = false;
  31. },
  32. onPopupClose() {
  33. // 判断是否有协议内容
  34. // if (!this.protocolHTML) {
  35. // return
  36. // }
  37. this.popupStatus = !this.popupStatus
  38. // 打开弹窗
  39. if (this.popupStatus) {
  40. const route = this.$route
  41. let times = 0;
  42. for (let i in route.query) {
  43. times += 1
  44. }
  45. const origin = window.location.href
  46. const url = times > 0 ? '&pto=' + (+new Date()) : '?pto=' + (+new Date())
  47. history.pushState("", "", `${origin}${url}`)
  48. } else {
  49. window.history.go(-1)
  50. }
  51. if (this.protocolPopup) {
  52. (this.protocolPopup as any).scrollTop = 0
  53. }
  54. }
  55. },
  56. render() {
  57. return (
  58. <div class={styles.colProtocol}>
  59. <Checkbox v-model={this.checked}
  60. // @ts-ignore
  61. vSlots={{
  62. icon: (props: any) => (
  63. <Icon class={styles.boxStyle} name={props.checked ? activeButtonIcon : inactiveButtonIcon} size="15" />
  64. )
  65. }}
  66. >
  67. 我已阅读并同意
  68. </Checkbox>
  69. <span onClick={this.onPopupClose} class={styles.protocolText}>《酷乐秀平台服务协议》</span>
  70. <Popup ref={this.protocolPopup} show={this.popupStatus} position="bottom" style={{ height: '100%' }}>
  71. <div class={styles.protocolContent}>
  72. <div class={styles.protocolTitle}>酷乐秀平台服务协议</div>
  73. <div class={styles.protocolContent}>
  74. 呆头呆脑的协议内容
  75. </div>
  76. </div>
  77. </Popup>
  78. </div>
  79. )
  80. }
  81. })