authorization.vue 3.5 KB

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