LoginBox.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <div class="mobile-modal" v-show="showLogin" @touchmove="touchmove($event)">
  3. <div class="mobile-modal-box">
  4. <div class="mobile-modal-header">请登录后再操作<i @click="close" class="icon-guanbi iconfont"></i></div>
  5. <div class="mobile-modal-content">
  6. <span @click="onRegisterClick">立即注册</span><span @click="goLogin">马上登录</span>
  7. <p><i>*</i>目前手机端暂不支持开店功能,完成注册后请前往PC端操作</p>
  8. </div>
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. export default {
  14. name: 'loginBox',
  15. props: ['url'],
  16. data() {
  17. return {
  18. showLogin: false
  19. }
  20. },
  21. methods: {
  22. touchmove(e) {
  23. e.preventDefault()
  24. },
  25. close: function () {
  26. this.$emit('onLoginBoxClose')
  27. },
  28. goLogin: function () {
  29. this.$router.push('/auth/login?returnUrl=' + window.location.href)
  30. },
  31. onRegisterClick () {
  32. this.$http.get('/register/page').then(response => {
  33. if (response.data) {
  34. window.location.href = response.data.content
  35. }
  36. })
  37. }
  38. },
  39. mounted() {
  40. // document.querySelector('html').addEventListener('touchmove', function(e) {
  41. // e.preventDefault()
  42. // })
  43. document.querySelector('.mobile-modal').addEventListener('touchmove', function(e) {
  44. e.preventDefault()
  45. })
  46. let ua = window.navigator.userAgent.toLowerCase()
  47. if (ua.match(/micromessenger/i) && ua.match(/micromessenger/i)[0] === 'micromessenger') {
  48. if (this.url) {
  49. this.$router.push(`/mobile/wechat?url=${this.url}`)
  50. } else {
  51. this.$router.push(`/mobile/wechat`)
  52. }
  53. } else {
  54. // document.querySelector('html').style = 'overflow-y: hidden'
  55. // document.querySelector('body').style = 'overflow-y: hidden'
  56. this.showLogin = true
  57. }
  58. }
  59. }
  60. </script>
  61. <style lang="scss" scoped>
  62. .mobile-modal-content {
  63. padding: .54rem !important;
  64. text-align: center;
  65. span {
  66. display: inline-block;
  67. width: 1.5rem;
  68. height: .6rem;
  69. line-height: .6rem;
  70. text-align: center;
  71. background: #418df6;
  72. color: #fff;
  73. border-radius: .1rem;
  74. &:first-child {
  75. margin-right: .5rem;
  76. }
  77. }
  78. p {
  79. font-size: .28rem;
  80. color: #666;
  81. margin-top: .2rem;
  82. i {
  83. font-style: normal;
  84. color: red;
  85. margin-right: .05rem;
  86. }
  87. }
  88. }
  89. </style>