authorization.vue 4.0 KB

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