authorization.vue 3.5 KB

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