LoginBox.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div class="mobile-modal" v-show="showLogin" @touchmove="preventTouchMove($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. close: function () {
  23. this.$emit('onLoginBoxClose')
  24. },
  25. goLogin: function () {
  26. this.$router.push('/auth/login?returnUrl=' + window.location.href)
  27. },
  28. onRegisterClick () {
  29. this.$http.get('/register/page').then(response => {
  30. if (response.data) {
  31. window.location.href = response.data.content
  32. }
  33. })
  34. }
  35. },
  36. mounted() {
  37. let ua = window.navigator.userAgent.toLowerCase()
  38. if (ua.match(/micromessenger/i) && ua.match(/micromessenger/i)[0] === 'micromessenger') {
  39. if (this.url) {
  40. this.$router.push(`/mobile/wechat?url=${this.url}`)
  41. } else {
  42. this.$router.push(`/mobile/wechat`)
  43. }
  44. } else {
  45. // document.querySelector('html').style = 'overflow-y: hidden'
  46. // document.querySelector('body').style = 'overflow-y: hidden'
  47. this.showLogin = true
  48. }
  49. }
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. .mobile-modal-content {
  54. padding: .54rem !important;
  55. text-align: center;
  56. span {
  57. display: inline-block;
  58. width: 1.5rem;
  59. height: .6rem;
  60. line-height: .6rem;
  61. text-align: center;
  62. background: #418df6;
  63. color: #fff;
  64. border-radius: .1rem;
  65. &:first-child {
  66. margin-right: .5rem;
  67. }
  68. }
  69. p {
  70. font-size: .28rem;
  71. color: #666;
  72. margin-top: .2rem;
  73. i {
  74. font-style: normal;
  75. color: red;
  76. margin-right: .05rem;
  77. }
  78. }
  79. }
  80. </style>