LoginBox.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <div class="mobile-modal" v-show="showLogin">
  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. this.showLogin = true
  46. }
  47. }
  48. }
  49. </script>
  50. <style lang="scss" scoped>
  51. .mobile-modal-content {
  52. padding: .54rem !important;
  53. text-align: center;
  54. span {
  55. display: inline-block;
  56. width: 1.5rem;
  57. height: .6rem;
  58. line-height: .6rem;
  59. text-align: center;
  60. background: #418df6;
  61. color: #fff;
  62. border-radius: .1rem;
  63. &:first-child {
  64. margin-right: .5rem;
  65. }
  66. }
  67. p {
  68. font-size: .28rem;
  69. color: #666;
  70. margin-top: .2rem;
  71. i {
  72. font-style: normal;
  73. color: red;
  74. margin-right: .05rem;
  75. }
  76. }
  77. }
  78. </style>