index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <div class="login-layout">
  3. <div class="mask" :style="{maxHeight: openClause ? '100%' : '0'}">
  4. <div class="user-clause" :class="{'cart-clause':cluseType==='cart'}">
  5. <div>
  6. <div class="clause-img" ref="clause">
  7. <div ref="clauseImg">
  8. <img :src="cluseType==='cart'?`${$cdn}images/cluse-long1.jpg`:`${$cdn}images/${language==='en'?'cluse-long-en':'cluse-long'}.jpg`" alt>
  9. <img v-if="cluseType!=='cart'&&language==='en'" :src="`${$cdn}images/cluse-long-en1.jpg`" alt>
  10. <img v-if="cluseType!=='cart'&&language==='en'" :src="`${$cdn}images/cluse-long-en2.jpg`" alt>
  11. </div>
  12. </div>
  13. <p>{{languagelAside.xieyi}}</p>
  14. <div class="cls-btn">
  15. <span @click="cancel">{{languagelAside.cancel}}</span>
  16. <span :class="{primary:allreadyRead}" @click="agree">{{languagelAside.comfirm}}</span>
  17. </div>
  18. </div>
  19. </div>
  20. </div>
  21. <component :is="login && notEmit ? 'cart' : 'login'" :cp="cp" :active='active'></component>
  22. </div>
  23. </template>
  24. <script>
  25. import {mapState} from 'vuex'
  26. import login from './temp/login'
  27. import cart from './temp/cart'
  28. export default {
  29. computed: {
  30. ...mapState({
  31. login: state => state.user.token,
  32. language: state => state.language.current,
  33. languagelAside: state => state.language.home.home.loginAside
  34. })
  35. },
  36. props: ['active', 'cp'],
  37. components: {
  38. login,
  39. cart
  40. },
  41. data () {
  42. return {
  43. notEmit: true,
  44. openClause: false,
  45. allreadyRead: false,
  46. cluseType: 'cart'
  47. }
  48. },
  49. watch: {
  50. openClause () {
  51. this.$refs.clause.scrollTop = 0
  52. this.allreadyRead = false
  53. }
  54. },
  55. methods: {
  56. cancel () {
  57. this.$bus.$emit('isAgree', false)
  58. this.$bus.$emit('openClause', {
  59. show: false,
  60. type: this.cluseType
  61. })
  62. this.openClause = false
  63. },
  64. agree () {
  65. if (this.allreadyRead) {
  66. this.$bus.$emit('isAgree', true)
  67. this.$bus.$emit('openClause', {
  68. show: false,
  69. type: this.cluseType
  70. })
  71. this.openClause = false
  72. }
  73. },
  74. sizeHandle: function () {
  75. let scrollHanlde = () => {
  76. let ny = this.$refs.clauseImg.offsetHeight
  77. // console.log(getPosition(this.$refs.clauseImg).y)
  78. // console.log(this.$refs.clauseImg.offsetHeight)
  79. if (this.$refs.clause.scrollTop > ny - 700) {
  80. this.allreadyRead = true
  81. }
  82. }
  83. this.$refs.clause.addEventListener('scroll', scrollHanlde)
  84. },
  85. logoutHandle () {
  86. this.$bus.$emit('hideAside')
  87. this.openClause = false
  88. }
  89. },
  90. mounted () {
  91. this.sizeHandle()
  92. this.$bus.$on('openClause', data => {
  93. this.openClause = data.show
  94. this.cluseType = data.type
  95. })
  96. this.$bus.$on('hasLogin', () => {
  97. this.notEmit = false
  98. setTimeout(() => {
  99. this.notEmit = true
  100. }, 700)
  101. })
  102. }
  103. }
  104. </script>
  105. <style lang="scss" scoped>
  106. .login-layout {
  107. $animateType: cubic-bezier(0.77, 0, 0.175, 1);
  108. .mask {
  109. transition: max-height 0.7s $animateType;
  110. max-height: 100%;
  111. position: fixed;
  112. z-index: 9999;
  113. width: 100%;
  114. height: 100%;
  115. overflow: hidden;
  116. background: rgba($color: #000000, $alpha: 0.8);
  117. .user-clause{
  118. z-index: 100000000;
  119. width: 70%;
  120. color: #fff;
  121. height: 100%;
  122. position: relative;
  123. text-align: center;
  124. margin: 0 auto;
  125. >div{
  126. height: 85%;
  127. position: absolute;
  128. transform: translate(-50%,-50%);
  129. left: 50%;
  130. top: 50%;
  131. background: #fff;
  132. padding: 0;
  133. .clause-img{
  134. height: 80%;
  135. overflow-y: auto;
  136. overflow-x: hidden;
  137. }
  138. p{
  139. margin: 25px 0;
  140. color: #2d2d2d;
  141. }
  142. .cls-btn{
  143. span{
  144. display: inline-block;
  145. background: rgb(226, 226, 226);
  146. color: #000;
  147. height: 50px;
  148. width: 215px;
  149. line-height: 50px;
  150. text-align: center;
  151. cursor: pointer;
  152. &:first-of-type{
  153. margin-right: 80px;
  154. }
  155. }
  156. .primary{
  157. background: #1fe4dc;
  158. }
  159. }
  160. }
  161. }
  162. .cart-clause{
  163. width: calc(100% - 730px);
  164. }
  165. }
  166. }
  167. @media screen and (max-width: 1500px) {
  168. .user-clause{
  169. >div{
  170. width: 100%;
  171. .clause-img{
  172. margin: 0 auto;
  173. width: 90%;
  174. img{
  175. width: 100%;
  176. }
  177. }
  178. }
  179. }
  180. }
  181. </style>