authorization.vue 4.1 KB

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