login.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view class="login-modal">
  3. <view class="modal-bg" :style="{zIndex:zindex}"></view>
  4. <view class="modal-box animated fast" :style="{zIndex:zindex+1,background:bg}" :class="show ? 'slideInUp' : 'slideOutDown'">
  5. <view class="modal-main">
  6. <view class="closed">
  7. <text @click="closed()" class="iconfont ft20 cl-notice iconbtn_close"></text>
  8. </view>
  9. <view class="lh20 ft16 cl-main ftw600 text-center">{{step == 0 ? '授权登录请求' : '授权手机号码'}}</view>
  10. <view v-if="step == 0" class="mt60">
  11. <view class="text-center ft14 cl-main">
  12. 点击登录 享受更多会员特惠?
  13. </view>
  14. <view class="mt40 flex alcenter center">
  15. <button class="btn-mid" @click="closed()" :style="{color:tempColor,background:'#F5F6FA'}" style="width: 300rpx;">拒绝</button>
  16. <button class="btn-mid" @click="getUserInfo" :style="{background:tempColor}" style="margin-left: 30rpx;width: 300rpx; color: #FFFFFF;">登录</button>
  17. </view>
  18. </view>
  19. <view v-if="step == 1" class="mt60">
  20. <view class="text-center ft14 cl-main">
  21. 点击登录 享受更多会员特惠
  22. </view>
  23. <view class="plr30 mt40">
  24. <button class="btn-big" :style="getBtnStyle">
  25. <text class="iconfont iconicon_weixin mr10 ft20"></text>微信授权手机号
  26. </button>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default{
  35. props:{
  36. zindex:{
  37. type:Number,
  38. default:402,
  39. },
  40. bg:{
  41. type:String,
  42. default:'#ffffff',
  43. },
  44. },
  45. data(){
  46. return {
  47. show:false,
  48. code:'',
  49. mdata:'',
  50. miv:'',
  51. step:0, // 1
  52. }
  53. },
  54. created(){
  55. this.show = true;
  56. // uni.login({
  57. // provider: 'weixin',
  58. // success: (loginRes)=> {
  59. // console.log(loginRes);
  60. // this.code = loginRes.code;
  61. // },
  62. // fail:()=>{
  63. // uni.showToast({
  64. // icon:'none',
  65. // title:'小程序登录失败'
  66. // });
  67. // this.show = false;
  68. // }
  69. // });
  70. },
  71. methods:{
  72. getUserInfo(e){
  73. // if(!e.detail.userInfo){
  74. // this.closed();
  75. // }else{
  76. // this.mdata = e.detail.encryptedData;
  77. // this.miv = e.detail.iv;
  78. // this.step = 1;
  79. // }
  80. uni.navigateTo({
  81. url:'/pages/login/login'
  82. })
  83. },
  84. closed(){
  85. this.show = false;
  86. setTimeout(()=>{
  87. this.$emit('closed');
  88. },400);
  89. }
  90. }
  91. }
  92. </script>
  93. <style>
  94. .login-modal{
  95. position: relative;
  96. z-index: 400;
  97. }
  98. .login-modal .modal-bg{
  99. position: fixed;
  100. z-index: 400;
  101. left: 0;
  102. top: 0;
  103. width: 100%;
  104. height: 100vh;
  105. background: rgba(0,0,0,.5);
  106. }
  107. .login-modal .modal-box{
  108. position: fixed;
  109. z-index: 401;
  110. background:#FFFFFF;
  111. left: 0;
  112. bottom: 0;
  113. width: 100%;
  114. padding-bottom:0rpx;
  115. padding-bottom:constant(safe-area-inset-bottom);
  116. padding-bottom:env(safe-area-inset-bottom);
  117. border-radius:32rpx 32rpx 0rpx 0rpx;
  118. }
  119. .login-modal .modal-main{
  120. position: relative;
  121. height: auto;
  122. overflow: hidden;
  123. min-height: 800rpx;
  124. padding-top: 64rpx;
  125. padding-bottom: 40rpx;
  126. }
  127. .login-modal .modal-main .closed{
  128. position: absolute;
  129. right: 40rpx;
  130. top: 40rpx;
  131. }
  132. </style>