authorization.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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(option) {
  27. this.authorizeType = option.type
  28. },
  29. methods:{
  30. //授权登录
  31. getuserinfo: function (e) {
  32. console.log(e)
  33. if (e.detail.userInfo) {
  34. this.wxGetUserInfo()
  35. }else{
  36. this.$util.msg('授权失败',2000)
  37. }
  38. },
  39. undGetuserinfo(){
  40. switch(this.authorizeType){
  41. case '0':
  42. this.$api.switchTabTo('/pages/tabBar/home/home')
  43. break;
  44. default:
  45. uni.navigateBack({delta: 1});
  46. }
  47. },
  48. wxGetUserInfo(){
  49. authorize.getCode('weixin').then(wechatcode =>{
  50. wx.getUserInfo({
  51. success: res => {
  52. wxLogin.wxLoginAuthorize()
  53. setTimeout(()=>{
  54. uni.navigateBack({delta: 1});
  55. },2000)
  56. }
  57. });
  58. })
  59. },
  60. }
  61. }
  62. </script>
  63. <style lang="scss">
  64. .login{
  65. width: 100%;
  66. height: auto;
  67. .model-warp.none{
  68. display: none;
  69. }
  70. .model-warp.show{
  71. display: block;
  72. }
  73. .login-main{
  74. width: 100%;
  75. display: flex;
  76. flex-direction: column;
  77. align-items: center;
  78. height: auto;
  79. padding:200rpx 0 0 0;
  80. .logo{
  81. width: 200rpx;
  82. height: 170rpx;
  83. display: block;
  84. }
  85. .logo-text{
  86. font-size: $font-size-40;
  87. line-height: 40rpx;
  88. color:$color-system;
  89. margin-top: 40rpx;
  90. }
  91. }
  92. .login-content{
  93. width: 620rpx;
  94. margin: 95rpx auto;
  95. line-height: 36rpx;
  96. font-size: $font-size-24;
  97. color: #666666;
  98. text-align: justify;
  99. }
  100. .login-form{
  101. width: 702rpx;
  102. height: auto;
  103. display: flex;
  104. flex-direction: column;
  105. align-items: center;
  106. margin: 0 auto;
  107. .login-btn{
  108. width: 654rpx;
  109. height: 80rpx;
  110. border-radius: 14rpx;
  111. font-size: $font-size-32;
  112. line-height: 80rpx;
  113. color: #FFFFFF;
  114. text-align: center;
  115. background: linear-gradient(135deg,rgba(4,190,2,1) 0%,rgba(4,183,2,1) 100%);
  116. display: flex;
  117. flex-direction: column;
  118. align-items: center;
  119. &.back{
  120. height: 76rpx;
  121. background: #FFFFFF;
  122. border: 1px solid #08A267;
  123. color: #08A267;
  124. margin-top: 30rpx;
  125. }
  126. }
  127. }
  128. }
  129. </style>