authorization.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="container login">
  3. <view class="login-main">
  4. <image class="logo" src="../../static/login-logo@3x.png" mode=""></image>
  5. <text class="logo-text">生美/医美采购服务平台</text>
  6. </view>
  7. <view class="login-content">
  8. <text>您暂未授权采美采购小程序获取您的信息,将无法正常使用小程序的功能。如需正常使用,请点击“授权”按钮,并允许头像、昵称等信息的授权。</text>
  9. </view>
  10. <view class="login-form">
  11. <button class="login-btn use" type="primary" size="small" open-type="getUserInfo" lang="zh_CN" @getuserinfo="getuserinfo">微信授权</button>
  12. <view class="login-btn back" @tap="undGetuserinfo">取消</view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import {mapState,mapMutations } from 'vuex';
  18. import authorize from '@/common/config/authorize.js'
  19. import wxLogin from "@/common/config/wxLogin.js"
  20. export default{
  21. data() {
  22. return{
  23. authorizeType:''
  24. }
  25. },
  26. onLoad(e) {
  27. this.authorizeType = e.type
  28. },
  29. methods:{
  30. //授权登录
  31. getuserinfo: function (e) {
  32. if (e.detail.userInfo) {
  33. this.wxGetUserInfo()
  34. }else{
  35. this.$util.msg('授权失败',2000)
  36. }
  37. },
  38. undGetuserinfo(){
  39. switch(this.authorizeType){
  40. case '0':
  41. this.$api.switchTabTo('/pages/tabBar/home/home')
  42. break;
  43. default :
  44. uni.navigateBack({delta: 1});
  45. }
  46. },
  47. wxGetUserInfo(){
  48. authorize.getCode('weixin').then(wechatcode =>{
  49. wx.getUserInfo({
  50. success: res => {
  51. wxLogin.wxLoginAuthorize()
  52. setTimeout(()=>{
  53. uni.navigateBack({delta: 1});
  54. },2000)
  55. }
  56. });
  57. })
  58. },
  59. }
  60. }
  61. </script>
  62. <style lang="scss">
  63. .login{
  64. width: 100%;
  65. height: auto;
  66. .model-warp.none{
  67. display: none;
  68. }
  69. .model-warp.show{
  70. display: block;
  71. }
  72. .login-main{
  73. width: 100%;
  74. display: flex;
  75. flex-direction: column;
  76. align-items: center;
  77. height: auto;
  78. padding:200rpx 0 0 0;
  79. .logo{
  80. width: 200rpx;
  81. height: 170rpx;
  82. display: block;
  83. }
  84. .logo-text{
  85. font-size: $font-size-40;
  86. line-height: 40rpx;
  87. color:$color-system;
  88. margin-top: 40rpx;
  89. }
  90. }
  91. .login-content{
  92. width: 580rpx;
  93. margin: 95rpx auto;
  94. line-height: 40rpx;
  95. font-size: $font-size-24;
  96. color: #666666;
  97. text-align: justify;
  98. }
  99. .login-form{
  100. width: 702rpx;
  101. height: auto;
  102. display: flex;
  103. flex-direction: column;
  104. align-items: center;
  105. margin: 0 auto;
  106. .login-btn{
  107. width: 630rpx;
  108. height: 80rpx;
  109. border-radius: 14rpx;
  110. font-size: $font-size-32;
  111. line-height: 80rpx;
  112. color: #FFFFFF;
  113. text-align: center;
  114. background: linear-gradient(135deg,rgba(4,190,2,1) 0%,rgba(4,183,2,1) 100%);
  115. display: flex;
  116. flex-direction: column;
  117. align-items: center;
  118. &.back{
  119. height: 76rpx;
  120. background: #FFFFFF;
  121. border: 1px solid #08A267;
  122. color: #08A267;
  123. margin-top: 30rpx;
  124. }
  125. }
  126. }
  127. }
  128. </style>