authorize.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view>
  3. <view class='popup-box' v-if="value">
  4. <view class='title'>申请授权</view>
  5. <!-- #ifdef H5 || APP-PLUS -->
  6. <view class='tip' v-if="platformAgent != null && platformAgent.isWechat">获得你的公开信息(昵称、头像等),以便为您提供更好的服务</view>
  7. <view class='tip' v-if="platformAgent != null && !platformAgent.isWechat">您还没有登录,请登录后在继续操作。</view>
  8. <!-- #endif -->
  9. <!-- #ifdef MP -->
  10. <view class='tip'>获得你的公开信息(昵称、头像等),以便为您提供更好的服务</view>
  11. <!-- #endif -->
  12. <view class='bottom flex'>
  13. <view class='item' @click="close">随便逛逛</view>
  14. <!-- #ifdef H5 || APP-PLUS -->
  15. <button class='item grant' v-if="platformAgent != null && platformAgent.isWechat" type="primary" @click="login">去授权</button>
  16. <button class='item grant' v-if="platformAgent != null && !platformAgent.isWechat" type="primary" @click="login">去登录</button>
  17. <!-- #endif -->
  18. <!-- #ifdef MP -->
  19. <button class='item grant' type="primary" @click="login">去授权</button>
  20. <!-- #endif -->
  21. </view>
  22. </view>
  23. <view class='mask' v-if="value" @click="close"></view>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. props: {
  29. value: {
  30. type: [Boolean],
  31. default: true
  32. },
  33. isGoHome: {
  34. type: [Boolean],
  35. default: false
  36. },
  37. isBack: {
  38. type: [Boolean],
  39. default: false
  40. }
  41. },
  42. data(){
  43. return {
  44. platformAgent: null
  45. };
  46. },
  47. mounted() {
  48. this.platformAgent = this.$utils.platformAgent();
  49. },
  50. methods: {
  51. login(){
  52. uni.navigateTo({
  53. url: "/pages/public/login"
  54. })
  55. },
  56. close(){
  57. this.$emit("input",!this.value);
  58. if(this.isGoHome){
  59. uni.switchTab({ url: "/pages/index/index" })
  60. }else{
  61. if(!this.isBack){
  62. return ;
  63. }
  64. let pages = getCurrentPages();
  65. let currPage = pages[pages.length - 1];
  66. if(currPage.route == "pages/ucenter/index"){
  67. return ;
  68. }
  69. if(pages.length <= 1){
  70. uni.switchTab({ url: "/pages/index/index" });
  71. return ;
  72. }
  73. uni.navigateBack();
  74. }
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss">
  80. .popup-box{
  81. width:500rpx;
  82. background-color:#fff;
  83. position:fixed;
  84. top:50%;
  85. left:50%;
  86. margin-left:-250rpx;
  87. transform:translateY(-50%);
  88. z-index:311220;
  89. }
  90. .popup-box .title{
  91. font-size:28rpx;
  92. color:#000;
  93. text-align:center;
  94. margin-top: 30rpx;
  95. }
  96. .popup-box .tip{
  97. font-size:22rpx;
  98. color:#555;
  99. padding:0 24rpx;
  100. margin-top:25rpx;
  101. }
  102. .popup-box .bottom .item{
  103. width:50%;
  104. height:80rpx;
  105. background-color:#eeeeee;
  106. text-align:center;
  107. line-height:80rpx;
  108. font-size:24rpx;
  109. color:#666;
  110. margin-top:54rpx;
  111. }
  112. .popup-box .bottom .item.on{
  113. width: 100%;
  114. }
  115. .flex{
  116. display:flex;
  117. }
  118. .popup-box .bottom .item.grant{
  119. font-size:28rpx;
  120. color:#fff;
  121. font-weight:bold;
  122. background-color:#1b43c4;
  123. border-radius:0;
  124. padding:0;
  125. }
  126. .mask{
  127. position:fixed;
  128. top:0;
  129. right:0;
  130. left:0;
  131. bottom:0;
  132. background-color:rgba(0,0,0,0.3);
  133. z-index:311110;
  134. }
  135. </style>