authorization.vue 3.6 KB

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